diff --git a/base/base_tests/string_utils_test.cpp b/base/base_tests/string_utils_test.cpp index 254e6f1d59..88ddb70300 100644 --- a/base/base_tests/string_utils_test.cpp +++ b/base/base_tests/string_utils_test.cpp @@ -6,15 +6,15 @@ UNIT_TEST(make_lower_case) string s; s = "THIS_IS_UPPER"; - utils::make_lower_case(s); + string_utils::make_lower_case(s); TEST_EQUAL(s, "this_is_upper", ()); s = "THIS_iS_MiXed"; - utils::make_lower_case(s); + string_utils::make_lower_case(s); TEST_EQUAL(s, "this_is_mixed", ()); s = "this_is_lower"; - utils::make_lower_case(s); + string_utils::make_lower_case(s); TEST_EQUAL(s, "this_is_lower", ()); } @@ -24,30 +24,30 @@ UNIT_TEST(to_double) double d; s = "0.123"; - TEST(utils::to_double(s, d), ()); + TEST(string_utils::to_double(s, d), ()); TEST_ALMOST_EQUAL(0.123, d, ()); s = "1."; - TEST(utils::to_double(s, d), ()); + TEST(string_utils::to_double(s, d), ()); TEST_ALMOST_EQUAL(1.0, d, ()); s = "0"; - TEST(utils::to_double(s, d), ()); + TEST(string_utils::to_double(s, d), ()); TEST_ALMOST_EQUAL(0., d, ()); s = "5.6843418860808e-14"; - TEST(utils::to_double(s, d), ()); + TEST(string_utils::to_double(s, d), ()); TEST_ALMOST_EQUAL(5.6843418860808e-14, d, ()); s = "-2"; - TEST(utils::to_double(s, d), ()); + TEST(string_utils::to_double(s, d), ()); TEST_ALMOST_EQUAL(-2.0, d, ()); } UNIT_TEST(to_string) { - TEST_EQUAL(utils::to_string(-1), "-1", ()); - TEST_EQUAL(utils::to_string(1234567890), "1234567890", ()); - TEST_EQUAL(utils::to_string(0.56), "0.56", ()); - TEST_EQUAL(utils::to_string(-100.2), "-100.2", ()); + TEST_EQUAL(string_utils::to_string(-1), "-1", ()); + TEST_EQUAL(string_utils::to_string(1234567890), "1234567890", ()); + TEST_EQUAL(string_utils::to_string(0.56), "0.56", ()); + TEST_EQUAL(string_utils::to_string(-100.2), "-100.2", ()); } diff --git a/base/string_utils.cpp b/base/string_utils.cpp index edd76d1d5e..0d230c7d12 100644 --- a/base/string_utils.cpp +++ b/base/string_utils.cpp @@ -1,12 +1,11 @@ #include "string_utils.hpp" +#include "assert.hpp" #include "../std/sstream.hpp" #include // for make_lower_case -#include "../base/start_mem_debug.hpp" - -namespace utils { +namespace string_utils { TokenizeIterator::TokenizeIterator(string const & s, char const * delim) : m_start(0), m_src(s), m_delim(delim) diff --git a/base/string_utils.hpp b/base/string_utils.hpp index ae02c64c67..f905cccea1 100644 --- a/base/string_utils.hpp +++ b/base/string_utils.hpp @@ -1,10 +1,11 @@ #pragma once -#include "assert.hpp" - #include "../std/string.hpp" +#include "../std/stdint.hpp" -namespace utils +#include "../3party/utfcpp/source/utf8/unchecked.h" + +namespace string_utils { // get substrings from s divided by delim and pass them to toDo template void TokenizeString(string const & s, char const * delim, ToDo toDo) @@ -73,4 +74,54 @@ namespace utils void make_lower_case(string & s); bool equal_no_case(string s1, string s2); + + inline string ToUtf8(wstring const & wstr) + { + string result; + utf8::unchecked::utf16to8(wstr.begin(), wstr.end(), back_inserter(result)); + return result; + } + + inline wstring FromUtf8(string const & str) + { + wstring result; + utf8::unchecked::utf8to16(str.begin(), str.end(), back_inserter(result)); + return result; + } + + template + typename ItT::value_type JoinStrings(ItT begin, ItT end, DelimiterT const & delimiter) + { + typedef typename ItT::value_type StringT; + + if (begin == end) return StringT(); + + StringT result = *begin++; + for (ItT it = begin; it != end; ++it) + { + result += delimiter; + result += *it; + } + + return result; + } + + template + typename ContainerT::value_type JoinStrings(ContainerT const & container, + DelimiterT const & delimiter) + { + return JoinStrings(container.begin(), container.end(), delimiter); + } + + inline bool IsPrefixOf(string const & s1, string const & s2) + { + if (s1.size() > s2.size()) return false; + + for (size_t i = 0; i < s1.size(); ++i) + { + if (s1[i] != s2[i]) return false; + } + + return true; + } } diff --git a/coding/coding.pro b/coding/coding.pro index 86ccbaa9b3..6b615e55fd 100644 --- a/coding/coding.pro +++ b/coding/coding.pro @@ -45,7 +45,6 @@ HEADERS += \ dd_vector.hpp \ dd_bit_vector.hpp \ dd_base.hpp \ - strutil.hpp \ writer.hpp \ write_to_sink.hpp \ reader.hpp \ @@ -79,3 +78,4 @@ HEADERS += \ sha2.hpp \ value_opt_string.hpp \ multilang_utf8_string.hpp \ + url_encode.hpp \ diff --git a/coding/coding_tests/coding_tests.pro b/coding/coding_tests/coding_tests.pro index 40bb0cd5e3..c251056550 100644 --- a/coding/coding_tests/coding_tests.pro +++ b/coding/coding_tests/coding_tests.pro @@ -27,7 +27,7 @@ SOURCES += ../../testing/testingmain.cpp \ file_sort_test.cpp \ reader_cache_test.cpp \ file_container_test.cpp \ - strutil_test.cpp \ + url_encode_test.cpp \ bzip2_test.cpp \ gzip_test.cpp \ coder_util_test.cpp \ diff --git a/coding/coding_tests/file_container_test.cpp b/coding/coding_tests/file_container_test.cpp index c018bf9f80..53fd16dc83 100644 --- a/coding/coding_tests/file_container_test.cpp +++ b/coding/coding_tests/file_container_test.cpp @@ -18,7 +18,7 @@ UNIT_TEST(FilesContainer_Smoke) for (size_t i = 0; i < count; ++i) { - FileWriter w = writer.GetWriter(utils::to_string(i)); + FileWriter w = writer.GetWriter(string_utils::to_string(i)); for (uint32_t j = 0; j < i; ++j) WriteVarUint(w, j); @@ -33,7 +33,7 @@ UNIT_TEST(FilesContainer_Smoke) for (size_t i = 0; i < count; ++i) { - FileReader r = reader.GetReader(utils::to_string(i)); + FileReader r = reader.GetReader(string_utils::to_string(i)); ReaderSource src(r); for (uint32_t j = 0; j < i; ++j) @@ -51,7 +51,7 @@ UNIT_TEST(FilesContainer_Smoke) { FilesContainerW writer(fName, FileWriter::OP_APPEND); - FileWriter w = writer.GetWriter(utils::to_string(arrAppend[i])); + FileWriter w = writer.GetWriter(string_utils::to_string(arrAppend[i])); WriteVarUint(w, arrAppend[i]); writer.Finish(); @@ -61,7 +61,7 @@ UNIT_TEST(FilesContainer_Smoke) { FilesContainerR reader(fName); - FileReader r = reader.GetReader(utils::to_string(arrAppend[i])); + FileReader r = reader.GetReader(string_utils::to_string(arrAppend[i])); ReaderSource src(r); uint32_t const test = ReadVarUint(src); diff --git a/coding/coding_tests/strutil_test.cpp b/coding/coding_tests/url_encode_test.cpp similarity index 97% rename from coding/coding_tests/strutil_test.cpp rename to coding/coding_tests/url_encode_test.cpp index 9cc56cab98..ea8ec9817a 100644 --- a/coding/coding_tests/strutil_test.cpp +++ b/coding/coding_tests/url_encode_test.cpp @@ -1,6 +1,6 @@ #include "../../testing/testing.hpp" -#include "../strutil.hpp" +#include "../url_encode.hpp" char const * orig1 = "http://google.com/main_index.php"; char const * enc1 = "http%3A%2F%2Fgoogle.com%2Fmain_index.php"; diff --git a/coding/coding_tests/value_opt_string_test.cpp b/coding/coding_tests/value_opt_string_test.cpp index d25d4b37a1..db99f4831b 100644 --- a/coding/coding_tests/value_opt_string_test.cpp +++ b/coding/coding_tests/value_opt_string_test.cpp @@ -29,7 +29,7 @@ namespace ReaderSource src(r); s.Read(src); - TEST_EQUAL(utils::to_string(arr[i]), s.Get(), ()); + TEST_EQUAL(string_utils::to_string(arr[i]), s.Get(), ()); } } } diff --git a/coding/file_reader.cpp b/coding/file_reader.cpp index e476d59ec6..d666bde873 100644 --- a/coding/file_reader.cpp +++ b/coding/file_reader.cpp @@ -106,7 +106,7 @@ FileReader * FileReader::CreateSubReader(uint64_t pos, uint64_t size) const bool FileReader::IsEqual(string const & fName) const { #if defined(OMIM_OS_WINDOWS) - return utils::equal_no_case(fName, m_pFileData->GetName()); + return string_utils::equal_no_case(fName, m_pFileData->GetName()); #else return (fName == m_pFileData->GetName()); #endif diff --git a/coding/strutil.hpp b/coding/strutil.hpp deleted file mode 100644 index e643b076ff..0000000000 --- a/coding/strutil.hpp +++ /dev/null @@ -1,109 +0,0 @@ -#pragma once - -#include "hex.hpp" - -#include "../base/base.hpp" -#include "../base/macros.hpp" - -#include "../std/string.hpp" -#include "../std/memcpy.hpp" - -#include "../3party/utfcpp/source/utf8.h" - -#include "../base/start_mem_debug.hpp" - -//typedef basic_string byte_string; -// -//inline byte_string StringToByteString(string const & str) -//{ -// byte_string result; -// result.resize(str.size()); -// memcpy(&result[0], &str[0], str.size()); -// return result; -//} - -inline string ToUtf8(wstring const & wstr) -{ - string result; - utf8::utf16to8(wstr.begin(), wstr.end(), back_inserter(result)); - return result; -} - -inline wstring FromUtf8(string const & str) -{ - wstring result; - utf8::utf8to16(str.begin(), str.end(), back_inserter(result)); - return result; -} - -template -typename ItT::value_type JoinStrings(ItT begin, ItT end, DelimiterT const & delimiter) -{ - typedef typename ItT::value_type StringT; - - if (begin == end) return StringT(); - - StringT result = *begin++; - for (ItT it = begin; it != end; ++it) - { - result += delimiter; - result += *it; - } - - return result; -} - -template -typename ContainerT::value_type JoinStrings(ContainerT const & container, - DelimiterT const & delimiter) -{ - return JoinStrings(container.begin(), container.end(), delimiter); -} - -inline bool IsPrefixOf(string const & s1, string const & s2) -{ - if (s1.size() > s2.size()) return false; - - for (size_t i = 0; i < s1.size(); ++i) - { - if (s1[i] != s2[i]) return false; - } - - return true; -} - -inline string UrlEncode(string const & rawUrl) -{ - string result(rawUrl); - for (size_t i = 0; i < result.size(); ++i) - { - char const c = result[i]; - if (c < '-' || c == '/' || (c > '9' && c < 'A') || (c > 'Z' && c < '_') - || c == '`' || (c > 'z' && c < '~') || c > '~') - { - string hexStr("%"); - hexStr += NumToHex(c); - result.replace(i, 1, hexStr); - i += 2; - } - } - return result; -} - -inline string UrlDecode(string const & encodedUrl) -{ - string result; - for (size_t i = 0; i < encodedUrl.size(); ++i) - { - if (encodedUrl[i] == '%') - { - result += FromHex(encodedUrl.substr(i + 1, 2)); - i += 2; - } - else - result += encodedUrl[i]; - } - return result; -} - -#include "../base/stop_mem_debug.hpp" diff --git a/coding/url_encode.hpp b/coding/url_encode.hpp new file mode 100644 index 0000000000..4cadcae7fd --- /dev/null +++ b/coding/url_encode.hpp @@ -0,0 +1,39 @@ +#pragma once + +#include "hex.hpp" + +#include "../std/string.hpp" + +inline string UrlEncode(string const & rawUrl) +{ + string result(rawUrl); + for (size_t i = 0; i < result.size(); ++i) + { + char const c = result[i]; + if (c < '-' || c == '/' || (c > '9' && c < 'A') || (c > 'Z' && c < '_') + || c == '`' || (c > 'z' && c < '~') || c > '~') + { + string hexStr("%"); + hexStr += NumToHex(c); + result.replace(i, 1, hexStr); + i += 2; + } + } + return result; +} + +inline string UrlDecode(string const & encodedUrl) +{ + string result; + for (size_t i = 0; i < encodedUrl.size(); ++i) + { + if (encodedUrl[i] == '%') + { + result += FromHex(encodedUrl.substr(i + 1, 2)); + i += 2; + } + else + result += encodedUrl[i]; + } + return result; +} diff --git a/coding/value_opt_string.hpp b/coding/value_opt_string.hpp index 5e079a0aef..560a547e93 100644 --- a/coding/value_opt_string.hpp +++ b/coding/value_opt_string.hpp @@ -32,7 +32,7 @@ public: } template void Set(T const & s) { - m_s = utils::to_string(s); + m_s = string_utils::to_string(s); CHECK ( !m_s.empty(), () ); } @@ -43,7 +43,7 @@ public: template void Write(TSink & sink) const { int n; - if (utils::to_int(m_s, n) && n >= 0) + if (string_utils::to_int(m_s, n) && n >= 0) WriteVarUint(sink, static_cast((n << 1) | numeric_bit)); else { @@ -60,7 +60,7 @@ public: uint32_t sz = ReadVarUint(src); if ((sz & numeric_bit) != 0) - m_s = utils::to_string(sz >> 1); + m_s = string_utils::to_string(sz >> 1); else { sz = (sz >> 1) + 1; diff --git a/generator/borders_loader.cpp b/generator/borders_loader.cpp index 1e080ad963..4c4b343fc2 100644 --- a/generator/borders_loader.cpp +++ b/generator/borders_loader.cpp @@ -69,7 +69,7 @@ namespace borders m2::RectD rect; PolygonLoader loader(baseDir, simplifyCountriesLevel, country, rect); - utils::TokenizeString(line, "|", loader); + string_utils::TokenizeString(line, "|", loader); if (!country.m_regions.IsEmpty()) countries.Add(country, rect); } diff --git a/generator/feature_sorter.cpp b/generator/feature_sorter.cpp index d698a6dd72..2cbb86d43f 100644 --- a/generator/feature_sorter.cpp +++ b/generator/feature_sorter.cpp @@ -93,7 +93,7 @@ namespace feature { for (size_t i = 0; i < m_header.GetScalesCount(); ++i) { - string const postfix = utils::to_string(i); + string const postfix = string_utils::to_string(i); m_geoFile.push_back(new FileWriter(fName + GEOMETRY_FILE_TAG + postfix)); m_trgFile.push_back(new FileWriter(fName + TRIANGLE_FILE_TAG + postfix)); } @@ -120,7 +120,7 @@ namespace feature delete m_geoFile[i]; delete m_trgFile[i]; - string const postfix = utils::to_string(i); + string const postfix = string_utils::to_string(i); string geoPostfix = GEOMETRY_FILE_TAG; geoPostfix += postfix; diff --git a/generator/first_pass_parser.hpp b/generator/first_pass_parser.hpp index cbea6fac04..9624e38f65 100644 --- a/generator/first_pass_parser.hpp +++ b/generator/first_pass_parser.hpp @@ -24,15 +24,15 @@ protected: virtual void EmitElement(XMLElement * p) { uint64_t id; - VERIFY ( utils::to_uint64(p->attrs["id"], id), ("Unknown element with invalid id : ", p->attrs["id"]) ); + VERIFY ( string_utils::to_uint64(p->attrs["id"], id), ("Unknown element with invalid id : ", p->attrs["id"]) ); if (p->name == "node") { // store point double lat, lng; - VERIFY ( utils::to_double(p->attrs["lat"], lat), ("Bad node lat : ", p->attrs["lat"]) ); - VERIFY ( utils::to_double(p->attrs["lon"], lng), ("Bad node lon : ", p->attrs["lon"]) ); + VERIFY ( string_utils::to_double(p->attrs["lat"], lat), ("Bad node lat : ", p->attrs["lat"]) ); + VERIFY ( string_utils::to_double(p->attrs["lon"], lng), ("Bad node lon : ", p->attrs["lon"]) ); // convert to mercator lat = MercatorBounds::LatToY(lat); @@ -53,7 +53,7 @@ protected: if (p->childs[i].name == "nd") { uint64_t ref; - VERIFY ( utils::to_uint64(p->childs[i].attrs["ref"], ref), ("Bad node ref in way : ", p->childs[i].attrs["ref"]) ); + VERIFY ( string_utils::to_uint64(p->childs[i].attrs["ref"], ref), ("Bad node ref in way : ", p->childs[i].attrs["ref"]) ); e.nodes.push_back(ref); } else if (!bUnite && (p->childs[i].name == "tag")) @@ -84,7 +84,7 @@ protected: if (p->childs[i].name == "member") { uint64_t ref; - VERIFY ( utils::to_uint64(p->childs[i].attrs["ref"], ref), ("Bad ref in relation : ", p->childs[i].attrs["ref"]) ); + VERIFY ( string_utils::to_uint64(p->childs[i].attrs["ref"], ref), ("Bad ref in relation : ", p->childs[i].attrs["ref"]) ); string const & type = p->childs[i].attrs["type"]; string const & role = p->childs[i].attrs["role"]; diff --git a/generator/osm2type.cpp b/generator/osm2type.cpp index 2b83551c8e..64dcda2166 100644 --- a/generator/osm2type.cpp +++ b/generator/osm2type.cpp @@ -30,11 +30,11 @@ namespace ftype { static char const * aTrue[] = { "yes", "true", "1", "*" }; static char const * aFalse[] = { "no", "false", "-1" }; - utils::TokenizeIterator it(v, "|"); + string_utils::TokenizeIterator it(v, "|"); while (!it.end()) { - if (utils::IsInArray(aTrue, *it)) return 1; - if (utils::IsInArray(aFalse, *it)) return -1; + if (string_utils::IsInArray(aTrue, *it)) return 1; + if (string_utils::IsInArray(aFalse, *it)) return -1; ++it; } @@ -71,7 +71,7 @@ namespace ftype { { static char const * rules[] = { "line", "tunnel", "area", "symbol", "caption", "text", "circle", "pathText", "wayMarker" }; - return utils::IsInArray(rules, e); + return string_utils::IsInArray(rules, e); } uint8_t get_rule_type() @@ -87,7 +87,7 @@ namespace ftype { } ASSERT ( !e.empty(), () ); - utils::TokenizeIterator it(e, "|"); + string_utils::TokenizeIterator it(e, "|"); uint8_t ret = 0; while (!it.end()) { @@ -110,7 +110,7 @@ namespace ftype { // addclass appear in small scales (6-11) // don't skip it during parsing, but we don't process it like a rule "addclass" }; - return (utils::IsInArray(elems, e) || is_draw_rule(e)); + return (string_utils::IsInArray(elems, e) || is_draw_rule(e)); } /// check if it's processing key @@ -118,7 +118,7 @@ namespace ftype { { static char const * bad[] = { "osmarender:render", "osmarender:rendername", "osmarender:renderref", "addr:housenumber" }; - return (!k.empty() && !utils::IsInArray(bad, k)); + return (!k.empty() && !string_utils::IsInArray(bad, k)); } static bool is_valid_value(string const & v) @@ -132,13 +132,13 @@ namespace ftype { static char const * mark[] = { "bridge", "tunnel", "area", "lock", "oneway", "junction", "embankment", "cutting", "motorroad", "cycleway", "bicycle", "horse", "capital", "fee" }; - return utils::IsInArray(mark, k); + return string_utils::IsInArray(mark, k); } static bool process_feature_like_mark_from_root(string const & /*k*/, string const & v) { static char const * mark[] = { "turning_circle", "dyke", "dike", "levee", "embankment" }; - return utils::IsInArray(mark, v); + return string_utils::IsInArray(mark, v); } static bool process_feature_like_mark(string const & k, string const & v) @@ -150,7 +150,7 @@ namespace ftype { static bool is_skip_element_by_key(string const & k) { static char const * skip[] = { "addr:housenumber", "fixme" }; - return utils::IsInArray(skip, k); + return string_utils::IsInArray(skip, k); } /// skip element and all it's sub-elements @@ -176,8 +176,8 @@ namespace ftype { void AddAttr(string name, string value) { // make lower case for equivalent string comparison - utils::make_lower_case(name); - utils::make_lower_case(value); + string_utils::make_lower_case(name); + string_utils::make_lower_case(value); if ((name == "k") && is_skip_element_by_key(value)) m_forceSkip = true; @@ -261,7 +261,7 @@ namespace ftype { string v = e.attr["v"]; if (!is_valid_value(v)) continue; - utils::TokenizeIterator iK(k, "|"); + string_utils::TokenizeIterator iK(k, "|"); if (iK.is_last()) { // process one key @@ -324,7 +324,7 @@ namespace ftype { } // process values - utils::TokenizeIterator iV(v, "|"); + string_utils::TokenizeIterator iV(v, "|"); while (!iV.end()) { bool const b1 = process_feature_like_mark_from_root(k, *iV); @@ -358,14 +358,14 @@ namespace ftype { while (!iK.end()) { // let's try to add root keys - bool addMode = (pParent == get_root() && utils::IsInArray(aTry, *iK)); + bool addMode = (pParent == get_root() && string_utils::IsInArray(aTry, *iK)); ClassifObject * p = (addMode ? pParent->Add(*iK) : pParent->Find(*iK)); if (p && (get_mark_value(*iK, v) == 0)) { if (p->IsCriterion()) p = pParent; - utils::TokenizeIterator iV(v, "|"); + string_utils::TokenizeIterator iV(v, "|"); while (!iV.end()) { ClassifObject * pp = (addMode ? p->Add(*iV) : p->Find(*iV)); @@ -525,7 +525,7 @@ namespace ftype { // get names string lang; - utils::TokenizeString(k, "\t :", get_lang(lang)); + string_utils::TokenizeString(k, "\t :", get_lang(lang)); if (!lang.empty()) m_params.name.AddString(lang, v); @@ -552,7 +552,7 @@ namespace ftype { if (k == "population") { int n; - if (utils::to_int(v, n)) + if (string_utils::to_int(v, n)) m_params.rank = static_cast(log(double(n)) / log(1.1)); } diff --git a/generator/osm_element.hpp b/generator/osm_element.hpp index a26a12c634..9298325bb7 100644 --- a/generator/osm_element.hpp +++ b/generator/osm_element.hpp @@ -274,7 +274,7 @@ protected: bool ParseType(XMLElement * p, uint64_t & id, FeatureParams & fValue) { - VERIFY ( utils::to_uint64(p->attrs["id"], id), + VERIFY ( string_utils::to_uint64(p->attrs["id"], id), ("Unknown element with invalid id : ", p->attrs["id"]) ); // try to get type from element tags @@ -476,7 +476,7 @@ protected: if (p->childs[i].name == "nd") { uint64_t nodeID; - VERIFY ( utils::to_uint64(p->childs[i].attrs["ref"], nodeID), + VERIFY ( string_utils::to_uint64(p->childs[i].attrs["ref"], nodeID), ("Bad node ref in way : ", p->childs[i].attrs["ref"]) ); m2::PointD pt; @@ -534,7 +534,7 @@ protected: { string const & role = p->childs[i].attrs["role"]; uint64_t wayID; - VERIFY ( utils::to_uint64(p->childs[i].attrs["ref"], wayID), + VERIFY ( string_utils::to_uint64(p->childs[i].attrs["ref"], wayID), ("Bad way ref in relation : ", p->childs[i].attrs["ref"]) ); if (role == "outer") diff --git a/generator/osm_xml_parser.cpp b/generator/osm_xml_parser.cpp index b5b9b7d1fc..abcc4e2300 100644 --- a/generator/osm_xml_parser.cpp +++ b/generator/osm_xml_parser.cpp @@ -212,21 +212,21 @@ namespace osm string const & elem = m_xmlTags.back(); if (attr == "id" && (elem == "node" || elem == "way" || elem == "relation")) { - CHECK(utils::to_int64(value, m_id), ()); + CHECK(string_utils::to_int64(value, m_id), ()); CHECK_NOT_EQUAL(m_id, 0, ("id == 0 is invalid")); } else if (attr == "lat" && elem == "node") { - CHECK(utils::to_double(value, m_lat), ()); + CHECK(string_utils::to_double(value, m_lat), ()); } else if (attr == "lon" && elem == "node") { - CHECK(utils::to_double(value, m_lon), ()); + CHECK(string_utils::to_double(value, m_lon), ()); } else if (attr == "ref") { int64_t numVal; - CHECK(utils::to_int64(value, numVal), ()); + CHECK(string_utils::to_int64(value, numVal), ()); if (elem == "nd") m_ref = numVal; else if (elem == "member") diff --git a/generator/statistics.cpp b/generator/statistics.cpp index 0d9da58ad7..6119e96b60 100644 --- a/generator/statistics.cpp +++ b/generator/statistics.cpp @@ -102,7 +102,7 @@ namespace stats string GetKey(uint32_t i) { - return utils::to_string(i); + return string_utils::to_string(i); } string GetKey(TypeTag t) diff --git a/indexer/drawing_rule_def.cpp b/indexer/drawing_rule_def.cpp index bfb48a7f1c..a889c2532a 100644 --- a/indexer/drawing_rule_def.cpp +++ b/indexer/drawing_rule_def.cpp @@ -23,7 +23,7 @@ namespace drule { int * arrParams[] = { &m_scale, &m_type, &m_index, &m_priority }; - utils::TokenizeIterator it(s, "|"); + string_utils::TokenizeIterator it(s, "|"); size_t i = 0; while (!it.end()) { diff --git a/indexer/drawing_rules.cpp b/indexer/drawing_rules.cpp index bff760d7b0..bb129742e1 100644 --- a/indexer/drawing_rules.cpp +++ b/indexer/drawing_rules.cpp @@ -42,13 +42,13 @@ namespace drule { template <> double get_value(string const & s) { double d; - VERIFY ( utils::to_double(s, d), ("Bad double in drawing rule : ", s) ); + VERIFY ( string_utils::to_double(s, d), ("Bad double in drawing rule : ", s) ); return d; } template <> string get_value(string const & s) { string ss(s); - utils::make_lower_case(ss); + string_utils::make_lower_case(ss); return ss; } //@} @@ -213,7 +213,7 @@ namespace drule { template <> dash_array_t get_value(string const & s) { dash_array_t ret; - utils::TokenizeString(s, " \tpx,", bind(&dash_array_t::add, ref(ret), _1)); + string_utils::TokenizeString(s, " \tpx,", bind(&dash_array_t::add, ref(ret), _1)); /// @see http://www.w3.org/TR/SVG/painting.html stroke-dasharray size_t const count = ret.m_v.size(); @@ -866,10 +866,10 @@ Key RulesHolder::CreateRuleImpl1(string const & name, #endif attrs_map_t a; - utils::TokenizeString(clValue, " \t", bind(&RulesHolder::PushAttributes, this, _1, ref(a))); + string_utils::TokenizeString(clValue, " \t", bind(&RulesHolder::PushAttributes, this, _1, ref(a))); for (attrs_map_t::const_iterator i = attrs.begin(); i != attrs.end(); ++i) - if (!utils::IsInArray(arrClassTags, i->first)) + if (!string_utils::IsInArray(arrClassTags, i->first)) a[i->first] = i->second; // background color (imitation of masks in tunnel patterns) diff --git a/map/information_display.cpp b/map/information_display.cpp index 10aa8074bb..3e36de81d3 100644 --- a/map/information_display.cpp +++ b/map/information_display.cpp @@ -139,9 +139,9 @@ void InformationDisplay::drawRuler(DrawerYG * pDrawer) scalerText = "<"; if (curVal >= 1000) - scalerText += utils::to_string(curVal / 1000) + " km"; + scalerText += string_utils::to_string(curVal / 1000) + " km"; else - scalerText += utils::to_string(curVal) + " m"; + scalerText += string_utils::to_string(curVal) + " m"; m2::PointD scalerOrg = m2::PointD(m_displayRect.minX(), m_displayRect.maxY() - m_bottomShift * m_visualScale) + m2::PointD(10 * m_visualScale, -10 * m_visualScale); diff --git a/map/languages.cpp b/map/languages.cpp index 920019cc49..ac7249d23c 100644 --- a/map/languages.cpp +++ b/map/languages.cpp @@ -5,7 +5,6 @@ #include "../base/string_utils.hpp" #include "../coding/file_reader.hpp" -#include "../coding/strutil.hpp" #include "../coding/multilang_utf8_string.hpp" #include "../platform/platform.hpp" @@ -100,7 +99,7 @@ namespace languages CodesT currentCodes; Collector c(currentCodes); - utils::TokenizeString(settingsString, LANG_DELIMETER, c); + string_utils::TokenizeString(settingsString, LANG_DELIMETER, c); GetSupportedLanguages(outLanguages); Sort(currentCodes, outLanguages); @@ -109,7 +108,7 @@ namespace languages void SaveSettings(CodesT const & langs) { CHECK_EQUAL(langs.size(), MAX_SUPPORTED_LANGUAGES, ()); - string const saveString = JoinStrings(langs.begin(), langs.end(), LANG_DELIMETER); + string const saveString = string_utils::JoinStrings(langs.begin(), langs.end(), LANG_DELIMETER); Settings::Set(SETTING_LANG_KEY, saveString); // apply new settings diff --git a/platform/wifi_info_mac.mm b/platform/wifi_info_mac.mm index d8f69afc03..9da4857ed1 100644 --- a/platform/wifi_info_mac.mm +++ b/platform/wifi_info_mac.mm @@ -62,12 +62,12 @@ static string AppendZeroIfNeeded(string const & macAddrPart) CWNetwork * net = (CWNetwork *)[nets objectAtIndex:i]; WiFiInfo::AccessPoint apn; apn.m_ssid = [net.ssid UTF8String]; - apn.m_signalStrength = utils::to_string([net.rssi intValue]); + apn.m_signalStrength = string_utils::to_string([net.rssi intValue]); // fix formatting for wifi address string const rawBssid = [net.bssid UTF8String]; if (!rawBssid.empty()) { - utils::TokenizeIterator tokIt(rawBssid, ":"); + string_utils::TokenizeIterator tokIt(rawBssid, ":"); apn.m_bssid = AppendZeroIfNeeded(*tokIt); do { diff --git a/storage/storage.cpp b/storage/storage.cpp index b0a45d07e8..dc822bce9f 100644 --- a/storage/storage.cpp +++ b/storage/storage.cpp @@ -8,7 +8,7 @@ #include "../coding/file_writer.hpp" #include "../coding/file_reader.hpp" #include "../coding/file_container.hpp" -#include "../coding/strutil.hpp" +#include "../coding/url_encode.hpp" #include "../version/version.hpp" @@ -83,7 +83,7 @@ namespace storage string Storage::UpdateBaseUrl() const { - return UPDATE_BASE_URL OMIM_OS_NAME "/" + utils::to_string(m_currentVersion) + "/"; + return UPDATE_BASE_URL OMIM_OS_NAME "/" + string_utils::to_string(m_currentVersion) + "/"; } TCountriesContainer const & NodeFromIndex(TCountriesContainer const & root, TIndex const & index) @@ -248,7 +248,7 @@ namespace storage public: DeleteMap() { - m_workingDir = GetPlatform().WritableDir(); + m_workingDir = GetPlatform().WritableDir(); } /// @TODO do not delete other countries cells void operator()(TTile const & tile) diff --git a/yg/geometry_batcher.cpp b/yg/geometry_batcher.cpp index 963c823b59..40d034266f 100644 --- a/yg/geometry_batcher.cpp +++ b/yg/geometry_batcher.cpp @@ -9,8 +9,6 @@ #include "internal/opengl.hpp" -#include "../coding/strutil.hpp" - #include "../geometry/rect2d.hpp" #include "../base/assert.hpp" diff --git a/yg/glyph_cache.cpp b/yg/glyph_cache.cpp index 9a232b8703..7a7d56eb2f 100644 --- a/yg/glyph_cache.cpp +++ b/yg/glyph_cache.cpp @@ -7,9 +7,9 @@ #include "ft2_debug.hpp" #include "../coding/lodepng_io.hpp" -#include "../coding/strutil.hpp" #include "../base/logging.hpp" +#include "../base/string_utils.hpp" #include "../std/vector.hpp" #include "../std/map.hpp" @@ -240,7 +240,7 @@ namespace yg double GlyphCache::getTextLength(double fontSize, string const & text) { - wstring s = FromUtf8(text); + wstring s = string_utils::FromUtf8(text); double len = 0; for (unsigned i = 0; i < s.size(); ++i) { diff --git a/yg/skin_loader.cpp b/yg/skin_loader.cpp index 94a60ef7eb..513a365634 100644 --- a/yg/skin_loader.cpp +++ b/yg/skin_loader.cpp @@ -161,7 +161,7 @@ namespace yg int StrToInt(string const & s) { int i; - VERIFY ( utils::to_int(s, i), ("Bad int int StrToInt function") ); + VERIFY ( string_utils::to_int(s, i), ("Bad int int StrToInt function") ); return i; } diff --git a/yg/skin_loader.hpp b/yg/skin_loader.hpp index 9c5593a6d7..2356378877 100644 --- a/yg/skin_loader.hpp +++ b/yg/skin_loader.hpp @@ -11,10 +11,6 @@ #include "../std/vector.hpp" #include "../std/shared_ptr.hpp" #include "../std/utility.hpp" -#include "../std/shared_ptr.hpp" -#include "../coding/strutil.hpp" - -#include "../base/start_mem_debug.hpp" /// @example /// diff --git a/yg/text_renderer.cpp b/yg/text_renderer.cpp index bf2cd0330c..e76ab53beb 100644 --- a/yg/text_renderer.cpp +++ b/yg/text_renderer.cpp @@ -8,14 +8,13 @@ #include "render_state.hpp" #include "glyph_layout.hpp" -#include "../coding/strutil.hpp" - #include "../geometry/angles.hpp" #include "../std/bind.hpp" #include "../3party/fribidi/lib/fribidi-deprecated.h" +#include "../base/string_utils.hpp" #include "../base/logging.hpp" #include "../base/stl_add.hpp" @@ -250,7 +249,7 @@ namespace yg void TextRenderer::drawTextImpl(FontDesc const & fontDesc, m2::PointD const & pt, yg::EPosition pos, float angle, string const & utf8Text, double depth, bool log2vis) { - wstring text = FromUtf8(utf8Text); + wstring text = string_utils::FromUtf8(utf8Text); if (log2vis) text = Log2Vis(text); @@ -293,7 +292,7 @@ namespace yg m2::RectD rect; m2::PointD pt(0, 0); - wstring text = FromUtf8(utf8Text); + wstring text = string_utils::FromUtf8(utf8Text); if (log2vis) text = Log2Vis(text); @@ -351,7 +350,7 @@ namespace yg FontDesc const & fontDesc, m2::PointD const * path, size_t s, string const & utf8Text, double fullLength, double pathOffset, yg::EPosition pos, double depth) { - wstring const text = Log2Vis(FromUtf8(utf8Text)); + wstring const text = Log2Vis(string_utils::FromUtf8(utf8Text)); GlyphLayout layout(resourceManager(), fontDesc, path, s, text, fullLength, pathOffset, pos);