KSeExpr 6.0.0.0
Utils.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2020 L. E. Segovia <amy@amyspark.me>
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4#include <cfloat>
5#include <cmath>
6#include <cstdint>
7#include <string>
8
9namespace KSeExpr
10{
11 namespace Utils
12 {
13 bool parseRangeComment(const std::string &comment, double &from, double &to);
14 bool parseRangeComment(const std::string &comment, float &from, float &to);
15 bool parseRangeComment(const std::string &comment, int32_t &from, int32_t &to);
16 bool parseTypeNameComment(const std::string &comment, std::string &type, std::string &name);
17 bool parseLabelComment(const std::string &comment, std::string &label);
18
19 inline std::string trim(const std::string &s)
20 {
21 const auto begin {s.find_first_not_of(' ')};
22 const auto end {s.find_last_not_of(' ')};
23 if (begin != std::string::npos && end != std::string::npos)
24 return s.substr(begin, end + 1);
25 return s; // empty string
26 }
27 } // namespace Utils
28} // namespace KSeExpr
bool parseRangeComment(const std::string &comment, double &from, double &to)
Definition Utils.cpp:7
bool parseLabelComment(const std::string &comment, std::string &label)
Definition Utils.cpp:124
bool parseTypeNameComment(const std::string &comment, std::string &type, std::string &name)
Definition Utils.cpp:99
std::string trim(const std::string &s)
Definition Utils.h:19