diff options
author | crupest <crupest@outlook.com> | 2022-03-08 17:24:07 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-03-08 17:24:07 +0800 |
commit | 78f5221e8fbab510bb8b5ac268b7d42bed762961 (patch) | |
tree | 2066be748d39411e4dd6a74a538df4ca4a213543 /include/cru/common/String.h | |
parent | 62a0c3f1785e789357c892d94b3ea0bc3ea6833e (diff) | |
download | cru-78f5221e8fbab510bb8b5ac268b7d42bed762961.tar.gz cru-78f5221e8fbab510bb8b5ac268b7d42bed762961.tar.bz2 cru-78f5221e8fbab510bb8b5ac268b7d42bed762961.zip |
...
Diffstat (limited to 'include/cru/common/String.h')
-rw-r--r-- | include/cru/common/String.h | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/include/cru/common/String.h b/include/cru/common/String.h index be886168..60d0912e 100644 --- a/include/cru/common/String.h +++ b/include/cru/common/String.h @@ -13,6 +13,13 @@ #include <vector> namespace cru { +struct StringToFloatFlags { + constexpr static int kNoFlags = 0; + constexpr static int kAllowLeadingSpaces = 1 << 0; + constexpr static int kAllowTrailingSpaces = 1 << 1; + constexpr static int kAllowTrailingJunk = 1 << 2; +}; + class StringView; class CRU_BASE_API String { @@ -211,8 +218,10 @@ class CRU_BASE_API String { Range RangeFromCodeUnitToCodePoint(Range code_unit_range) const; Range RangeFromCodePointToCodeUnit(Range code_point_range) const; - float ParseToFloat(Index* processed_characters_count = nullptr) const; - double ParseToDouble(Index* processed_characters_count = nullptr) const; + float ParseToFloat(Index* processed_characters_count = nullptr, + int flags = StringToFloatFlags::kNoFlags) const; + double ParseToDouble(Index* processed_characters_count = nullptr, + int flags = StringToFloatFlags::kNoFlags) const; std::vector<float> ParseToFloatList(value_type separator = u' ') const; std::vector<double> ParseToDoubleList(value_type separator = u' ') const; @@ -244,9 +253,6 @@ class CRU_BASE_API String { class CRU_BASE_API StringView { public: - static double_conversion::StringToDoubleConverter - kDefaultStringToDoubleConverter; - using value_type = char16_t; using size_type = Index; using difference_type = Index; @@ -339,8 +345,10 @@ class CRU_BASE_API StringView { Range RangeFromCodeUnitToCodePoint(Range code_unit_range) const; Range RangeFromCodePointToCodeUnit(Range code_point_range) const; - float ParseToFloat(Index* processed_characters_count = nullptr) const; - double ParseToDouble(Index* processed_characters_count = nullptr) const; + float ParseToFloat(Index* processed_characters_count = nullptr, + int flags = StringToFloatFlags::kNoFlags) const; + double ParseToDouble(Index* processed_characters_count = nullptr, + int flags = StringToFloatFlags::kNoFlags) const; std::vector<float> ParseToFloatList(value_type separator = u' ') const; std::vector<double> ParseToDoubleList(value_type separator = u' ') const; |