From f9c72976b9ce378a1ae642ddeb8fe8bc344a37a2 Mon Sep 17 00:00:00 2001 From: Thomas Fischer <thomas.fischer@ufz.de> Date: Tue, 30 Oct 2012 12:06:31 +0100 Subject: [PATCH] moved functions trim(), replaceString(), splitString() and template functions number2str() and str2number() into namespace BaseLib --- BaseLib/DateTools.cpp | 6 +++--- BaseLib/StringTools.cpp | 4 ++-- BaseLib/StringTools.h | 3 +-- FileIO/GMSInterface.cpp | 4 ++-- FileIO/Gmsh2GeoIO.cpp | 20 ++++++++++---------- FileIO/Legacy/MeshIO.cpp | 4 ++-- FileIO/Legacy/OGSIOVer4.cpp | 4 ++-- FileIO/MeshIO/TetGenInterface.cpp | 20 ++++++++++---------- FileIO/PetrelInterface.cpp | 12 ++++++------ FileIO/RapidXmlIO/RapidVtuInterface.cpp | 6 +++--- FileIO/SHPInterface.cpp | 2 +- GeoLib/Color.cpp | 2 +- GeoLib/GEOObjects.cpp | 2 +- GeoLib/Grid.h | 6 +++--- GeoLib/SensorData.cpp | 4 ++-- GeoLib/Station.cpp | 24 ++++++++++++------------ Gui/DataView/DiagramView/DiagramList.cpp | 4 ++-- Gui/DataView/FEMConditionSetupDialog.cpp | 4 ++-- Gui/DataView/GEOModels.cpp | 12 ++++++------ Gui/DataView/GMSHPrefsDialog.cpp | 2 +- Gui/DataView/ListPropertiesDialog.cpp | 7 +++---- Gui/VtkVis/VtkRaster.cpp | 10 +++++----- Gui/mainwindow.cpp | 2 +- OGS/ProjectData.cpp | 2 +- Utils/FileConverter/ConvertSHPToGLI.cpp | 2 +- 25 files changed, 83 insertions(+), 85 deletions(-) diff --git a/BaseLib/DateTools.cpp b/BaseLib/DateTools.cpp index 275696f798f..d2850d55684 100644 --- a/BaseLib/DateTools.cpp +++ b/BaseLib/DateTools.cpp @@ -71,13 +71,13 @@ std::string date2string(double ddate) if (d < 1 || d > 31) std::cout << "Warning: date2String() -- day not in [1:31]" << std::endl; - std::string day = number2str(d); + std::string day = BaseLib::number2str(d); if (d < 10) day = "0" + day; - std::string month = number2str(m); + std::string month = BaseLib::number2str(m); if (m < 10) month = "0" + month; - std::string s = number2str(y) + "-" + month + "-" + day; + std::string s = BaseLib::number2str(y) + "-" + month + "-" + day; return s; } diff --git a/BaseLib/StringTools.cpp b/BaseLib/StringTools.cpp index 709b1645c35..63b2d79a495 100644 --- a/BaseLib/StringTools.cpp +++ b/BaseLib/StringTools.cpp @@ -12,6 +12,8 @@ #include "StringTools.h" +namespace BaseLib { + std::list<std::string> splitString(const std::string &str, char delim) { std::list<std::string> strList; @@ -47,8 +49,6 @@ void trim(std::string &str, char ch) else str.erase(str.begin(), str.end()); } -namespace BaseLib { - std::string getFileNameFromPath(const std::string &str, bool with_extension) { std::string::size_type beg1 = str.find_last_of('/'); diff --git a/BaseLib/StringTools.h b/BaseLib/StringTools.h index 3f11c0fbbf2..89af747bba5 100644 --- a/BaseLib/StringTools.h +++ b/BaseLib/StringTools.h @@ -20,6 +20,7 @@ #include <iostream> #include <ctype.h> +namespace BaseLib { /** * Splits a string into a list of strings. @@ -69,8 +70,6 @@ template<typename T> T str2number (const std::string &str) */ void trim(std::string &str, char ch=' '); -namespace BaseLib { - /** * Extract the filename from a path */ diff --git a/FileIO/GMSInterface.cpp b/FileIO/GMSInterface.cpp index 727d12feb06..47178575c90 100644 --- a/FileIO/GMSInterface.cpp +++ b/FileIO/GMSInterface.cpp @@ -42,7 +42,7 @@ int GMSInterface::readBoreholesFromGMS(std::vector<GeoLib::Point*>* boreholes, /* read all stations */ while ( getline(in, line) ) { - std::list<std::string> fields = splitString(line, '\t'); + std::list<std::string> fields = BaseLib::splitString(line, '\t'); if (fields.size() >= 5) { @@ -222,7 +222,7 @@ std::vector<std::string> GMSInterface::readSoilIDfromFile(const std::string &fil if (in.is_open()) while ( getline(in, line) ) { - trim(line); + BaseLib::trim(line); soilID.push_back(line); } in.close(); diff --git a/FileIO/Gmsh2GeoIO.cpp b/FileIO/Gmsh2GeoIO.cpp index 1e72c76dbe3..0f00fccbad2 100644 --- a/FileIO/Gmsh2GeoIO.cpp +++ b/FileIO/Gmsh2GeoIO.cpp @@ -40,7 +40,7 @@ void Gmsh2GeoIO::loadMeshAsGeometry (std::string & fname, GeoLib::GEOObjects* ge getline (ins, line); // read number of nodes getline (ins, line); - const size_t n_pnts (str2number<size_t>(line)); + const size_t n_pnts (BaseLib::str2number<size_t>(line)); std::vector<GeoLib::Point*>* pnts (new std::vector<GeoLib::Point*>); for (size_t k(0); k < n_pnts; k++) { @@ -52,15 +52,15 @@ void Gmsh2GeoIO::loadMeshAsGeometry (std::string & fname, GeoLib::GEOObjects* ge // parse x coordinate pos_beg = pos_end + 1; pos_end = line.find(" ", pos_beg); - double x (str2number<double>(line.substr(pos_beg, pos_end - pos_beg))); + double x (BaseLib::str2number<double>(line.substr(pos_beg, pos_end - pos_beg))); // parse y coordinate pos_beg = pos_end + 1; pos_end = line.find(" ", pos_beg); - double y (str2number<double>(line.substr(pos_beg, pos_end - pos_beg))); + double y (BaseLib::str2number<double>(line.substr(pos_beg, pos_end - pos_beg))); // parse z coordinate pos_beg = pos_end + 1; pos_end = line.find("\n", pos_beg); - double z (str2number<double>(line.substr(pos_beg, pos_end - pos_beg))); + double z (BaseLib::str2number<double>(line.substr(pos_beg, pos_end - pos_beg))); pnts->push_back (new GeoLib::Point (x,y,z)); } @@ -74,7 +74,7 @@ void Gmsh2GeoIO::loadMeshAsGeometry (std::string & fname, GeoLib::GEOObjects* ge getline (ins, line); // read number of elements getline (ins, line); - const size_t n_elements (str2number<size_t>(line)); + const size_t n_elements (BaseLib::str2number<size_t>(line)); GeoLib::Surface* sfc (new GeoLib::Surface (*pnts)); for (size_t k(0); k < n_elements; k++) { @@ -86,12 +86,12 @@ void Gmsh2GeoIO::loadMeshAsGeometry (std::string & fname, GeoLib::GEOObjects* ge // parse element type pos_beg = pos_end + 1; pos_end = line.find(" ", pos_beg); - size_t ele_type (str2number<size_t>(line.substr(pos_beg, pos_end - pos_beg))); + size_t ele_type (BaseLib::str2number<size_t>(line.substr(pos_beg, pos_end - pos_beg))); if (ele_type == 2) // read 3 node triangle { // parse number of tags pos_beg = pos_end + 1; pos_end = line.find(" ", pos_beg); - const size_t n_tags (str2number<size_t>(line.substr(pos_beg, + const size_t n_tags (BaseLib::str2number<size_t>(line.substr(pos_beg, pos_end - pos_beg))); // (over) read tags for (size_t j(0); j < n_tags; j++) @@ -102,17 +102,17 @@ void Gmsh2GeoIO::loadMeshAsGeometry (std::string & fname, GeoLib::GEOObjects* ge // parse first id of triangle pos_beg = pos_end + 1; pos_end = line.find(" ", pos_beg); - const size_t id0 (str2number<size_t>(line.substr(pos_beg, + const size_t id0 (BaseLib::str2number<size_t>(line.substr(pos_beg, pos_end - pos_beg)) - 1); // shift -1! // parse second id of triangle pos_beg = pos_end + 1; pos_end = line.find(" ", pos_beg); - const size_t id1 (str2number<size_t>(line.substr(pos_beg, + const size_t id1 (BaseLib::str2number<size_t>(line.substr(pos_beg, pos_end - pos_beg)) - 1); // shift -1! // parse third id of triangle pos_beg = pos_end + 1; pos_end = line.find(" ", pos_beg); - const size_t id2 (str2number<size_t>(line.substr(pos_beg, + const size_t id2 (BaseLib::str2number<size_t>(line.substr(pos_beg, pos_end - pos_beg)) - 1); // shift -1! sfc->addTriangle (pnt_id_map[id0], pnt_id_map[id1], pnt_id_map[id2]); } diff --git a/FileIO/Legacy/MeshIO.cpp b/FileIO/Legacy/MeshIO.cpp index 2a1c6b420cd..55a93e851cc 100644 --- a/FileIO/Legacy/MeshIO.cpp +++ b/FileIO/Legacy/MeshIO.cpp @@ -66,7 +66,7 @@ MeshLib::Mesh* MeshIO::loadMeshFromFile(const std::string& file_name) double x, y, z, double_dummy; unsigned idx; getline(in, line_string); - trim(line_string); + BaseLib::trim(line_string); unsigned nNodes = atoi(line_string.c_str()); std::string s; for (unsigned i = 0; i < nNodes; i++) @@ -84,7 +84,7 @@ MeshLib::Mesh* MeshIO::loadMeshFromFile(const std::string& file_name) else if (line_string.find("$ELEMENTS") != std::string::npos) { getline(in, line_string); - trim(line_string); + BaseLib::trim(line_string); unsigned nElements = atoi(line_string.c_str()); for (unsigned i = 0; i < nElements; i++) { diff --git a/FileIO/Legacy/OGSIOVer4.cpp b/FileIO/Legacy/OGSIOVer4.cpp index 85191ba7f20..47e65d3f293 100644 --- a/FileIO/Legacy/OGSIOVer4.cpp +++ b/FileIO/Legacy/OGSIOVer4.cpp @@ -193,7 +193,7 @@ std::string readPolyline(std::istream &in, == std::string::npos)) { - size_t pnt_id(str2number<size_t> (line)); + size_t pnt_id(BaseLib::str2number<size_t> (line)); if (!zero_based_indexing) pnt_id--; // one based indexing size_t ply_size (ply->getNumberOfPoints()); @@ -757,7 +757,7 @@ void writeAllDataToGLIFileV4 (const std::string& fname, const GeoLib::GEOObjects os << "\t$NAME " << std::endl << "\t\t" << sfc_name << std::endl; } else { os << "\t$NAME " << std::endl << "\t\t" << sfcs_cnt << std::endl; - sfc_name += number2str (sfcs_cnt); + sfc_name += BaseLib::number2str (sfcs_cnt); } sfc_name += ".tin"; os << "\t$TIN" << std::endl; diff --git a/FileIO/MeshIO/TetGenInterface.cpp b/FileIO/MeshIO/TetGenInterface.cpp index 585cc74cc9c..d3104df588e 100644 --- a/FileIO/MeshIO/TetGenInterface.cpp +++ b/FileIO/MeshIO/TetGenInterface.cpp @@ -122,7 +122,7 @@ bool TetGenInterface::parseNodesFileHeader(std::string &line, pos_beg = line.find_first_not_of (" "); pos_end = line.find_first_of(" ", pos_beg); if (pos_beg != std::string::npos && pos_end != std::string::npos) - n_nodes = str2number<size_t> (line.substr(pos_beg, pos_end - pos_beg)); + n_nodes = BaseLib::str2number<size_t> (line.substr(pos_beg, pos_end - pos_beg)); else { ERR("TetGenInterface::parseNodesFileHeader(): could not correct read TetGen mesh header - number of nodes"); @@ -131,11 +131,11 @@ bool TetGenInterface::parseNodesFileHeader(std::string &line, // dimension pos_beg = line.find_first_not_of (" ", pos_end); pos_end = line.find_first_of(" ", pos_beg); - dim = str2number<size_t> (line.substr(pos_beg, pos_end - pos_beg)); + dim = BaseLib::str2number<size_t> (line.substr(pos_beg, pos_end - pos_beg)); // number of attributes pos_beg = line.find_first_not_of (" ", pos_end); pos_end = line.find_first_of(" ", pos_beg); - n_attributes = str2number<size_t> (line.substr(pos_beg, pos_end - pos_beg)); + n_attributes = BaseLib::str2number<size_t> (line.substr(pos_beg, pos_end - pos_beg)); // boundary marker at nodes? pos_beg = line.find_first_not_of (" ", pos_end); pos_end = line.find_first_of(" ", pos_beg); @@ -165,7 +165,7 @@ bool TetGenInterface::parseNodes(std::ifstream& ins, size_t n_nodes, size_t dim) pos_beg = line.find_first_not_of(" ", pos_end); pos_end = line.find_first_of(" \n", pos_beg); if (pos_beg != std::string::npos && pos_end != std::string::npos) { - id = str2number<size_t> (line.substr(pos_beg, pos_end - pos_beg)); + id = BaseLib::str2number<size_t> (line.substr(pos_beg, pos_end - pos_beg)); if (k == 0 && id == 0) _zero_based_idx = true; } else { @@ -178,7 +178,7 @@ bool TetGenInterface::parseNodes(std::ifstream& ins, size_t n_nodes, size_t dim) pos_end = line.find_first_of(" \n", pos_beg); if (pos_end == std::string::npos) pos_end = line.size(); if (pos_beg != std::string::npos) - coordinates[i] = str2number<double> ( + coordinates[i] = BaseLib::str2number<double> ( line.substr(pos_beg, pos_end - pos_beg)); else { ERR("TetGenInterface::parseNodes(): error reading coordinate %d of node %d", i, k); @@ -243,7 +243,7 @@ bool TetGenInterface::parseElementsFileHeader(std::string &line, pos_beg = line.find_first_not_of (" "); pos_end = line.find_first_of(" ", pos_beg); if (pos_beg != std::string::npos && pos_end != std::string::npos) - n_tets = str2number<size_t> (line.substr(pos_beg, pos_end - pos_beg)); + n_tets = BaseLib::str2number<size_t> (line.substr(pos_beg, pos_end - pos_beg)); else { ERR("TetGenInterface::parseElementsFileHeader(): could not correct read TetGen mesh header - number of tetrahedras"); return false; @@ -251,7 +251,7 @@ bool TetGenInterface::parseElementsFileHeader(std::string &line, // nodes per tet - either 4 or 10 pos_beg = line.find_first_not_of (" \t", pos_end); pos_end = line.find_first_of(" \t", pos_beg); - n_nodes_per_tet = str2number<size_t> (line.substr(pos_beg, pos_end - pos_beg)); + n_nodes_per_tet = BaseLib::str2number<size_t> (line.substr(pos_beg, pos_end - pos_beg)); // region attribute at tetrahedra? pos_beg = line.find_first_not_of (" \t", pos_end); pos_end = line.find_first_of(" \t\n", pos_beg); @@ -285,7 +285,7 @@ bool TetGenInterface::parseElements(std::ifstream& ins, size_t n_tets, size_t n_ pos_beg = line.find_first_not_of(" ", pos_end); pos_end = line.find_first_of(" \n", pos_beg); if (pos_beg != std::string::npos && pos_end != std::string::npos) - id = str2number<size_t>(line.substr(pos_beg, pos_end - pos_beg)); + id = BaseLib::str2number<size_t>(line.substr(pos_beg, pos_end - pos_beg)); else { ERR("TetGenInterface::parseElements(): error reading id of tetrahedra %d", k); return false; @@ -299,7 +299,7 @@ bool TetGenInterface::parseElements(std::ifstream& ins, size_t n_tets, size_t n_ pos_end = line.size(); if (pos_beg != std::string::npos && pos_end != std::string::npos) - ids[i] = str2number<std::size_t>(line.substr(pos_beg, pos_end - pos_beg)); + ids[i] = BaseLib::str2number<std::size_t>(line.substr(pos_beg, pos_end - pos_beg)); else { ERR("TetGenInterface::parseElements(): error reading node %d of tetrahedra %d", i, k); @@ -319,7 +319,7 @@ bool TetGenInterface::parseElements(std::ifstream& ins, size_t n_tets, size_t n_ pos_end = line.find_first_of(" ", pos_beg); if (pos_end == std::string::npos) pos_end = line.size(); if (pos_beg != std::string::npos && pos_end != std::string::npos) - region = str2number<unsigned> (line.substr(pos_beg, pos_end - pos_beg)); + region = BaseLib::str2number<unsigned> (line.substr(pos_beg, pos_end - pos_beg)); else { ERR("TetGenInterface::parseElements(): error reading region attribute of tetrahedra %d", k); return false; diff --git a/FileIO/PetrelInterface.cpp b/FileIO/PetrelInterface.cpp index f5f41d5a319..fe1ca243159 100644 --- a/FileIO/PetrelInterface.cpp +++ b/FileIO/PetrelInterface.cpp @@ -118,7 +118,7 @@ void PetrelInterface::readPetrelWellTrace(std::istream &in) // read well name in.getline(buffer, MAX_COLS_PER_ROW); line = buffer; - std::list<std::string> str_list(splitString(line, ' ')); + std::list<std::string> str_list(BaseLib::splitString(line, ' ')); std::list<std::string>::const_iterator it(str_list.begin()); while (it != str_list.end()) std::cout << *it++ << " " << std::flush; @@ -127,7 +127,7 @@ void PetrelInterface::readPetrelWellTrace(std::istream &in) // read well head x coordinate in.getline(buffer, MAX_COLS_PER_ROW); line = buffer; - str_list = splitString(line, ' '); + str_list = BaseLib::splitString(line, ' '); it = str_list.begin(); while (it != str_list.end()) std::cout << *it++ << " " << std::flush; @@ -140,7 +140,7 @@ void PetrelInterface::readPetrelWellTrace(std::istream &in) // read well head y coordinate in.getline(buffer, MAX_COLS_PER_ROW); line = buffer; - str_list = splitString(line, ' '); + str_list = BaseLib::splitString(line, ' '); it = str_list.begin(); while (it != str_list.end()) std::cout << *it++ << " " << std::flush; @@ -152,7 +152,7 @@ void PetrelInterface::readPetrelWellTrace(std::istream &in) // read well KB in.getline(buffer, MAX_COLS_PER_ROW); line = buffer; - str_list = splitString(line, ' '); + str_list = BaseLib::splitString(line, ' '); it = str_list.begin(); while (it != str_list.end()) std::cout << *it++ << " " << std::flush; @@ -171,7 +171,7 @@ void PetrelInterface::readPetrelWellTrace(std::istream &in) // read well type in.getline(buffer, MAX_COLS_PER_ROW); line = buffer; - str_list = splitString(line, ' '); + str_list = BaseLib::splitString(line, ' '); it = str_list.begin(); while (it != str_list.end()) std::cout << *it++ << " " << std::flush; @@ -200,7 +200,7 @@ void PetrelInterface::readPetrelWellTraceData(std::istream &in) } // read column information - str_list = splitString(line, ' '); + str_list = BaseLib::splitString(line, ' '); it = str_list.begin(); while (it != str_list.end()) std::cout << *it++ << " " << std::flush; diff --git a/FileIO/RapidXmlIO/RapidVtuInterface.cpp b/FileIO/RapidXmlIO/RapidVtuInterface.cpp index f7c257d6da8..83a05b7f58d 100644 --- a/FileIO/RapidXmlIO/RapidVtuInterface.cpp +++ b/FileIO/RapidXmlIO/RapidVtuInterface.cpp @@ -355,9 +355,9 @@ int RapidVtuInterface::write(std::ostream& stream) root_node->append_node(grid_node); xml_node<> *piece_node (_doc->allocate_node(node_element, "Piece")); grid_node->append_node(piece_node); - const std::string str_nNodes (number2str(nNodes)); + const std::string str_nNodes (BaseLib::number2str(nNodes)); piece_node->append_attribute (_doc->allocate_attribute("NumberOfPoints", str_nNodes.c_str())); - const std::string str_nElems (number2str(nElems)); + const std::string str_nElems (BaseLib::number2str(nElems)); piece_node->append_attribute(_doc->allocate_attribute("NumberOfCells", str_nElems.c_str())); // scalar arrays for point- and cell-data @@ -457,7 +457,7 @@ xml_node<>* RapidVtuInterface::addDataArray(const std::string &name, const std:: dataarray_node->append_attribute(attr); if (nComponents > 1) { - attr = _doc->allocate_attribute(_doc->allocate_string("NumberOfComponents"), _doc->allocate_string(number2str(nComponents).c_str())); + attr = _doc->allocate_attribute(_doc->allocate_string("NumberOfComponents"), _doc->allocate_string(BaseLib::number2str(nComponents).c_str())); dataarray_node->append_attribute(attr); } std::string comp_type = (_use_compressor) ? "appended" : "ascii"; diff --git a/FileIO/SHPInterface.cpp b/FileIO/SHPInterface.cpp index 8fd5d0db272..d8799c2a7e4 100644 --- a/FileIO/SHPInterface.cpp +++ b/FileIO/SHPInterface.cpp @@ -79,7 +79,7 @@ void SHPInterface::readStations(const SHPHandle &hSHP, int numberOfElements, std { hSHPObject = SHPReadObject(hSHP,i); GeoLib::Station* stn = - GeoLib::Station::createStation( number2str(i), *(hSHPObject->padfX), + GeoLib::Station::createStation( BaseLib::number2str(i), *(hSHPObject->padfX), *(hSHPObject->padfY), *(hSHPObject->padfZ) ); stations->push_back(stn); diff --git a/GeoLib/Color.cpp b/GeoLib/Color.cpp index 7a4e92a821d..0564dca9ac1 100644 --- a/GeoLib/Color.cpp +++ b/GeoLib/Color.cpp @@ -37,7 +37,7 @@ int readColorLookupTable(std::map<std::string, Color*> &colors, const std::strin while ( getline(in, line) ) { - std::list<std::string> fields = splitString(line, '\t'); + std::list<std::string> fields = BaseLib::splitString(line, '\t'); Color *c = new Color(); if (fields.size()>=4) diff --git a/GeoLib/GEOObjects.cpp b/GeoLib/GEOObjects.cpp index 10ab4ba9785..b4b32df6ed4 100644 --- a/GeoLib/GEOObjects.cpp +++ b/GeoLib/GEOObjects.cpp @@ -341,7 +341,7 @@ bool GEOObjects::isUniquePointVecName(std::string &name) // If the original name already exists we start to add numbers to name for // as long as it takes to make the name unique. if (count > 1) - cpName = cpName + "-" + number2str(count); + cpName = cpName + "-" + BaseLib::number2str(count); for (size_t i = 0; i < _pnt_vecs.size(); i++) if ( cpName.compare(_pnt_vecs[i]->getName()) == 0 ) diff --git a/GeoLib/Grid.h b/GeoLib/Grid.h index 96c452b395f..c3d98bacc89 100644 --- a/GeoLib/Grid.h +++ b/GeoLib/Grid.h @@ -386,11 +386,11 @@ void Grid<POINT>::createGridGeometry(GeoLib::GEOObjects* geo_obj) const for (std::size_t k(0); k<_n_steps[2]; k++) { std::string name("Grid-"); - name += number2str<std::size_t>(i); + name += BaseLib::number2str<std::size_t>(i); name +="-"; - name += number2str<std::size_t>(j); + name += BaseLib::number2str<std::size_t>(j); name += "-"; - name += number2str<std::size_t> (k); + name += BaseLib::number2str<std::size_t> (k); grid_names.push_back(name); std::vector<GeoLib::Point*>* points (new std::vector<GeoLib::Point*>); diff --git a/GeoLib/SensorData.cpp b/GeoLib/SensorData.cpp index ecbb0080375..6e3992c36ca 100644 --- a/GeoLib/SensorData.cpp +++ b/GeoLib/SensorData.cpp @@ -102,7 +102,7 @@ int SensorData::readDataFromFile(const std::string &file_name) /* first line contains field names */ getline(in, line); - std::list<std::string> fields = splitString(line, '\t'); + std::list<std::string> fields = BaseLib::splitString(line, '\t'); std::list<std::string>::const_iterator it (fields.begin()); size_t nFields = fields.size(); @@ -122,7 +122,7 @@ int SensorData::readDataFromFile(const std::string &file_name) while ( getline(in, line) ) { - fields = splitString(line, '\t'); + fields = BaseLib::splitString(line, '\t'); if (nFields == fields.size()) { diff --git a/GeoLib/Station.cpp b/GeoLib/Station.cpp index 1c730e5769d..b672ee203b1 100644 --- a/GeoLib/Station.cpp +++ b/GeoLib/Station.cpp @@ -66,16 +66,16 @@ Station* Station::createStation(const std::string & line) { std::list<std::string>::const_iterator it; Station* station = new Station(); - std::list<std::string> fields = splitString(line, '\t'); + std::list<std::string> fields = BaseLib::splitString(line, '\t'); if (fields.size() >= 3) { it = fields.begin(); station->_name = *it; - (*station)[0] = strtod((replaceString(",", ".", *(++it))).c_str(), NULL); - (*station)[1] = strtod((replaceString(",", ".", *(++it))).c_str(), NULL); + (*station)[0] = strtod((BaseLib::replaceString(",", ".", *(++it))).c_str(), NULL); + (*station)[1] = strtod((BaseLib::replaceString(",", ".", *(++it))).c_str(), NULL); if (++it != fields.end()) - (*station)[2] = strtod((replaceString(",", ".", *it)).c_str(), NULL); + (*station)[2] = strtod((BaseLib::replaceString(",", ".", *it)).c_str(), NULL); } else { @@ -175,7 +175,7 @@ int StationBorehole::readStratigraphyFile(const std::string &path, while ( getline(in, line) ) { - std::list<std::string> fields = splitString(line, '\t'); + std::list<std::string> fields = BaseLib::splitString(line, '\t'); data.push_back(fields); } @@ -228,7 +228,7 @@ int StationBorehole::addLayer(std::list<std::string> fields, StationBorehole* bo std::cerr << "StationBorehole::addLayer - assuming correct order" << std::endl; - double thickness(strtod(replaceString(",", ".", fields.front()).c_str(), 0)); + double thickness(strtod(BaseLib::replaceString(",", ".", fields.front()).c_str(), 0)); fields.pop_front(); borehole->addSoilLayer(thickness, fields.front()); } @@ -285,7 +285,7 @@ int StationBorehole::addStratigraphies(const std::string &path, std::vector<Poin fields.pop_front(); //the method just assumes that layers are read in correct order fields.pop_front(); - double thickness (strtod(replaceString(",", ".", + double thickness (strtod(BaseLib::replaceString(",", ".", fields.front()).c_str(), 0)); fields.pop_front(); std::string soil_name (fields.front()); @@ -310,19 +310,19 @@ int StationBorehole::addStratigraphies(const std::string &path, std::vector<Poin StationBorehole* StationBorehole::createStation(const std::string &line) { StationBorehole* borehole = new StationBorehole(); - std::list<std::string> fields = splitString(line, '\t'); + std::list<std::string> fields = BaseLib::splitString(line, '\t'); if (fields.size() >= 5) { borehole->_name = fields.front(); fields.pop_front(); - (*borehole)[0] = strtod((replaceString(",", ".", fields.front())).c_str(), NULL); + (*borehole)[0] = strtod((BaseLib::replaceString(",", ".", fields.front())).c_str(), NULL); fields.pop_front(); - (*borehole)[1] = strtod((replaceString(",", ".", fields.front())).c_str(), NULL); + (*borehole)[1] = strtod((BaseLib::replaceString(",", ".", fields.front())).c_str(), NULL); fields.pop_front(); - (*borehole)[2] = strtod((replaceString(",", ".", fields.front())).c_str(), NULL); + (*borehole)[2] = strtod((BaseLib::replaceString(",", ".", fields.front())).c_str(), NULL); fields.pop_front(); - borehole->_depth = strtod((replaceString(",", ".", fields.front())).c_str(), NULL); + borehole->_depth = strtod((BaseLib::replaceString(",", ".", fields.front())).c_str(), NULL); fields.pop_front(); if (fields.empty()) borehole->_date = 0; diff --git a/Gui/DataView/DiagramView/DiagramList.cpp b/Gui/DataView/DiagramView/DiagramList.cpp index b2b20567076..ffaffd99b93 100644 --- a/Gui/DataView/DiagramView/DiagramList.cpp +++ b/Gui/DataView/DiagramView/DiagramList.cpp @@ -160,7 +160,7 @@ int DiagramList::readList(const QString &path, std::vector<DiagramList*> &lists) { DiagramList* l = new DiagramList; l->setName(fields.takeFirst()); - //value = strtod(replaceString(",", ".", fields.takeFirst().toStdString()).c_str(),0); + //value = strtod(BaseLib::replaceStringreplaceString(",", ".", fields.takeFirst().toStdString()).c_str(),0); //l->setStartDate(startDate); //l->addNextPoint(0,value); lists.push_back(l); @@ -192,7 +192,7 @@ int DiagramList::readList(const QString &path, std::vector<DiagramList*> &lists) for (int i = 0; i < nLists; i++) { - value = strtod(replaceString(",", ".",fields.takeFirst().toStdString()).c_str(),0); + value = strtod(BaseLib::replaceString(",", ".",fields.takeFirst().toStdString()).c_str(),0); lists[i]->addNextPoint(numberOfSecs,value); } } diff --git a/Gui/DataView/FEMConditionSetupDialog.cpp b/Gui/DataView/FEMConditionSetupDialog.cpp index 9fe94ee0230..fbd10102f52 100644 --- a/Gui/DataView/FEMConditionSetupDialog.cpp +++ b/Gui/DataView/FEMConditionSetupDialog.cpp @@ -307,7 +307,7 @@ void FEMConditionSetupDialog::copyCondOnPoints() FEMCondition* cond = new FEMCondition(_cond); cond->setGeoObj(NULL); cond->setGeoType(GeoLib::POINT); - cond->setGeoName(_cond.getAssociatedGeometryName() + "_Point" + number2str(ply->getPointID(i))); + cond->setGeoName(_cond.getAssociatedGeometryName() + "_Point" + BaseLib::number2str(ply->getPointID(i))); cond->clearDisValues(); cond->setConstantDisValue((*ply->getPoint(i))[2]); conditions.push_back(this->typeCast(*cond)); @@ -326,7 +326,7 @@ void FEMConditionSetupDialog::copyCondOnPoints() FEMCondition* cond = new FEMCondition(_cond); cond->setGeoObj(NULL); cond->setGeoType(GeoLib::POINT); - cond->setGeoName(_cond.getAssociatedGeometryName() + "_Point" + number2str((*tri)[j])); + cond->setGeoName(_cond.getAssociatedGeometryName() + "_Point" + BaseLib::number2str((*tri)[j])); cond->clearDisValues(); cond->setConstantDisValue((*tri->getPoint(j))[2]); conditions.push_back(this->typeCast(*cond)); diff --git a/Gui/DataView/GEOModels.cpp b/Gui/DataView/GEOModels.cpp index 7ffb6a263e2..db05fa64d0f 100644 --- a/Gui/DataView/GEOModels.cpp +++ b/Gui/DataView/GEOModels.cpp @@ -44,7 +44,7 @@ void GEOModels::updateGeometry(const std::string &geo_name) this->_geoModel->removeGeoList(geo_name, GeoLib::POINT); _geoModel->addPointList(QString::fromStdString(geo_name), points); emit geoDataAdded(_geoModel, geo_name, GeoLib::POINT); - + if (lines) { emit geoDataRemoved(_geoModel, geo_name, GeoLib::POLYLINE); @@ -52,7 +52,7 @@ void GEOModels::updateGeometry(const std::string &geo_name) _geoModel->addPolylineList(QString::fromStdString(geo_name), lines); emit geoDataAdded(_geoModel, geo_name, GeoLib::POLYLINE); } - + if (surfaces) { emit geoDataRemoved(_geoModel, geo_name, GeoLib::SURFACE); @@ -268,7 +268,7 @@ void GEOModels::addNameForObjectPoints(const std::string &geometry_name, const G const GeoLib::Polyline* ply = dynamic_cast<const GeoLib::Polyline*>(obj); size_t nPoints = ply->getNumberOfPoints(); for (size_t i=0; i<nPoints; i++) - pnt_vec->setNameForElement(ply->getPointID(i), new_name + "_Point" + number2str(ply->getPointID(i))); + pnt_vec->setNameForElement(ply->getPointID(i), new_name + "_Point" + BaseLib::number2str(ply->getPointID(i))); } else if (object_type == GeoLib::SURFACE) { @@ -277,9 +277,9 @@ void GEOModels::addNameForObjectPoints(const std::string &geometry_name, const G for (size_t i=0; i<nTriangles; i++) { const GeoLib::Triangle* tri = (*sfc)[i]; - pnt_vec->setNameForElement((*tri)[0], new_name + "_Point" + number2str((*tri)[0])); - pnt_vec->setNameForElement((*tri)[1], new_name + "_Point" + number2str((*tri)[1])); - pnt_vec->setNameForElement((*tri)[2], new_name + "_Point" + number2str((*tri)[2])); + pnt_vec->setNameForElement((*tri)[0], new_name + "_Point" + BaseLib::number2str((*tri)[0])); + pnt_vec->setNameForElement((*tri)[1], new_name + "_Point" + BaseLib::number2str((*tri)[1])); + pnt_vec->setNameForElement((*tri)[2], new_name + "_Point" + BaseLib::number2str((*tri)[2])); } } else diff --git a/Gui/DataView/GMSHPrefsDialog.cpp b/Gui/DataView/GMSHPrefsDialog.cpp index c7e85c0a055..abfe017dcf7 100644 --- a/Gui/DataView/GMSHPrefsDialog.cpp +++ b/Gui/DataView/GMSHPrefsDialog.cpp @@ -153,7 +153,7 @@ void GMSHPrefsDialog::accept() if (this->radioAdaptive->isChecked()) { - max_number_of_points_in_quadtree_leaf = str2number<unsigned> ( + max_number_of_points_in_quadtree_leaf = BaseLib::str2number<unsigned> ( param1->text().toStdString().c_str()); if (max_number_of_points_in_quadtree_leaf == 0) max_number_of_points_in_quadtree_leaf = 10; diff --git a/Gui/DataView/ListPropertiesDialog.cpp b/Gui/DataView/ListPropertiesDialog.cpp index a4c6e82ecad..dd4153e0062 100644 --- a/Gui/DataView/ListPropertiesDialog.cpp +++ b/Gui/DataView/ListPropertiesDialog.cpp @@ -136,11 +136,10 @@ void ListPropertiesDialog::accept() } else { - minVal = strtod(replaceString(",", ".", + minVal = strtod(BaseLib::replaceString(",", ".", _minValue[i]->text().toStdString()).c_str(),0); - maxVal = strtod(replaceString(",", ".", - _maxValue[i]->text().toStdString()).c_str(), - 0); + maxVal = strtod(BaseLib::replaceString(",", ".", + _maxValue[i]->text().toStdString()).c_str(),0); } PropertyBounds b(_propLabel[i]->text().toStdString(), minVal, maxVal); bounds.push_back(b); diff --git a/Gui/VtkVis/VtkRaster.cpp b/Gui/VtkVis/VtkRaster.cpp index e54b9597ac9..593a51c9d32 100644 --- a/Gui/VtkVis/VtkRaster.cpp +++ b/Gui/VtkVis/VtkRaster.cpp @@ -139,7 +139,7 @@ bool VtkRaster::readASCHeader(ascHeader &header, std::ifstream &in) if (tag.compare("xllcorner") == 0) { in >> value; - header.x = strtod(replaceString(",", ".", value).c_str(),0); + header.x = strtod(BaseLib::replaceString(",", ".", value).c_str(),0); } else return false; @@ -147,7 +147,7 @@ bool VtkRaster::readASCHeader(ascHeader &header, std::ifstream &in) if (tag.compare("yllcorner") == 0) { in >> value; - header.y = strtod(replaceString(",", ".", value).c_str(),0); + header.y = strtod(BaseLib::replaceString(",", ".", value).c_str(),0); } else return false; @@ -155,7 +155,7 @@ bool VtkRaster::readASCHeader(ascHeader &header, std::ifstream &in) if (tag.compare("cellsize") == 0) { in >> value; - header.cellsize = strtod(replaceString(",", ".", value).c_str(),0); + header.cellsize = strtod(BaseLib::replaceString(",", ".", value).c_str(),0); } else return false; @@ -215,7 +215,7 @@ float* VtkRaster::loadDataFromASC(const std::string &fileName, { in >> s; unsigned index = 2*(col_index+i); - values[index] = static_cast<float>(strtod(replaceString(",", ".", s).c_str(),0)); + values[index] = static_cast<float>(strtod(BaseLib::replaceString(",", ".", s).c_str(),0)); if (values[index] > max_val) max_val = values[index]; } @@ -318,7 +318,7 @@ float* VtkRaster::loadDataFromSurfer(const std::string &fileName, if (s.compare(header.noData) == 0) s = "-9999"; unsigned index = 2*(col_index+i); - values[index] = static_cast<float>(strtod(replaceString(",", ".", s).c_str(),0)); + values[index] = static_cast<float>(strtod(BaseLib::replaceString(",", ".", s).c_str(),0)); if (values[index] > max_val) max_val = values[index]; } diff --git a/Gui/mainwindow.cpp b/Gui/mainwindow.cpp index f3b39a758f0..a1a45b4a6e9 100644 --- a/Gui/mainwindow.cpp +++ b/Gui/mainwindow.cpp @@ -1237,7 +1237,7 @@ void MainWindow::on_actionExportVTK_triggered(bool checked /*= false*/) { count++; static_cast<VtkVisPipelineItem*> (*it)->writeToFile(basename - + number2str(count)); + + BaseLib::number2str(count)); ++it; } } diff --git a/OGS/ProjectData.cpp b/OGS/ProjectData.cpp index 318f207f1a6..22ab8ea8b7d 100644 --- a/OGS/ProjectData.cpp +++ b/OGS/ProjectData.cpp @@ -210,7 +210,7 @@ bool ProjectData::isUniqueMeshName(std::string &name) // If the original name already exists we start to add numbers to name for // as long as it takes to make the name unique. if (count > 1) - cpName = cpName + "-" + number2str(count); + cpName = cpName + "-" + BaseLib::number2str(count); for (std::vector<MeshLib::Mesh*>::iterator it = _msh_vec.begin(); it != _msh_vec.end(); ++it) if ( cpName.compare((*it)->getName()) == 0 ) diff --git a/Utils/FileConverter/ConvertSHPToGLI.cpp b/Utils/FileConverter/ConvertSHPToGLI.cpp index 954bbcb45ee..7276ec255b0 100644 --- a/Utils/FileConverter/ConvertSHPToGLI.cpp +++ b/Utils/FileConverter/ConvertSHPToGLI.cpp @@ -87,7 +87,7 @@ void convertPoints (DBFHandle dbf_handle, name += DBFReadStringAttribute(dbf_handle, k, name_component_ids[j]); name += " "; } - } else name = number2str(k); + } else name = BaseLib::number2str(k); if (station) { GeoLib::Station* pnt(GeoLib::Station::createStation(name, x, y, z)); -- GitLab