aboutsummaryrefslogtreecommitdiff
path: root/src/common/String.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/String.cpp')
-rw-r--r--src/common/String.cpp29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/common/String.cpp b/src/common/String.cpp
index 48705d3b..3721eed3 100644
--- a/src/common/String.cpp
+++ b/src/common/String.cpp
@@ -13,8 +13,7 @@
namespace cru {
double_conversion::StringToDoubleConverter
String::kDefaultStringToDoubleConverter(
- double_conversion::StringToDoubleConverter::ALLOW_TRAILING_JUNK |
- double_conversion::StringToDoubleConverter::ALLOW_LEADING_SPACES |
+ double_conversion::StringToDoubleConverter::ALLOW_LEADING_SPACES |
double_conversion::StringToDoubleConverter::ALLOW_TRAILING_SPACES |
double_conversion::StringToDoubleConverter::
ALLOW_CASE_INSENSIBILITY,
@@ -454,6 +453,32 @@ double String::ParseToDouble(Index* processed_characters_count) const {
return result;
}
+std::vector<float> String::ParseToFloatList(value_type separator) {
+ std::vector<float> result;
+ auto list = Split(separator);
+ for (auto& item : list) {
+ auto value = ParseToFloat();
+ if (std::isnan(value)) {
+ throw Exception(u"Invalid double value.");
+ }
+ result.push_back(value);
+ }
+ return result;
+}
+
+std::vector<double> String::ParseToDoubleList(value_type separator) {
+ std::vector<double> result;
+ auto list = Split(separator);
+ for (auto& item : list) {
+ auto value = ParseToDouble();
+ if (std::isnan(value)) {
+ throw Exception(u"Invalid double value.");
+ }
+ result.push_back(value);
+ }
+ return result;
+}
+
StringView StringView::substr(Index pos) {
Expects(pos >= 0 && pos < size_);
return StringView(ptr_ + pos, size_ - pos);