aboutsummaryrefslogtreecommitdiff
path: root/src/common/Utilities/Util.h
diff options
context:
space:
mode:
authorTreeston <treeston.mmoc@gmail.com>2020-08-28 00:11:16 +0200
committerGitHub <noreply@github.com>2020-08-28 00:11:16 +0200
commit534a2388b7c662c8796aabb1ec8cb424879799b6 (patch)
treedf01a59b06bbb376dfeb95f2d538ab43b082e20d /src/common/Utilities/Util.h
parent7478c2c65aea853a2086c9c7ecc56c14ad6ee338 (diff)
Core/Common: Tokenizer -> Trinity::Tokenize (PR: #25327)
Diffstat (limited to 'src/common/Utilities/Util.h')
-rw-r--r--src/common/Utilities/Util.h34
1 files changed, 9 insertions, 25 deletions
diff --git a/src/common/Utilities/Util.h b/src/common/Utilities/Util.h
index b3e37424a09..a355d1af6d3 100644
--- a/src/common/Utilities/Util.h
+++ b/src/common/Utilities/Util.h
@@ -36,35 +36,19 @@ enum class TimeFormat : uint8
Numeric // 1:2:3:4
};
-class TC_COMMON_API Tokenizer
+namespace Trinity
{
-public:
- typedef std::vector<char const*> StorageType;
-
- typedef StorageType::size_type size_type;
-
- typedef StorageType::const_iterator const_iterator;
- typedef StorageType::reference reference;
- typedef StorageType::const_reference const_reference;
-
-public:
- Tokenizer(std::string_view src, char const sep, uint32 vectorReserve = 0, bool keepEmptyStrings = true);
- ~Tokenizer() { delete[] m_str; }
+ TC_COMMON_API std::vector<std::string_view> Tokenize(std::string_view str, char sep, bool keepEmpty);
- const_iterator begin() const { return m_storage.begin(); }
- const_iterator end() const { return m_storage.end(); }
+ /* this would return string_view into temporary otherwise */
+ std::vector<std::string_view> Tokenize(std::string&&, char, bool) = delete;
+ std::vector<std::string_view> Tokenize(std::string const&&, char, bool) = delete;
- size_type size() const { return m_storage.size(); }
-
- reference operator [] (size_type i) { return m_storage[i]; }
- const_reference operator [] (size_type i) const { return m_storage[i]; }
-
-private:
- char* m_str;
- StorageType m_storage;
-};
+ /* the delete overload means we need to make this explicit */
+ inline std::vector<std::string_view> Tokenize(char const* str, char sep, bool keepEmpty) { return Tokenize(std::string_view(str ? str : ""), sep, keepEmpty); }
+}
-TC_COMMON_API int32 MoneyStringToMoney(std::string const& moneyString);
+TC_COMMON_API Optional<int32> MoneyStringToMoney(std::string const& moneyString);
TC_COMMON_API struct tm* localtime_r(time_t const* time, struct tm *result);
TC_COMMON_API time_t LocalTimeToUTCTime(time_t time);