diff --git a/BaseLib/ConfigTree.cpp b/BaseLib/ConfigTree.cpp index bc7be50d3365e52f7f236de7e18c55935b4dcffe..ab87cca03bd5a1fbb27dfbf4f5da5a5d3b3dd3d7 100644 --- a/BaseLib/ConfigTree.cpp +++ b/BaseLib/ConfigTree.cpp @@ -12,9 +12,9 @@ #include <forward_list> #include <utility> -#include "Logging.h" #include "Error.h" +#include "Logging.h" // Explicitly instantiate the boost::property_tree::ptree which is a typedef to // the following basic_ptree. @@ -27,7 +27,6 @@ static std::forward_list<std::string> configtree_destructor_error_messages; namespace BaseLib { - const char ConfigTree::pathseparator = '/'; const std::string ConfigTree::key_chars_start = "abcdefghijklmnopqrstuvwxyz"; const std::string ConfigTree::key_chars = key_chars_start + "_0123456789"; @@ -84,17 +83,18 @@ ConfigTree::~ConfigTree() return; } - try { + try + { checkAndInvalidate(); - } catch (std::exception& e) { + } + catch (std::exception& e) + { ERR("{:s}", e.what()); configtree_destructor_error_messages.push_front(e.what()); } } -ConfigTree& -ConfigTree:: -operator=(ConfigTree&& other) +ConfigTree& ConfigTree::operator=(ConfigTree&& other) { checkAndInvalidate(); @@ -110,9 +110,7 @@ operator=(ConfigTree&& other) return *this; } -ConfigTree -ConfigTree:: -getConfigParameter(std::string const& root) const +ConfigTree ConfigTree::getConfigParameter(std::string const& root) const { auto ct = getConfigSubtree(root); if (ct.hasChildren()) @@ -133,25 +131,22 @@ std::optional<ConfigTree> ConfigTree::getConfigParameterOptional( return ct; } -Range<ConfigTree::ParameterIterator> -ConfigTree:: -getConfigParameterList(const std::string ¶m) const +Range<ConfigTree::ParameterIterator> ConfigTree::getConfigParameterList( + const std::string& param) const { checkUnique(param); markVisited(param, Attr::TAG, true); auto p = tree_->equal_range(param); - return Range<ParameterIterator>( - ParameterIterator(p.first, param, *this), - ParameterIterator(p.second, param, *this)); + return Range<ParameterIterator>(ParameterIterator(p.first, param, *this), + ParameterIterator(p.second, param, *this)); } -ConfigTree -ConfigTree:: -getConfigSubtree(std::string const& root) const +ConfigTree ConfigTree::getConfigSubtree(std::string const& root) const { - if (auto t = getConfigSubtreeOptional(root)) { + if (auto t = getConfigSubtreeOptional(root)) + { return std::move(*t); } error("Key <" + root + "> has not been found."); @@ -171,21 +166,19 @@ std::optional<ConfigTree> ConfigTree::getConfigSubtreeOptional( return std::nullopt; } -Range<ConfigTree::SubtreeIterator> -ConfigTree:: -getConfigSubtreeList(std::string const& root) const +Range<ConfigTree::SubtreeIterator> ConfigTree::getConfigSubtreeList( + std::string const& root) const { checkUnique(root); markVisited(root, Attr::TAG, true); auto p = tree_->equal_range(root); - return Range<SubtreeIterator>( - SubtreeIterator(p.first, root, *this), - SubtreeIterator(p.second, root, *this)); + return Range<SubtreeIterator>(SubtreeIterator(p.first, root, *this), + SubtreeIterator(p.second, root, *this)); } -void ConfigTree::ignoreConfigParameter(const std::string ¶m) const +void ConfigTree::ignoreConfigParameter(const std::string& param) const { checkUnique(param); // if not found, peek only @@ -193,7 +186,7 @@ void ConfigTree::ignoreConfigParameter(const std::string ¶m) const markVisited(param, Attr::TAG, peek_only); } -void ConfigTree::ignoreConfigAttribute(const std::string &attr) const +void ConfigTree::ignoreConfigAttribute(const std::string& attr) const { checkUniqueAttr(attr); @@ -204,18 +197,18 @@ void ConfigTree::ignoreConfigAttribute(const std::string &attr) const markVisited(attr, Attr::ATTR, peek_only); } -void ConfigTree::ignoreConfigParameterAll(const std::string ¶m) const +void ConfigTree::ignoreConfigParameterAll(const std::string& param) const { checkUnique(param); auto& ct = markVisited(param, Attr::TAG, true); auto p = tree_->equal_range(param); - for (auto it = p.first; it != p.second; ++it) { + for (auto it = p.first; it != p.second; ++it) + { ++ct.count; } } - void ConfigTree::error(const std::string& message) const { onerror_(filename_, path_, message); @@ -229,16 +222,15 @@ void ConfigTree::warning(const std::string& message) const onwarning_(filename_, path_, message); } - void ConfigTree::onerror(const std::string& filename, const std::string& path, - const std::string& message) + const std::string& message) { OGS_FATAL("ConfigTree: In file `{:s}' at path <{:s}>: {:s}", filename, path, message); } void ConfigTree::onwarning(const std::string& filename, const std::string& path, - const std::string& message) + const std::string& message) { WARN("ConfigTree: In file `{:s}' at path <{:s}>: {:s}", filename, path, message); @@ -254,14 +246,15 @@ void ConfigTree::assertNoSwallowedErrors() ERR("ConfigTree: There have been errors when parsing the configuration " "file(s):"); - for (auto const& msg : configtree_destructor_error_messages) { + for (auto const& msg : configtree_destructor_error_messages) + { ERR("{:s}", msg); } OGS_FATAL("There have been errors when parsing the configuration file(s)."); } -std::string ConfigTree::shortString(const std::string &s) +std::string ConfigTree::shortString(const std::string& s) { const std::size_t maxlen = 100; @@ -270,19 +263,25 @@ std::string ConfigTree::shortString(const std::string &s) return s; } - return s.substr(0, maxlen-3) + "..."; + return s.substr(0, maxlen - 3) + "..."; } - void ConfigTree::checkKeyname(std::string const& key) const { - if (key.empty()) { + if (key.empty()) + { error("Search for empty key."); - } else if (key_chars_start.find(key.front()) == std::string::npos) { + } + else if (key_chars_start.find(key.front()) == std::string::npos) + { error("Key <" + key + "> starts with an illegal character."); - } else if (key.find_first_not_of(key_chars, 1) != std::string::npos) { + } + else if (key.find_first_not_of(key_chars, 1) != std::string::npos) + { error("Key <" + key + "> contains illegal characters."); - } else if (key.find("__") != std::string::npos) { + } + else if (key.find("__") != std::string::npos) + { // This is illegal because we use parameter names to generate doxygen // page names. Thereby "__" acts as a separator character. Choosing // other separators is not possible because of observed limitations @@ -291,10 +290,11 @@ void ConfigTree::checkKeyname(std::string const& key) const } } -std::string ConfigTree:: -joinPaths( const std::string &p1, const std::string &p2) const +std::string ConfigTree::joinPaths(const std::string& p1, + const std::string& p2) const { - if (p2.empty()) { + if (p2.empty()) + { error("Second path to be joined is empty."); } @@ -306,7 +306,7 @@ joinPaths( const std::string &p1, const std::string &p2) const return p1 + pathseparator + p2; } -void ConfigTree::checkUnique(const std::string &key) const +void ConfigTree::checkUnique(const std::string& key) const { checkKeyname(key); @@ -316,9 +316,10 @@ void ConfigTree::checkUnique(const std::string &key) const } } -void ConfigTree::checkUniqueAttr(const std::string &attr) const +void ConfigTree::checkUniqueAttr(const std::string& attr) const { - // Workaround for handling attributes with xml namespaces and uppercase letters. + // Workaround for handling attributes with xml namespaces and uppercase + // letters. if (attr.find(':') != std::string::npos) { auto pos = decltype(std::string::npos){0}; @@ -327,7 +328,8 @@ void ConfigTree::checkUniqueAttr(const std::string &attr) const // That means, attributes containing a colon are also allowed to contain // uppercase letters. auto attr2 = attr; - do { + do + { pos = attr2.find_first_of(":ABCDEFGHIJKLMNOPQRSTUVWXYZ", pos); if (pos != std::string::npos) { @@ -348,30 +350,29 @@ void ConfigTree::checkUniqueAttr(const std::string &attr) const } } -ConfigTree::CountType& -ConfigTree:: -markVisited(std::string const& key, Attr const is_attr, bool const peek_only) const +ConfigTree::CountType& ConfigTree::markVisited(std::string const& key, + Attr const is_attr, + bool const peek_only) const { return markVisited<ConfigTree>(key, is_attr, peek_only); } -void -ConfigTree:: -markVisitedDecrement(Attr const is_attr, std::string const& key) const +void ConfigTree::markVisitedDecrement(Attr const is_attr, + std::string const& key) const { auto const type = std::type_index(typeid(nullptr)); auto p = visited_params_.emplace(std::make_pair(is_attr, key), CountType{-1, type}); - if (!p.second) { // no insertion happened + if (!p.second) + { // no insertion happened auto& v = p.first->second; --v.count; } } -bool -ConfigTree::hasChildren() const +bool ConfigTree::hasChildren() const { auto const& tree = *tree_; if (tree.begin() == tree.end()) @@ -386,8 +387,7 @@ ConfigTree::hasChildren() const return true; } -void -ConfigTree::checkAndInvalidate() +void ConfigTree::checkAndInvalidate() { if (!tree_) { @@ -415,48 +415,59 @@ ConfigTree::checkAndInvalidate() // iterate over attributes if (auto attrs = tree_->get_child_optional("<xmlattr>")) { - for (auto const& p : *attrs) { + for (auto const& p : *attrs) + { markVisitedDecrement(Attr::ATTR, p.first); } } for (auto const& p : visited_params_) { - auto const& tag = p.first.second; + auto const& tag = p.first.second; auto const& count = p.second.count; - switch (p.first.first) { - case Attr::ATTR: - if (count > 0) { - warning("XML attribute '" + tag + "' has been read " + - std::to_string(count) + - " time(s) more than it was present in the " - "configuration tree."); - } else if (count < 0) { - warning("XML attribute '" + tag + "' has been read " + - std::to_string(-count) + - " time(s) less than it was present in the " - "configuration tree."); - } - break; - case Attr::TAG: - if (count > 0) { - warning("Key <" + tag + "> has been read " + std::to_string(count) - + " time(s) more than it was present in the configuration tree."); - } else if (count < 0) { - warning("Key <" + tag + "> has been read " + std::to_string(-count) - + " time(s) less than it was present in the configuration tree."); - } + switch (p.first.first) + { + case Attr::ATTR: + if (count > 0) + { + warning("XML attribute '" + tag + "' has been read " + + std::to_string(count) + + " time(s) more than it was present in the " + "configuration tree."); + } + else if (count < 0) + { + warning("XML attribute '" + tag + "' has been read " + + std::to_string(-count) + + " time(s) less than it was present in the " + "configuration tree."); + } + break; + case Attr::TAG: + if (count > 0) + { + warning("Key <" + tag + "> has been read " + + std::to_string(count) + + " time(s) more than it was present in the " + "configuration tree."); + } + else if (count < 0) + { + warning("Key <" + tag + "> has been read " + + std::to_string(-count) + + " time(s) less than it was present in the " + "configuration tree."); + } } } - // The following invalidates this instance, s.t. it can not be read from it anymore, - // but it also prevents double-checking. + // The following invalidates this instance, s.t. it can not be read from it + // anymore, but it also prevents double-checking. tree_ = nullptr; } - -void checkAndInvalidate(ConfigTree &conf) +void checkAndInvalidate(ConfigTree& conf) { conf.checkAndInvalidate(); } diff --git a/BaseLib/DateTools.cpp b/BaseLib/DateTools.cpp index 3558de5977e934b47ad3832b18e400c4b42f4535..28ddc226a87e88f758280e8837e54324264f3431 100644 --- a/BaseLib/DateTools.cpp +++ b/BaseLib/DateTools.cpp @@ -25,7 +25,7 @@ namespace BaseLib { int date2int(int y, int m, int d) { - if ( (y < 1000 || y > 9999) || (m < 1 || m > 12) || (d < 1 || d > 31) ) + if ((y < 1000 || y > 9999) || (m < 1 || m > 12) || (d < 1 || d > 31)) { WARN("date2int(): Input not in expected range."); return 0; @@ -95,40 +95,40 @@ std::string date2string(double ddate) { month = "0" + month; } - std::string s = std::to_string(y) + "-" + month + "-" + day; + std::string s = std::to_string(y) + "-" + month + "-" + day; return s; } -int strDate2int(const std::string &s) +int strDate2int(const std::string& s) { std::string str(s); if (s.length() > 10) { str = s.substr(0, 10); } - std::size_t sep ( str.find('.',0) ); - int d ( atoi(str.substr(0, sep).c_str()) ); - std::size_t sep2 ( str.find('.', sep + 1) ); - int m ( atoi(str.substr(sep + 1,sep2 - (sep + 1)).c_str()) ); - int y ( atoi(str.substr(sep2 + 1, s.length() - (sep2 + 1)).c_str()) ); + std::size_t sep(str.find('.', 0)); + int d(atoi(str.substr(0, sep).c_str())); + std::size_t sep2(str.find('.', sep + 1)); + int m(atoi(str.substr(sep + 1, sep2 - (sep + 1)).c_str())); + int y(atoi(str.substr(sep2 + 1, s.length() - (sep2 + 1)).c_str())); return date2int(y, m, d); } -int xmlDate2int(const std::string &s) +int xmlDate2int(const std::string& s) { if (s.length() == 10) { - int d = atoi(s.substr(8,2).c_str()); + int d = atoi(s.substr(8, 2).c_str()); if (d < 1 || d > 31) { WARN("xmlDate2double(): day not in [1:31]."); } - int m = atoi(s.substr(5,2).c_str()); + int m = atoi(s.substr(5, 2).c_str()); if (m < 1 || m > 12) { WARN("xmlDate2double(): month not in [1:12]."); } - int y = atoi(s.substr(0,4).c_str()); + int y = atoi(s.substr(0, 4).c_str()); return date2int(y, m, d); } return 0; @@ -140,9 +140,10 @@ std::string formatDate( auto const time_t = std::chrono::system_clock::to_time_t(time); char time_str[100]; if (std::strftime(time_str, sizeof(time_str), "%Y-%m-%d %H:%M:%S%z", - std::localtime(&time_t))) { + std::localtime(&time_t))) + { return time_str; } return "FAILED FORMATTING THE GIVEN TIME POINT."; } -} // end namespace BaseLib +} // end namespace BaseLib diff --git a/BaseLib/FileTools.cpp b/BaseLib/FileTools.cpp index a70cd564db3c97cf03e5ff7a9e614572d420af1a..2cb4c7bb0990e2f6a94c782ec56af7c815015fa4 100644 --- a/BaseLib/FileTools.cpp +++ b/BaseLib/FileTools.cpp @@ -12,15 +12,15 @@ * */ -#include <unordered_map> +#include "FileTools.h" + +#include <boost/algorithm/string.hpp> #include <typeindex> +#include <unordered_map> -#include "FileTools.h" #include "Error.h" #include "filesystem.h" -#include <boost/algorithm/string.hpp> - namespace { /// The directory where the prj file resides. @@ -35,7 +35,7 @@ namespace BaseLib /** * Returns true if given file exists. */ -bool IsFileExisting(const std::string &strFilename) +bool IsFileExisting(const std::string& strFilename) { return fs::exists(fs::path(strFilename)); } @@ -88,7 +88,7 @@ bool substituteKeyword(std::string& result, std::string& parenthesized_string, std::unordered_map<std::type_index, char> type_specification; type_specification[std::type_index(typeid(int))] = 'd'; - type_specification[std::type_index(typeid(double))] = 'f'; // default + type_specification[std::type_index(typeid(double))] = 'f'; // default type_specification[std::type_index(typeid(std::string))] = 's'; auto const& b = precision_specification.back(); @@ -145,7 +145,7 @@ double swapEndianness(double const& v) { double v; char c[sizeof(double)]; - } a {}, b {}; + } a{}, b{}; a.v = v; for (unsigned short i = 0; i < sizeof(double) / 2; i++) @@ -178,7 +178,7 @@ std::string extractBaseNameWithoutExtension(std::string const& pathname) return dropFileExtension(basename); } -std::string getFileExtension(const std::string &path) +std::string getFileExtension(const std::string& path) { return fs::path(path).extension().string(); } @@ -188,11 +188,11 @@ bool hasFileExtension(std::string const& extension, std::string const& filename) return boost::iequals(extension, getFileExtension(filename)); } -std::string copyPathToFileName(const std::string &file_name, - const std::string &source) +std::string copyPathToFileName(const std::string& file_name, + const std::string& source) { auto filePath = fs::path(file_name); - if(filePath.has_parent_path()) + if (filePath.has_parent_path()) { return filePath.string(); } @@ -244,4 +244,4 @@ void removeFiles(std::vector<std::string> const& files) removeFile(file); } } -} // end namespace BaseLib +} // end namespace BaseLib diff --git a/BaseLib/IO/Writer.cpp b/BaseLib/IO/Writer.cpp index be8c08e720e888ddfb3fccdb598c3098835077dd..a686743c2342457c8a277b5e2137688728d6125e 100644 --- a/BaseLib/IO/Writer.cpp +++ b/BaseLib/IO/Writer.cpp @@ -23,7 +23,6 @@ namespace BaseLib { namespace IO { - Writer::Writer() { out.precision(std::numeric_limits<double>::digits10); diff --git a/BaseLib/IO/XmlIO/Qt/XMLQtInterface.cpp b/BaseLib/IO/XmlIO/Qt/XMLQtInterface.cpp index 6564e5c028447801d3a311df411d8f3e5f18888b..46e68abad28f75b71e845766a3ea474290392c47 100644 --- a/BaseLib/IO/XmlIO/Qt/XMLQtInterface.cpp +++ b/BaseLib/IO/XmlIO/Qt/XMLQtInterface.cpp @@ -31,9 +31,10 @@ namespace IO { XMLQtInterface::XMLQtInterface(QString schemaFile) : schemaFile_(std::move(schemaFile)) -{} +{ +} -int XMLQtInterface::readFile(const QString &fileName) +int XMLQtInterface::readFile(const QString& fileName) { fileName_ = fileName; QFile file(fileName); @@ -64,9 +65,9 @@ int XMLQtInterface::isValid() const auto url = QUrl::fromLocalFile(path); schema.load(url); } - if ( schema.isValid() ) + if (schema.isValid()) { - QXmlSchemaValidator validator( schema ); + QXmlSchemaValidator validator(schema); if (validator.validate(fileData_)) { return 1; @@ -119,7 +120,7 @@ bool XMLQtInterface::checkHash() const } QFile fileMD5(md5FileName); - if(fileMD5.open(QIODevice::WriteOnly)) + if (fileMD5.open(QIODevice::WriteOnly)) { fileMD5.write(fileHash); fileMD5.close(); diff --git a/BaseLib/Logging.cpp b/BaseLib/Logging.cpp index f8e94466809061256dde29fcd22d2880a355a76a..3142046ed90792ec566f5df91d38e695fc6ac948 100644 --- a/BaseLib/Logging.cpp +++ b/BaseLib/Logging.cpp @@ -11,8 +11,8 @@ #include "Logging.h" -#include <spdlog/spdlog.h> #include <spdlog/sinks/stdout_color_sinks.h> +#include <spdlog/spdlog.h> #include <map> diff --git a/BaseLib/MemWatch.cpp b/BaseLib/MemWatch.cpp index 379338a9090a3c92cd7661909cba87b7ab4ca397..216451b274362b8483b3f115645b54c7e466b8bc 100644 --- a/BaseLib/MemWatch.cpp +++ b/BaseLib/MemWatch.cpp @@ -15,51 +15,51 @@ #include "MemWatch.h" #if !defined(_WIN32) && !defined(__APPLE__) && !defined(__MINGW32__) -#include <fstream> -#include <string> -#include <sstream> #include <sys/types.h> #include <unistd.h> -#endif -namespace BaseLib { +#include <fstream> +#include <sstream> +#include <string> +#endif -MemWatch::MemWatch () +namespace BaseLib { - updateMemUsage (); +MemWatch::MemWatch() +{ + updateMemUsage(); } -unsigned MemWatch::updateMemUsage () +unsigned MemWatch::updateMemUsage() { #if !defined(_WIN32) && !defined(__APPLE__) && !defined(__MINGW32__) - std::string fname ("/proc/"); - std::stringstream str_pid; - str_pid << static_cast<unsigned> (getpid()); - fname += str_pid.str(); - fname += "/statm"; - unsigned pages; + std::string fname("/proc/"); + std::stringstream str_pid; + str_pid << static_cast<unsigned>(getpid()); + fname += str_pid.str(); + fname += "/statm"; + unsigned pages; - std::ifstream in (fname.c_str(), std::ios::in); - if (!in.is_open()) - { - perror( "open" ); - return 1; - } + std::ifstream in(fname.c_str(), std::ios::in); + if (!in.is_open()) + { + perror("open"); + return 1; + } - in >> pages; - vmem_size_ = static_cast<unsigned long>(pages) * - static_cast<unsigned long>(getpagesize()); - in.close (); + in >> pages; + vmem_size_ = static_cast<unsigned long>(pages) * + static_cast<unsigned long>(getpagesize()); + in.close(); #endif - return 0; + return 0; } -unsigned long MemWatch::getVirtMemUsage () +unsigned long MemWatch::getVirtMemUsage() { - updateMemUsage (); - return vmem_size_; + updateMemUsage(); + return vmem_size_; } -} // end namespace BaseLib - +} // end namespace BaseLib diff --git a/BaseLib/StringTools.cpp b/BaseLib/StringTools.cpp index 269cab3ad5c15c11574dc78bf4e49b11063707d7..dd7ef12887ac0fd061111f0c768effb85073ec35 100644 --- a/BaseLib/StringTools.cpp +++ b/BaseLib/StringTools.cpp @@ -30,12 +30,12 @@ std::vector<std::string> splitString(std::string const& str) std::istringstream str_stream(str); std::vector<std::string> items; std::copy(std::istream_iterator<std::string>(str_stream), - std::istream_iterator<std::string>(), - std::back_inserter(items)); + std::istream_iterator<std::string>(), + std::back_inserter(items)); return items; } -std::list<std::string> splitString(const std::string &str, char delim) +std::list<std::string> splitString(const std::string& str, char delim) { std::list<std::string> strList; std::stringstream ss(str); @@ -47,18 +47,18 @@ std::list<std::string> splitString(const std::string &str, char delim) return strList; } -std::string replaceString(const std::string &searchString, - const std::string &replaceString, +std::string replaceString(const std::string& searchString, + const std::string& replaceString, std::string stringToReplace) { boost::replace_all(stringToReplace, searchString, replaceString); return stringToReplace; } -void trim(std::string &str, char ch) +void trim(std::string& str, char ch) { std::string::size_type pos = str.find_last_not_of(ch); - if(pos != std::string::npos) + if (pos != std::string::npos) { str.erase(pos + 1); pos = str.find_first_not_of(ch); @@ -73,16 +73,16 @@ void trim(std::string &str, char ch) } } -void simplify(std::string &str) +void simplify(std::string& str) { - trim (str); - str.erase( - std::unique(str.begin(), str.end(), [](char a, char b) { return a == ' ' && b == ' '; }), - str.end() - ); + trim(str); + str.erase(std::unique(str.begin(), + str.end(), + [](char a, char b) { return a == ' ' && b == ' '; }), + str.end()); } -std::string format(const char* format_str, ... ) +std::string format(const char* format_str, ...) { va_list args; va_start(args, format_str); @@ -92,7 +92,7 @@ std::string format(const char* format_str, ... ) int char_length = std::vsnprintf(nullptr, 0, format_str, args_tmp); va_end(args_tmp); // allocate buffer and store formatted output there - std::vector<char> buffer(char_length + 1); // note +1 for null terminator + std::vector<char> buffer(char_length + 1); // note +1 for null terminator vsnprintf(buffer.data(), buffer.size(), format_str, args); va_end(args); diff --git a/BaseLib/Subdivision.cpp b/BaseLib/Subdivision.cpp index bac3c58e49050bd98702d31ac84d057e796970d2..178a85ec05c6493c8449457f7c6a6b574b6cb9a1 100644 --- a/BaseLib/Subdivision.cpp +++ b/BaseLib/Subdivision.cpp @@ -10,11 +10,11 @@ #include "Subdivision.h" +#include <BaseLib/Error.h> + #include <algorithm> #include <cmath> -#include <BaseLib/Error.h> - namespace BaseLib { GradualSubdivision::GradualSubdivision(const double L, @@ -25,7 +25,8 @@ GradualSubdivision::GradualSubdivision(const double L, { // Check if accumulated subdivisions can ever sum up to length. // Cf. geometric series formula. - if (multiplier < 1.0 && dL0 / (1.0 - multiplier) < L) { + if (multiplier < 1.0 && dL0 / (1.0 - multiplier) < L) + { OGS_FATAL( "Using dL0={:g} and multiplier={:g} the generated subdivisions can " "not sum up to a total length of {:g}.", @@ -41,7 +42,8 @@ std::vector<double> GradualSubdivision::operator()() const double x = 0; unsigned i = 0; - do { + do + { vec_x.push_back(x); x += std::min(max_dL_, dL0_ * std::pow(multiplier_, static_cast<double>(i))); @@ -76,14 +78,17 @@ std::vector<double> GradualSubdivisionFixedNum::operator()() const subdivisions.push_back(0.0); auto const q = multiplier_; - if (q == 1.0) { + if (q == 1.0) + { double const dx = length_ / num_subdivisions_; for (std::size_t i = 1; i < num_subdivisions_; ++i) { subdivisions.push_back(dx * i); } - } else { + } + else + { // compute initial subdivision size auto const a = length_ * (q - 1.0) / (std::pow(q, num_subdivisions_) - 1.0);