.. _program_listing_file_src_utils_ParseUtils.hpp: Program Listing for File ParseUtils.hpp ======================================= |exhale_lsh| :ref:`Return to documentation for file ` (``src/utils/ParseUtils.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #ifndef PARSEUTILS_HPP #define PARSEUTILS_HPP #include "../pdfs/PDF.hpp" #include #include #include #include #include #include #include #include namespace utils { inline auto stod(const std::string& str) -> double { size_t processedLen = 0; auto result = std::stod(str, &processedLen); if (processedLen != str.size()) { throw std::invalid_argument(""); } return result; } auto trim(const std::string& str) -> std::string; inline auto tokenize(const std::string& str) -> std::vector { std::istringstream stream(str); std::vector tokens( (std::istream_iterator(stream)), std::istream_iterator() ); return tokens; } inline auto splitOnChar(const std::string& str, const char delim) -> std::vector { std::vector tokens; std::size_t start = 0; while (true) { const std::size_t pos = str.find(delim, start); if (pos == std::string::npos) { tokens.push_back(str.substr(start)); break; } tokens.push_back(str.substr(start, pos - start)); start = pos + 1; } return tokens; } auto initPDFFromString(const std::string& value, const std::string& prefix = "") -> pdfs::PDF; template auto getTOMLKeyWithError( const toml::table& inputDeck, const std::string& key, bool required = false) -> std::optional; } // namespace utils #endif // PARSEUTILS_HPP