diff --git a/BaseLib/DateTools.cpp b/BaseLib/DateTools.cpp index 48f4550ea61773f2b125147c303642a61bbe47cf..37bf369e6691d2f95fe397198035812ab4222c32 100644 --- a/BaseLib/DateTools.cpp +++ b/BaseLib/DateTools.cpp @@ -13,17 +13,21 @@ */ #include "DateTools.h" + #include <cmath> #include <cstdlib> #include <iostream> -namespace BaseLib { +// ThirdParty/logog +#include "logog/include/logog.hpp" +namespace BaseLib +{ int date2int(int y, int m, int d) { if ( (y < 1000 || y > 9999) || (m < 1 || m > 12) || (d < 1 || d > 31) ) { - std::cout << "Error: date2double() -- input not in expected format." << std::endl; + WARN("date2int(): Input not in expected range."); return 0; } @@ -37,16 +41,16 @@ int date2int(int y, int m, int d) std::string int2date(int date) { - if (date>10000000 && date<22000000) + if (date > 10000000 && date < 22000000) { - int y = static_cast<int>(floor(date/10000.0)); - int m = static_cast<int>(floor((date-(y*10000))/100.0)); - int d = date-(y*10000)-(m*100); + int y = static_cast<int>(floor(date / 10000.0)); + int m = static_cast<int>(floor((date - (y * 10000)) / 100.0)); + int d = date - (y * 10000) - (m * 100); std::stringstream ss; - if (d<10) + if (d < 10) ss << "0"; ss << d << "."; - if (m<10) + if (m < 10) ss << "0"; ss << m << "." << y; return ss.str(); @@ -58,7 +62,7 @@ std::string date2string(double ddate) { if (ddate < 10000101 || ddate > 99991231) { - std::cout << "Error: date2String() -- input not in expected format." << std::endl; + WARN("date2String(): Input not in expected format."); return "0.0.0000"; } @@ -67,11 +71,11 @@ std::string date2string(double ddate) rest = rest % (y * 10000); int m = static_cast<int>(floor(rest / 100.0)); if (m < 1 || m > 12) - std::cout << "Warning: date2String() -- month not in [1:12]" << std::endl; + WARN("date2String(): month not in [1:12]."); rest = rest % (m * 100); int d = rest; if (d < 1 || d > 31) - std::cout << "Warning: date2String() -- day not in [1:31]" << std::endl; + WARN("date2String(): day not in [1:31]."); std::string day = BaseLib::number2str(d); if (d < 10) @@ -102,15 +106,13 @@ int xmlDate2int(const std::string &s) { int d = atoi(s.substr(8,2).c_str()); if (d < 1 || d > 31) - std::cout << "Warning: xmlDate2double() -- day not in [1:31]" << std::endl; + WARN("xmlDate2double(): day not in [1:31]."); int m = atoi(s.substr(5,2).c_str()); if (m < 1 || m > 12) - std::cout << "Warning: xmlDate2double() -- month not in [1:12]" << - std::endl; + WARN("xmlDate2double(): month not in [1:12]."); int y = atoi(s.substr(0,4).c_str()); return date2int(y, m, d); } return 0; } - } // end namespace BaseLib diff --git a/BaseLib/FileFinder.h b/BaseLib/FileFinder.h index 36ecb628f6ef93f595c7bb1ea1505585b88ebe03..db0d0e5dba3ddf035ebec6d591aab808ea244911 100644 --- a/BaseLib/FileFinder.h +++ b/BaseLib/FileFinder.h @@ -15,12 +15,15 @@ #ifndef FILEFINDER_H #define FILEFINDER_H -#include <iostream> #include <fstream> #include <string> -#include <list> +#include <vector> -namespace BaseLib { +// ThirdParty/logog +#include "logog/include/logog.hpp" + +namespace BaseLib +{ /** * FileFinder stores a list of directories and will return the complete path * for a given filename if the corresponding file is found in any of these @@ -30,40 +33,50 @@ class FileFinder { public: /// Constructor - FileFinder() {}; + FileFinder() {} /** * \brief Adds another directory to the search-space. * If the given directory does not end with a slash one will be appended. */ - void addDirectory(std::string dir) + void addDirectory(std::string const& dir) { - if (dir[dir.size()-1] != '/') dir.append("/"); - _directories.push_back(dir); - }; + if (dir.empty()) + return; + + if (dir[dir.size() - 1] != '/') + _directories.push_back(std::string(dir + "/")); + else + _directories.push_back(dir); + } /** * Given a filename, this method will return the complete path where this file can be found. * If the file is located in more than one of the directories in the search list, only the * first location will be returned. */ - std::string getPath(std::string filename) const + std::string getPath(std::string const& filename) const { - if (_directories.empty()) std::cout << "Error: FileFinder::getPath() -- directory list is empty." << std::endl; - for (std::list<std::string>::const_iterator it = _directories.begin(); it != _directories.end(); ++it) + if (_directories.empty()) + ERR("FileFinder::getPath(): No directories set."); + + for (auto it = _directories.begin(); it != _directories.end(); ++it) { std::string testDir(*it); std::ifstream is(testDir.append(filename).c_str()); - if (is.good()) return testDir; + if (is.good()) + { + is.close(); + return testDir; + } } - std::cout << "Error: FileFinder::getPath() -- file not found." << std::endl; + ERR("FileFinder::getPath(): File not found."); return filename; - }; + } private: - std::list<std::string> _directories; + std::vector<std::string> _directories; }; - } // end namespace BaseLib #endif // FILEFINDER_H diff --git a/BaseLib/StringTools.cpp b/BaseLib/StringTools.cpp index 85ea397cba52e16e874c4d57b91d1507f97b366c..778ffef9898beb36bcdd4d1e2763a34f6cc03aaf 100644 --- a/BaseLib/StringTools.cpp +++ b/BaseLib/StringTools.cpp @@ -12,26 +12,30 @@ * */ -#include "StringTools.h" - #include <algorithm> #include <cctype> -namespace BaseLib { +// ThirdParty/logog +#include "logog/include/logog.hpp" + +#include "StringTools.h" +namespace BaseLib +{ std::list<std::string> splitString(const std::string &str, char delim) { std::list<std::string> strList; std::stringstream ss(str); - std::string item; - while(getline(ss, item, delim)) { - strList.push_back(item); - } - return strList; + std::string item; + while(getline(ss, item, delim)) + strList.push_back(item); + return strList; } -std::string replaceString(const std::string &searchString, const std::string &replaceString, std::string stringToReplace) - { +std::string replaceString(const std::string &searchString, + const std::string &replaceString, + std::string stringToReplace) +{ std::string::size_type pos = stringToReplace.find(searchString, 0); int intLengthSearch = searchString.length(); @@ -44,14 +48,16 @@ std::string replaceString(const std::string &searchString, const std::string &re void trim(std::string &str, char ch) { - std::string::size_type pos = str.find_last_not_of(ch); - if(pos != std::string::npos) - { - str.erase(pos + 1); - pos = str.find_first_not_of(ch); - if(pos != std::string::npos) str.erase(0, pos); - } - else str.erase(str.begin(), str.end()); + std::string::size_type pos = str.find_last_not_of(ch); + if(pos != std::string::npos) + { + str.erase(pos + 1); + pos = str.find_first_not_of(ch); + if(pos != std::string::npos) + str.erase(0, pos); + } + else + str.erase(str.begin(), str.end()); } std::string stringToUpper(std::string const& str) @@ -60,10 +66,8 @@ std::string stringToUpper(std::string const& str) std::transform(s.begin(), s.end(), s.begin(), (int(*)(int)) std::toupper); return s; } - } // end namespace BaseLib - #ifdef MSVC void correctScientificNotation(std::string filename, size_t precision) { @@ -76,7 +80,7 @@ void correctScientificNotation(std::string filename, size_t precision) if (!stream) { - std::cout << "correctScientificNotation: fstream is not open" << std::endl; + WARN("correctScientificNotation: fstream is not open."); return; } @@ -126,5 +130,3 @@ void correctScientificNotation(std::string filename, size_t precision) rename(tmpFilename.c_str(), filename.c_str()); } #endif - - diff --git a/BaseLib/printList.h b/BaseLib/printList.h deleted file mode 100644 index 2ca61ea8291b2e30b44df9d52ca58c2f236b1d71..0000000000000000000000000000000000000000 --- a/BaseLib/printList.h +++ /dev/null @@ -1,37 +0,0 @@ -/** - * \file - * \author Thomas Fischer - * \date 2011-02-23 - * \brief Definition of the printList function. - * - * \copyright - * Copyright (c) 2013, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#ifndef PRINTLIST_H_ -#define PRINTLIST_H_ - -// STL -#include <list> -#include <string> -#include <iostream> - -namespace BaseLib { - -void printList (std::list<std::size_t> const& mylist, std::string const& title) -{ - std::cout << title << std::endl; - for (std::list<std::size_t>::const_iterator my_it (mylist.begin()); - my_it != mylist.end(); my_it++) { - std::cout << *my_it << " "; - } - std::cout << std::endl; -} - -} // end namespace BaseLib - -#endif /* PRINTLIST_H_ */ diff --git a/MathLib/EarClippingTriangulation.cpp b/MathLib/EarClippingTriangulation.cpp index 5c4d6d46a273e0877ee004bc57005aed2ec8a6eb..ede63e70c3d45f96393b9498a009ca69e60c853a 100644 --- a/MathLib/EarClippingTriangulation.cpp +++ b/MathLib/EarClippingTriangulation.cpp @@ -16,7 +16,6 @@ #include <vector> // BaseLib -#include "printList.h" #include "uniqueInsert.h" // MathLib