diff options
author | crupest <crupest@outlook.com> | 2022-03-10 16:43:04 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-03-10 16:43:04 +0800 |
commit | 51f87e3ff980e62f9cb5ee656e5591412e2766eb (patch) | |
tree | 4101a0c00fd77dfc694c377ae2b69178a77cdb63 /include/cru/common/StringToNumberConverter.h | |
parent | 0b5c16f6b35f7144b34996d8c77f370bcbcf150c (diff) | |
download | cru-51f87e3ff980e62f9cb5ee656e5591412e2766eb.tar.gz cru-51f87e3ff980e62f9cb5ee656e5591412e2766eb.tar.bz2 cru-51f87e3ff980e62f9cb5ee656e5591412e2766eb.zip |
...
Diffstat (limited to 'include/cru/common/StringToNumberConverter.h')
-rw-r--r-- | include/cru/common/StringToNumberConverter.h | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/include/cru/common/StringToNumberConverter.h b/include/cru/common/StringToNumberConverter.h index b5118de6..f1baafee 100644 --- a/include/cru/common/StringToNumberConverter.h +++ b/include/cru/common/StringToNumberConverter.h @@ -4,7 +4,7 @@ #include <ostream> namespace cru { -struct StringToNumberFlags { +struct CRU_BASE_API StringToNumberFlags { constexpr static unsigned kNoFlags = 0; constexpr static unsigned kAllowLeadingSpaces = 1 << 0; constexpr static unsigned kAllowTrailingSpaces = 1 << 1; @@ -13,7 +13,7 @@ struct StringToNumberFlags { constexpr static unsigned kThrowOnError = 1 << 3; }; -struct StringToIntegerConverterImplResult { +struct CRU_BASE_API StringToIntegerConverterImplResult { StringToIntegerConverterImplResult() = default; StringToIntegerConverterImplResult(bool negate, unsigned long long value) : negate(negate), value(value) {} @@ -22,13 +22,15 @@ struct StringToIntegerConverterImplResult { unsigned long long value; }; -inline bool operator==(const StringToIntegerConverterImplResult& left, - const StringToIntegerConverterImplResult& right) { +inline bool CRU_BASE_API +operator==(const StringToIntegerConverterImplResult& left, + const StringToIntegerConverterImplResult& right) { return left.negate == right.negate && left.value == right.value; } -inline bool operator!=(const StringToIntegerConverterImplResult& left, - const StringToIntegerConverterImplResult& right) { +inline bool CRU_BASE_API +operator!=(const StringToIntegerConverterImplResult& left, + const StringToIntegerConverterImplResult& right) { return !(left == right); } @@ -41,7 +43,7 @@ inline std::ostream& operator<<( /** * \brief A converter that convert number into long long. */ -struct StringToIntegerConverterImpl { +struct CRU_BASE_API StringToIntegerConverterImpl { public: explicit StringToIntegerConverterImpl(unsigned flags, int base = 0) : flags(flags), base(base) {} @@ -58,6 +60,9 @@ struct StringToIntegerConverterImpl { StringToIntegerConverterImplResult Parse( const char* str, Index size, Index* processed_characters_count) const; + StringToIntegerConverterImplResult Parse( + const char16_t* str, Index size, Index* processed_characters_count) const; + template <std::size_t Size> StringToIntegerConverterImplResult Parse( const char (&str)[Size], Index* processed_characters_count) const { |