diff options
-rw-r--r-- | base/base_tests/string_utils_test.cpp | 6 | ||||
-rw-r--r-- | base/string_utils.cpp | 10 | ||||
-rw-r--r-- | base/string_utils.hpp | 14 | ||||
-rw-r--r-- | indexer/editable_map_object.cpp | 8 |
4 files changed, 14 insertions, 24 deletions
diff --git a/base/base_tests/string_utils_test.cpp b/base/base_tests/string_utils_test.cpp index 564e51fcbe..1f1aa05bc2 100644 --- a/base/base_tests/string_utils_test.cpp +++ b/base/base_tests/string_utils_test.cpp @@ -411,12 +411,6 @@ UNIT_TEST(SimpleTokenizer) tokens.assign(&s[0], &s[0] + ARRAY_SIZE(s)); TestIter("/1/2/", "/", tokens); } - { - using strings::SimpleTokenizer; - string const str("a,b,c"); - TEST_EQUAL(vector<string>(SimpleTokenizer(str, ","), SimpleTokenizer()), - (vector<string>{"a", "b", "c"}), ()); - } { string const s = ""; diff --git a/base/string_utils.cpp b/base/string_utils.cpp index d36b33a853..7b6b808995 100644 --- a/base/string_utils.cpp +++ b/base/string_utils.cpp @@ -24,12 +24,14 @@ SimpleDelimiter::SimpleDelimiter(char const * delims) m_delims.push_back(utf8::unchecked::next(it)); } +SimpleDelimiter::SimpleDelimiter(char delim) +{ + m_delims.push_back(delim); +} + bool SimpleDelimiter::operator()(UniChar c) const { - for (UniString::const_iterator it = m_delims.begin(); it != m_delims.end(); ++it) - if (*it == c) - return true; - return false; + return find(m_delims.begin(), m_delims.end(), c) != m_delims.end(); } UniChar LastUniChar(string const & s) diff --git a/base/string_utils.hpp b/base/string_utils.hpp index c114748369..d557706d85 100644 --- a/base/string_utils.hpp +++ b/base/string_utils.hpp @@ -113,10 +113,6 @@ public: Move(); } - // Use default-constructed iterator for operator == to determine the - // end of the token stream. - TokenizeIterator() = default; - string operator*() const { ASSERT(m_start != m_finish, ("Dereferencing of empty iterator.")); @@ -204,10 +200,6 @@ public: ++m_end; } - // Use default-constructed iterator for operator == to determine the - // end of the token stream. - TokenizeIterator() = default; - string operator*() const { ASSERT(!m_finished, ("Dereferencing of empty iterator.")); @@ -290,9 +282,9 @@ class SimpleDelimiter public: SimpleDelimiter(char const * delims); - // Used in TokenizeIterator to allow past the end iterator construction. - SimpleDelimiter() = default; - /// @return true if c is delimiter + SimpleDelimiter(char delim); + + // Returns true iff |c| is a delimiter. bool operator()(UniChar c) const; }; diff --git a/indexer/editable_map_object.cpp b/indexer/editable_map_object.cpp index d54d1e0483..e69836c95c 100644 --- a/indexer/editable_map_object.cpp +++ b/indexer/editable_map_object.cpp @@ -232,12 +232,14 @@ bool EditableMapObject::ValidateHouseNumber(string const & houseNumber) // static bool EditableMapObject::ValidateFlats(string const & flats) { - auto it = strings::SimpleTokenizer(flats, ";"); - for (; it != strings::SimpleTokenizer(); ++it) + for (auto it = strings::SimpleTokenizer(flats, ";"); it; ++it) { auto token = *it; strings::Trim(token); - vector<string> range(strings::SimpleTokenizer(token, "-"), strings::SimpleTokenizer()); + + vector<string> range; + for (auto i = strings::SimpleTokenizer(token, "-"); i; ++i) + range.push_back(*i); if (range.empty() || range.size() > 2) return false; |