diff options
author | Arsentiy Milchakov <milcars@mapswithme.com> | 2019-03-01 13:08:56 +0300 |
---|---|---|
committer | mpimenov <mpimenov@users.noreply.github.com> | 2019-03-03 00:03:13 +0300 |
commit | ccda0f4bc85354528fed7099ac0bfcbcd01099b5 (patch) | |
tree | 97f1dacadcef42178b3f54a8080f64b3f8394c43 /editor | |
parent | 089bfe5548f0a356e5afca310a847940f713a6d2 (diff) |
[editor] std migration + clang-format
Diffstat (limited to 'editor')
37 files changed, 366 insertions, 354 deletions
diff --git a/editor/changeset_wrapper.cpp b/editor/changeset_wrapper.cpp index 1e5cc4cefc..e997b04fc6 100644 --- a/editor/changeset_wrapper.cpp +++ b/editor/changeset_wrapper.cpp @@ -8,12 +8,15 @@ #include "base/logging.hpp" #include "base/macros.hpp" -#include "std/algorithm.hpp" -#include "std/random.hpp" -#include "std/sstream.hpp" +#include <algorithm> +#include <exception> +#include <random> +#include <sstream> #include "private.h" +using namespace std; + using editor::XMLFeature; namespace @@ -117,7 +120,7 @@ ChangesetWrapper::~ChangesetWrapper() m_api.UpdateChangeSet(m_changesetId, m_changesetComments); m_api.CloseChangeSet(m_changesetId); } - catch (std::exception const & ex) + catch (exception const & ex) { LOG(LWARNING, (ex.what())); } diff --git a/editor/changeset_wrapper.hpp b/editor/changeset_wrapper.hpp index ba8293e4dd..ca2a76687f 100644 --- a/editor/changeset_wrapper.hpp +++ b/editor/changeset_wrapper.hpp @@ -8,8 +8,8 @@ #include "geometry/point2d.hpp" #include "geometry/rect2d.hpp" -#include "std/set.hpp" -#include "std/vector.hpp" +#include <map> +#include <vector> class FeatureType; @@ -19,7 +19,7 @@ struct ClientToken; class ChangesetWrapper { - using TTypeCount = map<string, size_t>; + using TTypeCount = std::map<std::string, size_t>; public: DECLARE_EXCEPTION(ChangesetWrapperException, RootException); @@ -39,7 +39,7 @@ public: /// Throws many exceptions from above list, plus including XMLNode's parsing ones. /// OsmObjectWasDeletedException means that node was deleted from OSM server by someone else. editor::XMLFeature GetMatchingNodeFeatureFromOSM(m2::PointD const & center); - editor::XMLFeature GetMatchingAreaFeatureFromOSM(vector<m2::PointD> const & geomerty); + editor::XMLFeature GetMatchingAreaFeatureFromOSM(std::vector<m2::PointD> const & geomerty); /// Throws exceptions from above list. void Create(editor::XMLFeature node); @@ -67,8 +67,8 @@ private: TTypeCount m_modified_types; TTypeCount m_created_types; TTypeCount m_deleted_types; - static string TypeCountToString(TTypeCount const & typeCount); - string GetDescription() const; + static std::string TypeCountToString(TTypeCount const & typeCount); + std::string GetDescription() const; }; } // namespace osm diff --git a/editor/config_loader.cpp b/editor/config_loader.cpp index f04e7924ee..9a497f1f0c 100644 --- a/editor/config_loader.cpp +++ b/editor/config_loader.cpp @@ -7,12 +7,14 @@ #include "coding/internal/file_data.hpp" #include "coding/reader.hpp" -#include "std/exception.hpp" -#include "std/fstream.hpp" -#include "std/iterator.hpp" +#include <exception> +#include <fstream> +#include <iterator> #include "3party/pugixml/src/pugixml.hpp" +using namespace std; + namespace { using platform::HttpClient; @@ -20,7 +22,7 @@ using platform::HttpClient; auto const kConfigFileName = "editor.config"; auto const kHashFileName = "editor.config.hash"; -auto const kSynchroTimeout = hours(4); +auto const kSynchroTimeout = chrono::hours(4); auto const kRemoteHashUrl = "http://osmz.ru/mwm/editor.config.date"; auto const kRemoteConfigUrl = "http://osmz.ru/mwm/editor.config"; diff --git a/editor/config_loader.hpp b/editor/config_loader.hpp index 73bf1ee527..e8171b2213 100644 --- a/editor/config_loader.hpp +++ b/editor/config_loader.hpp @@ -4,12 +4,12 @@ #include "base/exception.hpp" #include "base/logging.hpp" -#include "std/chrono.hpp" -#include "std/condition_variable.hpp" -#include "std/mutex.hpp" -#include "std/shared_ptr.hpp" -#include "std/string.hpp" -#include "std/thread.hpp" +#include <chrono> +#include <condition_variable> +#include <memory> +#include <mutex> +#include <string> +#include <thread> namespace pugi { @@ -25,9 +25,9 @@ class Waiter { public: template <typename Rep, typename Period> - bool Wait(duration<Rep, Period> const & waitDuration) + bool Wait(std::chrono::duration<Rep, Period> const & waitDuration) { - unique_lock<mutex> lock(m_mutex); + std::unique_lock<std::mutex> lock(m_mutex); if (m_interrupted) return false; @@ -41,8 +41,8 @@ public: private: bool m_interrupted = false; - mutex m_mutex; - condition_variable m_event; + std::mutex m_mutex; + std::condition_variable m_event; }; // Class which loads config from local drive, checks hash @@ -55,10 +55,10 @@ public: // Static methods for production and testing. static void LoadFromLocal(pugi::xml_document & doc); - static string GetRemoteHash(); + static std::string GetRemoteHash(); static void GetRemoteConfig(pugi::xml_document & doc); - static bool SaveHash(string const & hash, string const & filePath); - static string LoadHash(string const & filePath); + static bool SaveHash(std::string const & hash, std::string const & filePath); + static std::string LoadHash(std::string const & filePath); private: void LoadFromServer(); @@ -68,6 +68,6 @@ private: base::AtomicSharedPtr<EditorConfig> & m_config; Waiter m_waiter; - thread m_loaderThread; + std::thread m_loaderThread; }; } // namespace editor diff --git a/editor/editor_config.cpp b/editor/editor_config.cpp index d34172189f..f82018bb27 100644 --- a/editor/editor_config.cpp +++ b/editor/editor_config.cpp @@ -2,9 +2,11 @@ #include "base/stl_helpers.hpp" -#include "std/algorithm.hpp" -#include "std/cstring.hpp" -#include "std/unordered_map.hpp" +#include <algorithm> +#include <cstring> +#include <unordered_map> + +using namespace std; namespace { diff --git a/editor/editor_config.hpp b/editor/editor_config.hpp index 8afa7b396e..1b3ae152e9 100644 --- a/editor/editor_config.hpp +++ b/editor/editor_config.hpp @@ -2,8 +2,8 @@ #include "indexer/feature_meta.hpp" -#include "std/string.hpp" -#include "std/vector.hpp" +#include <string> +#include <vector> #include "3party/pugixml/src/pugixml.hpp" @@ -14,7 +14,7 @@ namespace editor struct TypeAggregatedDescription { using EType = feature::Metadata::EType; - using TFeatureFields = vector<EType>; + using TFeatureFields = std::vector<EType>; bool IsEmpty() const { @@ -38,9 +38,9 @@ public: EditorConfig() = default; // TODO(mgsergio): Reduce overhead by matching uint32_t types instead of strings. - bool GetTypeDescription(vector<string> classificatorTypes, + bool GetTypeDescription(std::vector<std::string> classificatorTypes, TypeAggregatedDescription & outDesc) const; - vector<string> GetTypesThatCanBeAdded() const; + std::vector<std::string> GetTypesThatCanBeAdded() const; void SetConfig(pugi::xml_document const & doc); diff --git a/editor/editor_storage.cpp b/editor/editor_storage.cpp index e6d3b601b2..8a6344996a 100644 --- a/editor/editor_storage.cpp +++ b/editor/editor_storage.cpp @@ -6,7 +6,7 @@ #include "base/logging.hpp" -#include "std/string.hpp" +#include <string> using namespace pugi; @@ -14,7 +14,7 @@ namespace { char const * kEditorXMLFileName = "edits.xml"; -string GetEditorFilePath() { return GetPlatform().WritablePathForFile(kEditorXMLFileName); } +std::string GetEditorFilePath() { return GetPlatform().WritablePathForFile(kEditorXMLFileName); } } // namespace namespace editor @@ -26,7 +26,7 @@ bool LocalStorage::Save(xml_document const & doc) std::lock_guard<std::mutex> guard(m_mutex); - return base::WriteToTempAndRenameToFile(editorFilePath, [&doc](string const & fileName) { + return base::WriteToTempAndRenameToFile(editorFilePath, [&doc](std::string const & fileName) { return doc.save_file(fileName.data(), " " /* indent */); }); } diff --git a/editor/editor_tests/editor_config_test.cpp b/editor/editor_tests/editor_config_test.cpp index 7666d23a2a..acfa7d2508 100644 --- a/editor/editor_tests/editor_config_test.cpp +++ b/editor/editor_tests/editor_config_test.cpp @@ -5,8 +5,6 @@ #include "base/stl_helpers.hpp" -#include "std/set.hpp" - using namespace editor; UNIT_TEST(EditorConfig_TypeDescription) diff --git a/editor/editor_tests/feature_matcher_test.cpp b/editor/editor_tests/feature_matcher_test.cpp index 15b7ca1204..b38b7ba4b1 100644 --- a/editor/editor_tests/feature_matcher_test.cpp +++ b/editor/editor_tests/feature_matcher_test.cpp @@ -279,7 +279,7 @@ UNIT_TEST(GetBestOsmNode_Test) TEST(osmResponse.load_buffer(osmRawResponseNode, ::strlen(osmRawResponseNode)), ()); auto const bestNode = matcher::GetBestOsmNode(osmResponse, ms::LatLon(53.8977254, 27.5578377)); - TEST_EQUAL(bestNode.attribute("id").value(), string("277172019"), ()); + TEST_EQUAL(bestNode.attribute("id").value(), std::string("277172019"), ()); } } @@ -288,7 +288,7 @@ UNIT_TEST(GetBestOsmWay_Test) { pugi::xml_document osmResponse; TEST(osmResponse.load_buffer(osmRawResponseWay, ::strlen(osmRawResponseWay)), ()); - vector<m2::PointD> const geometry = { + std::vector<m2::PointD> const geometry = { {27.557515856307106, 64.236609073256034}, {27.55784576801841, 64.236820967769773}, {27.557352241556003, 64.236863883114324}, @@ -308,7 +308,7 @@ UNIT_TEST(GetBestOsmWay_Test) pugi::xml_document osmResponse; TEST(osmResponse.load_buffer(osmRawResponseWay, ::strlen(osmRawResponseWay)), ()); // Each point is moved for 0.0001 on x and y. It is aboout a half of side length. - vector<m2::PointD> const geometry = { + std::vector<m2::PointD> const geometry = { {27.557615856307106, 64.236709073256034}, {27.55794576801841, 64.236920967769773}, {27.557452241556003, 64.236963883114324}, @@ -329,7 +329,7 @@ UNIT_TEST(GetBestOsmRealtion_Test) { pugi::xml_document osmResponse; TEST(osmResponse.load_buffer(osmRawResponseRelation, ::strlen(osmRawResponseRelation)), ()); - vector<m2::PointD> const geometry = { + std::vector<m2::PointD> const geometry = { {37.640253436865322, 67.455316241497655}, {37.64019442826654, 67.455394025559684}, {37.640749645536772, 67.455726619480004}, @@ -402,7 +402,7 @@ UNIT_TEST(GetBestOsmRealtion_Test) }; auto const bestWay = matcher::GetBestOsmWayOrRelation(osmResponse, geometry); - TEST_EQUAL(bestWay.attribute("id").value(), string("365808"), ()); + TEST_EQUAL(bestWay.attribute("id").value(), std::string("365808"), ()); } char const * const osmResponseBuildingMiss = R"SEP( @@ -452,7 +452,7 @@ UNIT_TEST(HouseBuildingMiss_test) { pugi::xml_document osmResponse; TEST(osmResponse.load_buffer(osmResponseBuildingMiss, ::strlen(osmResponseBuildingMiss)), ()); - vector<m2::PointD> const geometry = { + std::vector<m2::PointD> const geometry = { {-0.2048121407986514, 60.333984198674443}, {-0.20478800091734684, 60.333909096821458}, {-0.20465925488366565, 60.334029796228037}, @@ -462,10 +462,10 @@ UNIT_TEST(HouseBuildingMiss_test) }; auto const bestWay = matcher::GetBestOsmWayOrRelation(osmResponse, geometry); - TEST_EQUAL(bestWay.attribute("id").value(), string("345630019"), ()); + TEST_EQUAL(bestWay.attribute("id").value(), std::string("345630019"), ()); } -string const kHouseWithSeveralEntrances = R"xxx(" +std::string const kHouseWithSeveralEntrances = R"xxx(" <osm version="0.6" generator="CGImap 0.6.0 (3589 thorn-03.openstreetmap.org)" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/"> <node id="339283610" visible="true" version="6" changeset="33699414" timestamp="2015-08-31T09:53:02Z" user="Lazy Ranma" uid="914471" lat="55.8184397" lon="37.5700770"/> <node id="339283612" visible="true" version="6" changeset="33699414" timestamp="2015-08-31T09:53:02Z" user="Lazy Ranma" uid="914471" lat="55.8184655" lon="37.5702599"/> @@ -512,7 +512,7 @@ UNIT_TEST(HouseWithSeveralEntrances) TEST(osmResponse.load_buffer(kHouseWithSeveralEntrances.c_str(), kHouseWithSeveralEntrances.size()), ()); - vector<m2::PointD> geometry = { + std::vector<m2::PointD> geometry = { {37.570076119676798, 67.574481424499169}, {37.570258509891175, 67.574527022052763}, {37.569802534355233, 67.575570401367315}, @@ -522,10 +522,10 @@ UNIT_TEST(HouseWithSeveralEntrances) }; auto const bestWay = matcher::GetBestOsmWayOrRelation(osmResponse, geometry); - TEST_EQUAL(bestWay.attribute("id").value(), string("30680719"), ()); + TEST_EQUAL(bestWay.attribute("id").value(), std::string("30680719"), ()); } -string const kRelationWithSingleWay = R"XXX( +std::string const kRelationWithSingleWay = R"XXX( <osm version="0.6" generator="CGImap 0.6.0 (2191 thorn-01.openstreetmap.org)" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/"> <node id="287253844" visible="true" version="6" changeset="41744272" timestamp="2016-08-27T20:57:16Z" user="VadiŠ¼" uid="326091" lat="55.7955735" lon="37.5399204"/> <node id="287253846" visible="true" version="6" changeset="41744272" timestamp="2016-08-27T20:57:16Z" user="VadiŠ¼" uid="326091" lat="55.7952597" lon="37.5394774"/> @@ -561,7 +561,7 @@ UNIT_TEST(RelationWithSingleWay) pugi::xml_document osmResponse; TEST(osmResponse.load_buffer(kRelationWithSingleWay.c_str(), kRelationWithSingleWay.size()), ()); - vector<m2::PointD> geometry = { + std::vector<m2::PointD> geometry = { {37.539920043497688, 67.533792313440074}, {37.539477479006933, 67.533234413960827}, {37.541207503834414, 67.532770391797811}, @@ -571,12 +571,12 @@ UNIT_TEST(RelationWithSingleWay) }; auto const bestWay = matcher::GetBestOsmWayOrRelation(osmResponse, geometry); - TEST_EQUAL(bestWay.attribute("id").value(), string("26232961"), ()); + TEST_EQUAL(bestWay.attribute("id").value(), std::string("26232961"), ()); } UNIT_TEST(ScoreTriangulatedGeometries) { - vector<m2::PointD> lhs = { + std::vector<m2::PointD> lhs = { {0, 0}, {10, 10}, {10, 0}, @@ -585,7 +585,7 @@ UNIT_TEST(ScoreTriangulatedGeometries) {0, 10} }; - vector<m2::PointD> rhs = { + std::vector<m2::PointD> rhs = { {-1, -1}, {9, 9}, {9, -1}, diff --git a/editor/editor_tests/match_by_geometry_test.cpp b/editor/editor_tests/match_by_geometry_test.cpp index 86b06b86ce..19a3521a2c 100644 --- a/editor/editor_tests/match_by_geometry_test.cpp +++ b/editor/editor_tests/match_by_geometry_test.cpp @@ -8,7 +8,7 @@ namespace { // This place on OSM map https://www.openstreetmap.org/relation/1359233. -string const kSenatskiyDvorets = R"XXX( +std::string const kSenatskiyDvorets = R"XXX( <?xml version="1.0" encoding="UTF-8"?> <osm version="0.6" generator="CGImap 0.6.0 (31854 thorn-01.openstreetmap.org)" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/"> <node id="271895281" visible="true" version="9" changeset="39264478" timestamp="2016-05-12T13:15:43Z" user="Felis Pimeja" uid="260756" lat="55.7578113" lon="37.6220187" /> @@ -141,7 +141,7 @@ UNIT_TEST(MatchByGeometry) // It is a triangulated polygon. Every triangle is presented as three points. // For simplification, you can visualize it as a single sequence of points // by using, for ex. Gnuplot. - vector<m2::PointD> geometry = { + std::vector<m2::PointD> geometry = { {37.621818614168603, 67.468231078000599}, {37.621858847304139, 67.468292768808396}, {37.621783745451154, 67.468236442418657}, @@ -250,7 +250,7 @@ UNIT_TEST(MatchByGeometry) }; auto const matched = matcher::GetBestOsmWayOrRelation(osmResponse, geometry); - TEST_EQUAL(matched.attribute("id").value(), string("85761"), ()); + TEST_EQUAL(matched.attribute("id").value(), std::string("85761"), ()); } } // namespace diff --git a/editor/editor_tests/new_feature_categories_test.cpp b/editor/editor_tests/new_feature_categories_test.cpp index ddc86a5e57..aefca0ca01 100644 --- a/editor/editor_tests/new_feature_categories_test.cpp +++ b/editor/editor_tests/new_feature_categories_test.cpp @@ -6,18 +6,13 @@ #include "indexer/classificator.hpp" #include "indexer/classificator_loader.hpp" -#include "std/transform_iterator.hpp" - -#include <functional> -#include <map> -#include <set> +#include <algorithm> #include <string> -#include <vector> + +using namespace std; UNIT_TEST(NewFeatureCategories_UniqueNames) { - using namespace std; - classificator::Load(); editor::EditorConfig config; @@ -32,8 +27,8 @@ UNIT_TEST(NewFeatureCategories_UniqueNames) continue; categories.AddLanguage(lang); auto names = categories.GetAllCreatableTypeNames(); - std::sort(names.begin(), names.end()); - auto result = std::unique(names.begin(), names.end()); + sort(names.begin(), names.end()); + auto result = unique(names.begin(), names.end()); if (result != names.end()) { diff --git a/editor/editor_tests/opening_hours_ui_test.cpp b/editor/editor_tests/opening_hours_ui_test.cpp index 6d5014e095..176daf31a9 100644 --- a/editor/editor_tests/opening_hours_ui_test.cpp +++ b/editor/editor_tests/opening_hours_ui_test.cpp @@ -2,6 +2,8 @@ #include "editor/opening_hours_ui.hpp" +#include <set> + using namespace editor::ui; UNIT_TEST(TestTimeTable) @@ -23,7 +25,7 @@ UNIT_TEST(TestTimeTable) TEST(tt.RemoveWorkingDay(osmoh::Weekday::Friday), ()); TEST(!tt.RemoveWorkingDay(osmoh::Weekday::Saturday), ()); - TEST_EQUAL(tt.GetOpeningDays(), (set<osmoh::Weekday>{osmoh::Weekday::Saturday}), ()); + TEST_EQUAL(tt.GetOpeningDays(), (std::set<osmoh::Weekday>{osmoh::Weekday::Saturday}), ()); } } @@ -184,7 +186,7 @@ UNIT_TEST(TestAppendTimeTable) TEST(tt.Commit(), ()); TEST(tts.Append(tts.GetComplementTimeTable()), ()); - TEST_EQUAL(tts.Back().GetOpeningDays(), (set<osmoh::Weekday>{osmoh::Weekday::Sunday, + TEST_EQUAL(tts.Back().GetOpeningDays(), (std::set<osmoh::Weekday>{osmoh::Weekday::Sunday, osmoh::Weekday::Saturday}), ()); } @@ -196,7 +198,7 @@ UNIT_TEST(TestAppendTimeTable) } TEST(tts.Append(tts.GetComplementTimeTable()), ()); - TEST_EQUAL(tts.Back().GetOpeningDays(), (set<osmoh::Weekday>{osmoh::Weekday::Monday, + TEST_EQUAL(tts.Back().GetOpeningDays(), (std::set<osmoh::Weekday>{osmoh::Weekday::Monday, osmoh::Weekday::Tuesday}), ()); TEST(!tts.GetComplementTimeTable().IsValid(), ()); @@ -206,7 +208,7 @@ UNIT_TEST(TestAppendTimeTable) TEST(tts.Remove(0), ()); TEST(tts.Remove(1), ()); TEST_EQUAL(tts.Size(), 1, ()); - TEST_EQUAL(tts.GetUnhandledDays(), (set<osmoh::Weekday>{osmoh::Weekday::Monday, + TEST_EQUAL(tts.GetUnhandledDays(), (std::set<osmoh::Weekday>{osmoh::Weekday::Monday, osmoh::Weekday::Tuesday, osmoh::Weekday::Wednesday, osmoh::Weekday::Thursday, diff --git a/editor/editor_tests/osm_editor_test.cpp b/editor/editor_tests/osm_editor_test.cpp index 13195724ac..e01336581a 100644 --- a/editor/editor_tests/osm_editor_test.cpp +++ b/editor/editor_tests/osm_editor_test.cpp @@ -19,7 +19,7 @@ #include "coding/file_name_utils.hpp" -#include "std/unique_ptr.hpp" +#include <memory> using namespace generator::tests_support; using namespace editor::tests_support; @@ -47,7 +47,7 @@ private: class TestCafe : public TestPOI { public: - TestCafe(m2::PointD const & center, string const & name, string const & lang) + TestCafe(m2::PointD const & center, std::string const & name, std::string const & lang) : TestPOI(center, name, lang) { SetTypes({{"amenity", "cafe"}}); @@ -89,13 +89,13 @@ public: ScopedOptionalSaveStorage() { auto & editor = osm::Editor::Instance(); - editor.SetStorageForTesting(unique_ptr<OptionalSaveStorage>(m_storage)); + editor.SetStorageForTesting(std::unique_ptr<OptionalSaveStorage>(m_storage)); } ~ScopedOptionalSaveStorage() { auto & editor = osm::Editor::Instance(); - editor.SetStorageForTesting(make_unique<editor::InMemoryStorage>()); + editor.SetStorageForTesting(std::make_unique<editor::InMemoryStorage>()); } void AllowSave(bool allow) @@ -202,7 +202,7 @@ EditorTest::EditorTest() LOG(LERROR, ("Classificator read error: ", e.what())); } - editor::tests_support::SetUpEditorForTesting(make_unique<search::EditorDelegate>(m_dataSource)); + editor::tests_support::SetUpEditorForTesting(std::make_unique<search::EditorDelegate>(m_dataSource)); } EditorTest::~EditorTest() @@ -361,7 +361,7 @@ void EditorTest::GetEditedFeatureStreetTest() { FeatureID feature; - string street; + std::string street; TEST(!editor.GetEditedFeatureStreet(feature, street), ()); } @@ -373,7 +373,7 @@ void EditorTest::GetEditedFeatureStreetTest() ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [&editor](FeatureType & ft) { - string street; + std::string street; TEST(!editor.GetEditedFeatureStreet(ft.GetID(), street), ()); osm::LocalizedStreet ls{"some street", ""}; @@ -622,7 +622,7 @@ void EditorTest::RollBackChangesTest() builder.Add(cafe); }); - const string houseNumber = "4a"; + const std::string houseNumber = "4a"; ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [&editor, &houseNumber](FeatureType & ft) { @@ -677,7 +677,7 @@ void EditorTest::HaveMapEditsOrNotesToUploadTest() { using NoteType = osm::Editor::NoteProblemType; feature::TypesHolder typesHolder; - string defaultName; + std::string defaultName; editor.CreateNote({1.0, 1.0}, ft.GetID(), typesHolder, defaultName, NoteType::PlaceDoesNotExist, "exploded"); }); @@ -879,16 +879,16 @@ void EditorTest::CreateNoteTest() editor.m_notes = Notes::MakeNotes(sf.GetFullPath(), true); feature::TypesHolder holder; holder.Assign(classif().GetTypeByPath({"amenity", "restaurant"})); - string defaultName = "Test name"; + std::string defaultName = "Test name"; editor.CreateNote(pos, fId, holder, defaultName, noteType, "with comment"); auto notes = editor.m_notes->GetNotes(); TEST_EQUAL(notes.size(), 1, ()); TEST(notes.front().m_point.EqualDxDy(pos, 1e-10), ()); - TEST_NOT_EQUAL(notes.front().m_note.find("with comment"), string::npos, ()); - TEST_NOT_EQUAL(notes.front().m_note.find("OSM data version"), string::npos, ()); - TEST_NOT_EQUAL(notes.front().m_note.find("restaurant"), string::npos, ()); - TEST_NOT_EQUAL(notes.front().m_note.find("Test name"), string::npos, ()); + TEST_NOT_EQUAL(notes.front().m_note.find("with comment"), std::string::npos, ()); + TEST_NOT_EQUAL(notes.front().m_note.find("OSM data version"), std::string::npos, ()); + TEST_NOT_EQUAL(notes.front().m_note.find("restaurant"), std::string::npos, ()); + TEST_NOT_EQUAL(notes.front().m_note.find("Test name"), std::string::npos, ()); }; ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [&editor, &createAndCheckNote](FeatureType & ft) @@ -896,7 +896,7 @@ void EditorTest::CreateNoteTest() createAndCheckNote(ft.GetID(), {1.0, 1.0}, osm::Editor::NoteProblemType::PlaceDoesNotExist); auto notes = editor.m_notes->GetNotes(); - TEST_NOT_EQUAL(notes.front().m_note.find(osm::Editor::kPlaceDoesNotExistMessage), string::npos, ()); + TEST_NOT_EQUAL(notes.front().m_note.find(osm::Editor::kPlaceDoesNotExistMessage), std::string::npos, ()); TEST_EQUAL(editor.GetFeatureStatus(ft.GetID()), FeatureStatus::Obsolete, ()); }); @@ -906,7 +906,7 @@ void EditorTest::CreateNoteTest() TEST_NOT_EQUAL(editor.GetFeatureStatus(ft.GetID()), FeatureStatus::Obsolete, ()); auto notes = editor.m_notes->GetNotes(); - TEST_EQUAL(notes.front().m_note.find(osm::Editor::kPlaceDoesNotExistMessage), string::npos, ()); + TEST_EQUAL(notes.front().m_note.find(osm::Editor::kPlaceDoesNotExistMessage), std::string::npos, ()); }); } @@ -932,7 +932,7 @@ void EditorTest::LoadMapEditsTest() builder.Add(TestPOI(m2::PointD(100, 100), "Corner Post", "default")); }); - vector<FeatureID> features; + std::vector<FeatureID> features; ForEachCafeAtPoint(m_dataSource, m2::PointD(0.0, 0.0), [&features](FeatureType & ft) { @@ -977,7 +977,7 @@ void EditorTest::LoadMapEditsTest() editor.Save((*editor.m_features.Get())); editor.LoadEdits(); - auto const fillLoaded = [&editor](vector<FeatureID> & loadedFeatures) + auto const fillLoaded = [&editor](std::vector<FeatureID> & loadedFeatures) { loadedFeatures.clear(); for (auto const & mwm : *(editor.m_features.Get())) @@ -989,7 +989,7 @@ void EditorTest::LoadMapEditsTest() } }; - vector<FeatureID> loadedFeatures; + std::vector<FeatureID> loadedFeatures; fillLoaded(loadedFeatures); sort(loadedFeatures.begin(), loadedFeatures.end()); @@ -1209,7 +1209,7 @@ void EditorTest::SaveTransactionTest() { using NoteType = osm::Editor::NoteProblemType; feature::TypesHolder typesHolder; - string defaultName; + std::string defaultName; editor.CreateNote({1.0, 1.0}, ft.GetID(), typesHolder, defaultName, NoteType::PlaceDoesNotExist, "exploded"); }); diff --git a/editor/editor_tests/osm_editor_test.hpp b/editor/editor_tests/osm_editor_test.hpp index d8a0369c9d..9656d042a0 100644 --- a/editor/editor_tests/osm_editor_test.hpp +++ b/editor/editor_tests/osm_editor_test.hpp @@ -13,6 +13,10 @@ #include "platform/local_country_file_utils.hpp" +#include <string> +#include <utility> +#include <vector> + namespace editor { namespace testing @@ -48,11 +52,11 @@ private: template <typename TBuildFn> MwmSet::MwmId ConstructTestMwm(TBuildFn && fn) { - return BuildMwm("TestCountry", forward<TBuildFn>(fn)); + return BuildMwm("TestCountry", std::forward<TBuildFn>(fn)); } template <typename TBuildFn> - MwmSet::MwmId BuildMwm(string const & name, TBuildFn && fn, int64_t version = 0) + MwmSet::MwmId BuildMwm(std::string const & name, TBuildFn && fn, int64_t version = 0) { m_mwmFiles.emplace_back(GetPlatform().WritableDir(), platform::CountryFile(name), version); auto & file = m_mwmFiles.back(); @@ -82,7 +86,7 @@ private: EditableDataSource m_dataSource; storage::CountryInfoGetterForTesting m_infoGetter; - vector<platform::LocalCountryFile> m_mwmFiles; + std::vector<platform::LocalCountryFile> m_mwmFiles; }; } // namespace testing } // namespace editor diff --git a/editor/editor_tests/ui2oh_test.cpp b/editor/editor_tests/ui2oh_test.cpp index 271aad9c03..3f5bcfe0ea 100644 --- a/editor/editor_tests/ui2oh_test.cpp +++ b/editor/editor_tests/ui2oh_test.cpp @@ -2,7 +2,8 @@ #include "editor/ui2oh.hpp" -#include "std/sstream.hpp" +#include <sstream> +#include <string> using namespace osmoh; using namespace editor; @@ -10,9 +11,9 @@ using namespace editor::ui; namespace { -string ToString(OpeningHours const & oh) +std::string ToString(OpeningHours const & oh) { - stringstream sstr; + std::stringstream sstr; sstr << oh.GetRule(); return sstr.str(); } diff --git a/editor/editor_tests/xml_feature_test.cpp b/editor/editor_tests/xml_feature_test.cpp index ff0a91bd74..0ee64e2839 100644 --- a/editor/editor_tests/xml_feature_test.cpp +++ b/editor/editor_tests/xml_feature_test.cpp @@ -9,8 +9,10 @@ #include "base/timer.hpp" -#include "std/map.hpp" -#include "std/sstream.hpp" +#include <map> +#include <sstream> +#include <string> +#include <vector> #include "3party/pugixml/src/pugixml.hpp" @@ -40,7 +42,7 @@ UNIT_TEST(XMLFeature_RawGetSet) </node> )"; - stringstream sstr; + std::stringstream sstr; feature.Save(sstr); TEST_EQUAL(expected, sstr.str(), ()); } @@ -62,7 +64,7 @@ UNIT_TEST(XMLFeature_Setters) feature.SetTagValue("opening_hours", "Mo-Fr 08:15-17:30"); feature.SetTagValue("amenity", "atm"); - stringstream sstr; + std::stringstream sstr; feature.Save(sstr); auto const expectedString = R"(<?xml version="1.0"?> @@ -90,7 +92,7 @@ UNIT_TEST(XMLFeature_UintLang) feature.SetName(StringUtf8Multilang::kDefaultCode, "Gorki Park"); feature.SetName(StringUtf8Multilang::GetLangIndex("ru"), "ŠŠ°ŃŠŗ ŠŠ¾ŃŃŠŗŠ¾Š³Š¾"); feature.SetName(StringUtf8Multilang::kInternationalCode, "Gorky Park"); - stringstream sstr; + std::stringstream sstr; feature.Save(sstr); auto const expectedString = R"(<?xml version="1.0"?> @@ -174,7 +176,7 @@ UNIT_TEST(XMLFeature_FromXml) { XMLFeature feature(kTestNode); - stringstream sstr; + std::stringstream sstr; feature.Save(sstr); TEST_EQUAL(kTestNode, sstr.str(), ()); @@ -200,15 +202,14 @@ UNIT_TEST(XMLFeature_FromXml) UNIT_TEST(XMLFeature_ForEachName) { XMLFeature feature(kTestNode); - map<string, string> names; + std::map<std::string, std::string> names; - feature.ForEachName([&names](string const & lang, string const & name) - { - names.emplace(lang, name); - }); + feature.ForEachName( + [&names](std::string const & lang, std::string const & name) { names.emplace(lang, name); }); - TEST_EQUAL(names, (map<string, string>{ - {"default", "Gorki Park"}, {"en", "Gorki Park"}, {"ru", "ŠŠ°ŃŠŗ ŠŠ¾ŃŃŠŗŠ¾Š³Š¾"}}), + TEST_EQUAL(names, + (std::map<std::string, std::string>{ + {"default", "Gorki Park"}, {"en", "Gorki Park"}, {"ru", "ŠŠ°ŃŠŗ ŠŠ¾ŃŃŠŗŠ¾Š³Š¾"}}), ()); } @@ -233,7 +234,7 @@ UNIT_TEST(XMLFeature_FromOSM) TEST_ANY_THROW(XMLFeature::FromOSM("<?xml version=\"1.0\"?>"), ()); TEST_NO_THROW(XMLFeature::FromOSM("<?xml version=\"1.0\"?><osm></osm>"), ()); TEST_ANY_THROW(XMLFeature::FromOSM("<?xml version=\"1.0\"?><osm><node lat=\"11.11\"/></osm>"), ()); - vector<XMLFeature> features; + std::vector<XMLFeature> features; TEST_NO_THROW(features = XMLFeature::FromOSM(kTestNodeWay), ()); TEST_EQUAL(3, features.size(), ()); XMLFeature const & node = features[0]; @@ -264,15 +265,10 @@ UNIT_TEST(XMLFeature_FromXmlNode) UNIT_TEST(XMLFeature_Geometry) { - vector<m2::PointD> const geometry = { - {28.7206411, 3.7182409}, - {46.7569003, 47.0774689}, - {22.5909217, 41.6994874}, - {14.7537008, 17.7788229}, - {55.1261701, 10.3199476}, - {28.6519654, 50.0305930}, - {28.7206411, 3.7182409} - }; + std::vector<m2::PointD> const geometry = {{28.7206411, 3.7182409}, {46.7569003, 47.0774689}, + {22.5909217, 41.6994874}, {14.7537008, 17.7788229}, + {55.1261701, 10.3199476}, {28.6519654, 50.0305930}, + {28.7206411, 3.7182409}}; XMLFeature feature(XMLFeature::Type::Way); feature.SetGeometry(geometry); @@ -309,7 +305,7 @@ UNIT_TEST(XMLFeature_ApplyPatch) hasMainTag.ApplyPatch(XMLFeature(kPatch)); TEST_EQUAL(hasMainTag.GetTagValue("website"), "maps.me", ()); size_t tagsCount = 0; - hasMainTag.ForEachTag([&tagsCount](string const &, string const &){ ++tagsCount; }); + hasMainTag.ForEachTag([&tagsCount](std::string const &, std::string const &) { ++tagsCount; }); TEST_EQUAL(2, tagsCount, ("website should be replaced, not duplicated.")); } @@ -353,7 +349,7 @@ UNIT_TEST(XMLFeature_FromXMLAndBackToXML) { classificator::Load(); - string const xmlNoTypeStr = R"(<?xml version="1.0"?> + std::string const xmlNoTypeStr = R"(<?xml version="1.0"?> <node lat="55.7978998" lon="37.474528" timestamp="2015-11-27T21:13:32Z"> <tag k="name" v="Gorki Park" /> <tag k="name:en" v="Gorki Park" /> diff --git a/editor/editor_tests_support/helpers.cpp b/editor/editor_tests_support/helpers.cpp index bb79236dde..ad0f8e108c 100644 --- a/editor/editor_tests_support/helpers.cpp +++ b/editor/editor_tests_support/helpers.cpp @@ -2,15 +2,17 @@ #include "editor/editor_storage.hpp" +#include <utility> + namespace editor { namespace tests_support { -void SetUpEditorForTesting(unique_ptr<osm::Editor::Delegate> delegate) +void SetUpEditorForTesting(std::unique_ptr<osm::Editor::Delegate> delegate) { auto & editor = osm::Editor::Instance(); - editor.SetDelegate(move(delegate)); - editor.SetStorageForTesting(make_unique<editor::InMemoryStorage>()); + editor.SetDelegate(std::move(delegate)); + editor.SetStorageForTesting(std::make_unique<editor::InMemoryStorage>()); editor.ClearAllLocalEdits(); editor.ResetNotes(); } diff --git a/editor/editor_tests_support/helpers.hpp b/editor/editor_tests_support/helpers.hpp index 7431fbb582..67686e90bb 100644 --- a/editor/editor_tests_support/helpers.hpp +++ b/editor/editor_tests_support/helpers.hpp @@ -6,13 +6,13 @@ #include "base/assert.hpp" -#include "std/unique_ptr.hpp" +#include <memory> namespace editor { namespace tests_support { -void SetUpEditorForTesting(unique_ptr<osm::Editor::Delegate> delegate); +void SetUpEditorForTesting(std::unique_ptr<osm::Editor::Delegate> delegate); void TearDownEditorForTesting(); template <typename TFn> diff --git a/editor/feature_matcher.cpp b/editor/feature_matcher.cpp index 9eaa16dee4..0ec612f7cb 100644 --- a/editor/feature_matcher.cpp +++ b/editor/feature_matcher.cpp @@ -4,10 +4,10 @@ #include "base/stl_helpers.hpp" #include "base/stl_iterator.hpp" -#include "std/algorithm.hpp" -#include "std/function.hpp" -#include "std/string.hpp" -#include "std/utility.hpp" +#include <algorithm> +#include <functional> +#include <string> +#include <utility> #include <boost/geometry.hpp> #include <boost/geometry/geometries/adapted/boost_tuple.hpp> diff --git a/editor/new_feature_categories.cpp b/editor/new_feature_categories.cpp index d0e9967857..d66cde23ca 100644 --- a/editor/new_feature_categories.cpp +++ b/editor/new_feature_categories.cpp @@ -6,8 +6,8 @@ #include "base/assert.hpp" #include "base/stl_helpers.hpp" -#include "std/algorithm.hpp" -#include "std/utility.hpp" +#include <algorithm> +#include <utility> #include "3party/Alohalytics/src/alohalytics.h" @@ -33,12 +33,11 @@ NewFeatureCategories::NewFeatureCategories(editor::EditorConfig const & config) } NewFeatureCategories::NewFeatureCategories(NewFeatureCategories && other) - : m_index(move(other.m_index)) - , m_types(move(other.m_types)) + : m_index(std::move(other.m_index)), m_types(std::move(other.m_types)) { } -void NewFeatureCategories::AddLanguage(string lang) +void NewFeatureCategories::AddLanguage(std::string lang) { auto langCode = CategoriesHolder::MapLocaleToInteger(lang); if (langCode == CategoriesHolder::kUnsupportedLocaleCode) @@ -58,9 +57,9 @@ void NewFeatureCategories::AddLanguage(string lang) m_addedLangs.Insert(langCode); } -NewFeatureCategories::TypeNames NewFeatureCategories::Search(string const & query) const +NewFeatureCategories::TypeNames NewFeatureCategories::Search(std::string const & query) const { - vector<uint32_t> resultTypes; + std::vector<uint32_t> resultTypes; m_index.GetAssociatedTypes(query, resultTypes); auto const & c = classif(); diff --git a/editor/new_feature_categories.hpp b/editor/new_feature_categories.hpp index fb2110c89d..70ef5af080 100644 --- a/editor/new_feature_categories.hpp +++ b/editor/new_feature_categories.hpp @@ -8,9 +8,9 @@ #include "base/macros.hpp" #include "base/small_set.hpp" -#include "std/cstdint.hpp" -#include "std/string.hpp" -#include "std/vector.hpp" +#include <cstdint> +#include <string> +#include <vector> namespace osm { @@ -19,7 +19,7 @@ class NewFeatureCategories { public: using TypeName = string; - using TypeNames = vector<TypeName>; + using TypeNames = std::vector<TypeName>; NewFeatureCategories(editor::EditorConfig const & config); @@ -34,13 +34,13 @@ public: // If one language is added more than once, all the calls except for the // first one are ignored. // If |lang| is not supported, "en" is used. - void AddLanguage(string lang); + void AddLanguage(std::string lang); // Returns names (in language |queryLang|) and types of categories that have a synonym containing // the substring |query| (in any language that was added before). // If |lang| is not supported, "en" is used. // The returned list is sorted. - TypeNames Search(string const & query) const; + TypeNames Search(std::string const & query) const; // Returns all registered names of categories in language |lang| and // types corresponding to these names. The language must have been added before. diff --git a/editor/opening_hours_ui.cpp b/editor/opening_hours_ui.cpp index f1cf4f7580..f39ae494f0 100644 --- a/editor/opening_hours_ui.cpp +++ b/editor/opening_hours_ui.cpp @@ -1,10 +1,7 @@ #include "opening_hours_ui.hpp" -#include "std/algorithm.hpp" -#include "std/numeric.hpp" -#include "std/stack.hpp" -#include "std/tuple.hpp" -#include "std/type_traits.hpp" +#include <algorithm> +#include <iterator> #include "base/assert.hpp" @@ -49,17 +46,17 @@ bool FixTimeSpans(osmoh::Timespan openingTime, osmoh::TTimespans & spans) span.GetEnd().GetHourMinutes().AddDuration(24_h); } - sort(begin(spans), end(spans), [](osmoh::Timespan const & s1, osmoh::Timespan const s2) - { - auto const start1 = s1.GetStart().GetHourMinutes(); - auto const start2 = s2.GetStart().GetHourMinutes(); + std::sort(std::begin(spans), std::end(spans), + [](osmoh::Timespan const & s1, osmoh::Timespan const s2) { + auto const start1 = s1.GetStart().GetHourMinutes(); + auto const start2 = s2.GetStart().GetHourMinutes(); - // If two spans start at the same point the longest span should be leftmost. - if (start1 == start2) - return SpanLength(s1) > SpanLength(s2); + // If two spans start at the same point the longest span should be leftmost. + if (start1 == start2) + return SpanLength(s1) > SpanLength(s2); - return start1 < start2; - }); + return start1 < start2; + }); osmoh::TTimespans result{spans.front()}; for (size_t i = 1, j = 0; i < spans.size(); ++i) @@ -329,10 +326,8 @@ TimeTable TimeTableSet::GetComplementTimeTable() const bool TimeTableSet::IsTwentyFourPerSeven() const { return GetUnhandledDays().empty() && - all_of(std::begin(m_table), std::end(m_table), [](TimeTable const & tt) - { - return tt.IsTwentyFourHours(); - }); + std::all_of(std::begin(m_table), std::end(m_table), + [](TimeTable const & tt) { return tt.IsTwentyFourHours(); }); } bool TimeTableSet::Append(TimeTable const & tt) @@ -387,9 +382,9 @@ bool TimeTableSet::UpdateByIndex(TimeTableSet & ttSet, size_t const index) auto && tt = ttSet.m_table[i]; // Remove all days of updated timetable from all other timetables. TOpeningDays days; - set_difference(std::begin(tt.GetOpeningDays()), std::end(tt.GetOpeningDays()), - std::begin(updated.GetOpeningDays()), std::end(updated.GetOpeningDays()), - inserter(days, std::end(days))); + std::set_difference(std::begin(tt.GetOpeningDays()), std::end(tt.GetOpeningDays()), + std::begin(updated.GetOpeningDays()), std::end(updated.GetOpeningDays()), + inserter(days, std::end(days))); if (!tt.SetOpeningDays(days)) return false; diff --git a/editor/opening_hours_ui.hpp b/editor/opening_hours_ui.hpp index 8c4d502372..e62de24ffd 100644 --- a/editor/opening_hours_ui.hpp +++ b/editor/opening_hours_ui.hpp @@ -1,7 +1,7 @@ #pragma once -#include "std/set.hpp" -#include "std/vector.hpp" +#include <set> +#include <vector> #include "3party/opening_hours/opening_hours.hpp" @@ -9,8 +9,7 @@ namespace editor { namespace ui { - -using TOpeningDays = set<osmoh::Weekday>; +using TOpeningDays = std::set<osmoh::Weekday>; class TimeTable { @@ -73,7 +72,7 @@ using TTimeTableProxy = TimeTableProxyBase<TimeTableSet>; class TimeTableSet { - using TTimeTableSetImpl = vector<TimeTable>; + using TTimeTableSetImpl = std::vector<TimeTable>; public: TimeTableSet(); diff --git a/editor/osm_auth.cpp b/editor/osm_auth.cpp index 690cd9c672..6326077d45 100644 --- a/editor/osm_auth.cpp +++ b/editor/osm_auth.cpp @@ -8,13 +8,15 @@ #include "base/logging.hpp" #include "base/string_utils.hpp" -#include "std/iostream.hpp" -#include "std/map.hpp" +#include <iostream> +#include <map> #include "private.h" #include "3party/liboauthcpp/include/liboauthcpp/liboauthcpp.h" +using namespace std; + using platform::HttpClient; namespace osm diff --git a/editor/osm_auth.hpp b/editor/osm_auth.hpp index 378d37c965..7bc872085f 100644 --- a/editor/osm_auth.hpp +++ b/editor/osm_auth.hpp @@ -2,13 +2,12 @@ #include "base/exception.hpp" -#include "std/string.hpp" -#include "std/utility.hpp" +#include <string> +#include <utility> namespace osm { - -using TKeySecret = pair<string /*key*/, string /*secret*/>; +using TKeySecret = std::pair<std::string /*key*/, std::string /*secret*/>; using TRequestToken = TKeySecret; /// All methods that interact with the OSM server are blocking and not asynchronous. @@ -34,9 +33,9 @@ public: }; /// A pair of <http error code, response contents>. - using Response = std::pair<int, string>; + using Response = std::pair<int, std::string>; /// A pair of <url, key-secret>. - using TUrlRequestToken = std::pair<string, TRequestToken>; + using TUrlRequestToken = std::pair<std::string, TRequestToken>; DECLARE_EXCEPTION(OsmOAuthException, RootException); DECLARE_EXCEPTION(NetworkError, OsmOAuthException); @@ -58,8 +57,8 @@ public: static bool IsValid(TUrlRequestToken const & urt) noexcept; /// The constructor. Simply stores a lot of strings in fields. - OsmOAuth(string const & consumerKey, string const & consumerSecret, - string const & baseUrl, string const & apiUrl) noexcept; + OsmOAuth(std::string const & consumerKey, std::string const & consumerSecret, + std::string const & baseUrl, std::string const & apiUrl) noexcept; /// Should be used everywhere in production code instead of servers below. static OsmOAuth ServerAuth() noexcept; @@ -77,62 +76,67 @@ public: bool IsAuthorized() const noexcept; /// @returns false if login and/or password are invalid. - bool AuthorizePassword(string const & login, string const & password); + bool AuthorizePassword(std::string const & login, std::string const & password); /// @returns false if Facebook credentials are invalid. - bool AuthorizeFacebook(string const & facebookToken); + bool AuthorizeFacebook(std::string const & facebookToken); /// @returns false if Google credentials are invalid. - bool AuthorizeGoogle(string const & googleToken); + bool AuthorizeGoogle(std::string const & googleToken); /// @returns false if email has not been registered on a server. - bool ResetPassword(string const & email) const; + bool ResetPassword(std::string const & email) const; /// Throws in case of network errors. /// @param[method] The API method, must start with a forward slash. - Response Request(string const & method, string const & httpMethod = "GET", string const & body = "") const; + Response Request(std::string const & method, std::string const & httpMethod = "GET", + std::string const & body = "") const; /// Tokenless GET request, for convenience. /// @param[api] If false, request is made to m_baseUrl. - Response DirectRequest(string const & method, bool api = true) const; + Response DirectRequest(std::string const & method, bool api = true) const; /// @name Methods for WebView-based authentication. //@{ TUrlRequestToken GetFacebookOAuthURL() const; TUrlRequestToken GetGoogleOAuthURL() const; - TKeySecret FinishAuthorization(TRequestToken const & requestToken, string const & verifier) const; + TKeySecret FinishAuthorization(TRequestToken const & requestToken, + std::string const & verifier) const; //AuthResult FinishAuthorization(TKeySecret const & requestToken, string const & verifier); - string GetRegistrationURL() const noexcept { return m_baseUrl + "/user/new"; } - string GetResetPasswordURL() const noexcept { return m_baseUrl + "/user/forgot-password"; } + std::string GetRegistrationURL() const noexcept { return m_baseUrl + "/user/new"; } + std::string GetResetPasswordURL() const noexcept { return m_baseUrl + "/user/forgot-password"; } //@} private: struct SessionID { - string m_cookies; - string m_token; + std::string m_cookies; + std::string m_token; }; /// Key and secret for application. TKeySecret const m_consumerKeySecret; - string const m_baseUrl; - string const m_apiUrl; + std::string const m_baseUrl; + std::string const m_apiUrl; /// Key and secret to sign every OAuth request. TKeySecret m_tokenKeySecret; - SessionID FetchSessionId(string const & subUrl = "/login", string const & cookies = "") const; + SessionID FetchSessionId(std::string const & subUrl = "/login", + std::string const & cookies = "") const; /// Log a user out. void LogoutUser(SessionID const & sid) const; /// Signs a user id using login and password. /// @returns false if login or password are invalid. - bool LoginUserPassword(string const & login, string const & password, SessionID const & sid) const; + bool LoginUserPassword(std::string const & login, std::string const & password, + SessionID const & sid) const; /// Signs a user in using Facebook token. /// @returns false if the social token is invalid. - bool LoginSocial(string const & callbackPart, string const & socialToken, SessionID const & sid) const; + bool LoginSocial(std::string const & callbackPart, std::string const & socialToken, + SessionID const & sid) const; /// @returns non-empty string with oauth_verifier value. - string SendAuthRequest(string const & requestTokenKey, SessionID const & lastSid) const; + std::string SendAuthRequest(std::string const & requestTokenKey, SessionID const & lastSid) const; /// @returns valid key and secret or throws otherwise. TRequestToken FetchRequestToken() const; TKeySecret FetchAccessToken(SessionID const & sid) const; //AuthResult FetchAccessToken(SessionID const & sid); }; -string DebugPrint(OsmOAuth::Response const & code); +std::string DebugPrint(OsmOAuth::Response const & code); } // namespace osm diff --git a/editor/osm_auth_tests/osm_auth_tests.cpp b/editor/osm_auth_tests/osm_auth_tests.cpp index 115ef2846d..82eaa74dee 100644 --- a/editor/osm_auth_tests/osm_auth_tests.cpp +++ b/editor/osm_auth_tests/osm_auth_tests.cpp @@ -2,6 +2,8 @@ #include "editor/osm_auth.hpp" +#include <string> + using osm::OsmOAuth; using osm::TKeySecret; @@ -31,7 +33,7 @@ UNIT_TEST(OSM_Auth_Login) TEST(auth.IsAuthorized(), ("Should be authorized.")); OsmOAuth::Response const perm = auth.Request("/permissions"); TEST_EQUAL(perm.first, OsmOAuth::HTTP::OK, ("permission request ok")); - TEST_NOT_EQUAL(perm.second.find("write_api"), string::npos, ("can write to api")); + TEST_NOT_EQUAL(perm.second.find("write_api"), std::string::npos, ("can write to api")); } UNIT_TEST(OSM_Auth_ForgotPassword) diff --git a/editor/osm_auth_tests/server_api_test.cpp b/editor/osm_auth_tests/server_api_test.cpp index a586889b9e..8c4086b23b 100644 --- a/editor/osm_auth_tests/server_api_test.cpp +++ b/editor/osm_auth_tests/server_api_test.cpp @@ -5,8 +5,10 @@ #include "geometry/mercator.hpp" #include "base/scope_guard.hpp" +#include "base/string_utils.hpp" -#include "std/cstring.hpp" +#include <cstdint> +#include <string> #include "3party/pugixml/src/pugixml.hpp" diff --git a/editor/osm_editor.cpp b/editor/osm_editor.cpp index 73898a97c6..23ea63852a 100644 --- a/editor/osm_editor.cpp +++ b/editor/osm_editor.cpp @@ -33,19 +33,18 @@ #include "base/thread_checker.hpp" #include "base/timer.hpp" -#include "std/algorithm.hpp" -#include "std/array.hpp" -#include "std/chrono.hpp" -#include "std/sstream.hpp" #include "std/target_os.hpp" -#include "std/tuple.hpp" -#include "std/unordered_map.hpp" -#include "std/unordered_set.hpp" + +#include <algorithm> +#include <array> +#include <sstream> #include "3party/Alohalytics/src/alohalytics.h" #include "3party/opening_hours/opening_hours.hpp" #include "3party/pugixml/src/pugixml.hpp" +using namespace std; + using namespace pugi; using feature::EGeomType; using feature::Metadata; @@ -69,13 +68,13 @@ constexpr char const * kMatchedFeatureIsEmpty = "Matched feature has no tags"; struct XmlSection { - XmlSection(FeatureStatus status, std::string const & sectionName) + XmlSection(FeatureStatus status, string const & sectionName) : m_status(status), m_sectionName(sectionName) { } FeatureStatus m_status = FeatureStatus::Untouched; - std::string m_sectionName; + string m_sectionName; }; array<XmlSection, 4> const kXmlSections = {{{FeatureStatus::Deleted, kDeleteSection}, @@ -853,11 +852,9 @@ void Editor::UploadChanges(string const & key, string const & secret, ChangesetT if (!m_isUploadingNow) { m_isUploadingNow = true; - GetPlatform().RunTask(Platform::Thread::Network, [upload = std::move(upload), key, secret, - tags = std::move(tags), callback = std::move(callback)]() - { - upload(std::move(key), std::move(secret), std::move(tags), std::move(callback)); - }); + GetPlatform().RunTask(Platform::Thread::Network, [ + upload = move(upload), key, secret, tags = move(tags), callback = move(callback) + ]() { upload(move(key), move(secret), move(tags), move(callback)); }); } } diff --git a/editor/osm_editor.hpp b/editor/osm_editor.hpp index d5a229857a..90ca99c40e 100644 --- a/editor/osm_editor.hpp +++ b/editor/osm_editor.hpp @@ -18,13 +18,12 @@ #include "base/atomic_shared_ptr.hpp" #include "base/timer.hpp" -#include "std/ctime.hpp" -#include "std/function.hpp" -#include "std/map.hpp" -#include "std/string.hpp" -#include "std/vector.hpp" - #include <atomic> +#include <ctime> +#include <functional> +#include <map> +#include <string> +#include <vector> namespace editor { @@ -49,17 +48,18 @@ class Editor final : public MwmSet::Observer Editor(); public: - using FeatureTypeFn = function<void(FeatureType & ft)>; - using InvalidateFn = function<void()>; - using ForEachFeaturesNearByFn = function<void(FeatureTypeFn && fn, m2::PointD const & mercator)>; + using FeatureTypeFn = std::function<void(FeatureType & ft)>; + using InvalidateFn = std::function<void()>; + using ForEachFeaturesNearByFn = + std::function<void(FeatureTypeFn && fn, m2::PointD const & mercator)>; struct Delegate { virtual ~Delegate() = default; - virtual MwmSet::MwmId GetMwmIdByMapName(string const & name) const = 0; + virtual MwmSet::MwmId GetMwmIdByMapName(std::string const & name) const = 0; virtual unique_ptr<EditableMapObject> GetOriginalMapObject(FeatureID const & fid) const = 0; - virtual string GetOriginalFeatureStreet(FeatureID const & fid) const = 0; + virtual std::string GetOriginalFeatureStreet(FeatureID const & fid) const = 0; virtual void ForEachFeatureAtPoint(FeatureTypeFn && fn, m2::PointD const & point) const = 0; }; @@ -70,7 +70,7 @@ public: NothingToUpload }; - using FinishUploadCallback = function<void(UploadResult)>; + using FinishUploadCallback = std::function<void(UploadResult)>; enum class SaveResult { @@ -90,7 +90,7 @@ public: struct Stats { /// <id, feature status string> - vector<pair<FeatureID, string>> m_edits; + std::vector<std::pair<FeatureID, std::string>> m_edits; size_t m_uploadedCount = 0; time_t m_lastUploadTimestamp = base::INVALID_TIME_STAMP; }; @@ -100,9 +100,12 @@ public: static Editor & Instance(); - void SetDelegate(unique_ptr<Delegate> delegate) { m_delegate = move(delegate); } + void SetDelegate(unique_ptr<Delegate> delegate) { m_delegate = std::move(delegate); } - void SetStorageForTesting(unique_ptr<editor::StorageBase> storage) { m_storage = move(storage); } + void SetStorageForTesting(unique_ptr<editor::StorageBase> storage) + { + m_storage = std::move(storage); + } void ResetNotes() { m_notes = editor::Notes::MakeNotes(); } @@ -122,7 +125,7 @@ public: void OnMapDeregistered(platform::LocalCountryFile const & localFile) override; - using FeatureIndexFunctor = function<void(uint32_t)>; + using FeatureIndexFunctor = std::function<void(uint32_t)>; void ForEachCreatedFeature(MwmSet::MwmId const & id, FeatureIndexFunctor const & f, m2::RectD const & rect, int scale) const; @@ -143,10 +146,11 @@ public: /// @returns false if feature wasn't edited. /// @param outFeatureStreet is valid only if true was returned. - bool GetEditedFeatureStreet(FeatureID const & fid, string & outFeatureStreet) const; + bool GetEditedFeatureStreet(FeatureID const & fid, std::string & outFeatureStreet) const; /// @returns sorted features indices with specified status. - vector<uint32_t> GetFeaturesByStatus(MwmSet::MwmId const & mwmId, FeatureStatus status) const; + std::vector<uint32_t> GetFeaturesByStatus(MwmSet::MwmId const & mwmId, + FeatureStatus status) const; /// Editor checks internally if any feature params were actually edited. SaveResult SaveEditedFeature(EditableMapObject const & emo); @@ -160,10 +164,10 @@ public: bool HaveMapEditsOrNotesToUpload() const; bool HaveMapEditsToUpload(MwmSet::MwmId const & mwmId) const; - using ChangesetTags = map<string, string>; + using ChangesetTags = std::map<std::string, std::string>; /// Tries to upload all local changes to OSM server in a separate thread. /// @param[in] tags should provide additional information about client to use in changeset. - void UploadChanges(string const & key, string const & secret, ChangesetTags tags, + void UploadChanges(std::string const & key, std::string const & secret, ChangesetTags tags, FinishUploadCallback callBack = FinishUploadCallback()); // TODO(mgsergio): Test new types from new config but with old classificator (where these types are absent). // Editor should silently ignore all types in config which are unknown to him. @@ -173,8 +177,8 @@ public: EditableMapObject & outFeature) const; void CreateNote(ms::LatLon const & latLon, FeatureID const & fid, - feature::TypesHolder const & holder, string const & defaultName, - NoteProblemType const type, string const & note); + feature::TypesHolder const & holder, std::string const & defaultName, + NoteProblemType const type, std::string const & note); Stats GetStats() const; @@ -189,8 +193,8 @@ private: { time_t m_uploadAttemptTimestamp = base::INVALID_TIME_STAMP; /// Is empty if upload has never occured or one of k* constants above otherwise. - string m_uploadStatus; - string m_uploadError; + std::string m_uploadStatus; + std::string m_uploadError; }; struct FeatureTypeInfo @@ -198,15 +202,15 @@ private: FeatureStatus m_status; EditableMapObject m_object; /// If not empty contains Feature's addr:street, edited by user. - string m_street; + std::string m_street; time_t m_modificationTimestamp = base::INVALID_TIME_STAMP; time_t m_uploadAttemptTimestamp = base::INVALID_TIME_STAMP; /// Is empty if upload has never occured or one of k* constants above otherwise. - string m_uploadStatus; - string m_uploadError; + std::string m_uploadStatus; + std::string m_uploadError; }; - using FeaturesContainer = map<MwmSet::MwmId, map<uint32_t, FeatureTypeInfo>>; + using FeaturesContainer = std::map<MwmSet::MwmId, std::map<uint32_t, FeatureTypeInfo>>; /// @returns false if fails. bool Save(FeaturesContainer const & features) const; @@ -234,9 +238,9 @@ private: FeatureStatus status); // These methods are just checked wrappers around Delegate. - MwmSet::MwmId GetMwmIdByMapName(string const & name); + MwmSet::MwmId GetMwmIdByMapName(std::string const & name); unique_ptr<EditableMapObject> GetOriginalMapObject(FeatureID const & fid) const; - string GetOriginalFeatureStreet(FeatureID const & fid) const; + std::string GetOriginalFeatureStreet(FeatureID const & fid) const; void ForEachFeatureAtPoint(FeatureTypeFn && fn, m2::PointD const & point) const; FeatureID GetFeatureIdByXmlFeature(FeaturesContainer const & features, editor::XMLFeature const & xml, MwmSet::MwmId const & mwmId, @@ -274,5 +278,5 @@ private: DECLARE_THREAD_CHECKER(MainThreadChecker); }; // class Editor -string DebugPrint(Editor::SaveResult const saveResult); +std::string DebugPrint(Editor::SaveResult const saveResult); } // namespace osm diff --git a/editor/server_api.cpp b/editor/server_api.cpp index 51c3faff18..d0c4397a2b 100644 --- a/editor/server_api.cpp +++ b/editor/server_api.cpp @@ -9,15 +9,16 @@ #include "base/string_utils.hpp" #include "base/timer.hpp" -#include "std/sstream.hpp" +#include <sstream> +#include <string> #include "3party/pugixml/src/pugixml.hpp" namespace { -string KeyValueTagsToXML(osm::ServerApi06::TKeyValueTags const & kvTags) +std::string KeyValueTagsToXML(osm::ServerApi06::TKeyValueTags const & kvTags) { - ostringstream stream; + std::ostringstream stream; stream << "<osm>\n" "<changeset>\n"; for (auto const & tag : kvTags) @@ -72,7 +73,7 @@ void ServerApi06::CreateElementAndSetAttributes(editor::XMLFeature & element) co uint64_t ServerApi06::ModifyElement(editor::XMLFeature const & element) const { - string const id = element.GetAttribute("id"); + std::string const id = element.GetAttribute("id"); if (id.empty()) MYTHROW(ModifiedElementHasNoIdAttribute, ("Please set id attribute for", element)); @@ -94,7 +95,7 @@ void ServerApi06::ModifyElementAndSetVersion(editor::XMLFeature & element) const void ServerApi06::DeleteElement(editor::XMLFeature const & element) const { - string const id = element.GetAttribute("id"); + std::string const id = element.GetAttribute("id"); if (id.empty()) MYTHROW(DeletedElementHasNoIdAttribute, ("Please set id attribute for", element)); @@ -118,10 +119,12 @@ void ServerApi06::CloseChangeSet(uint64_t changesetId) const MYTHROW(ErrorClosingChangeSet, ("CloseChangeSet request has failed:", response)); } -uint64_t ServerApi06::CreateNote(ms::LatLon const & ll, string const & message) const +uint64_t ServerApi06::CreateNote(ms::LatLon const & ll, std::string const & message) const { CHECK(!message.empty(), ("Note content should not be empty.")); - string const params = "?lat=" + strings::to_string_dac(ll.lat, 7) + "&lon=" + strings::to_string_dac(ll.lon, 7) + "&text=" + UrlEncode(message + " #mapsme"); + std::string const params = "?lat=" + strings::to_string_dac(ll.lat, 7) + + "&lon=" + strings::to_string_dac(ll.lon, 7) + + "&text=" + UrlEncode(message + " #mapsme"); OsmOAuth::Response const response = m_auth.Request("/notes" + params, "POST"); if (response.first != OsmOAuth::HTTP::OK) MYTHROW(ErrorAddingNote, ("Could not post a new note:", response)); @@ -141,9 +144,9 @@ void ServerApi06::CloseNote(uint64_t const id) const MYTHROW(ErrorDeletingElement, ("Could not close a note:", response)); } -bool ServerApi06::TestOSMUser(string const & userName) +bool ServerApi06::TestOSMUser(std::string const & userName) { - string const method = "/user/" + UrlEncode(userName); + std::string const method = "/user/" + UrlEncode(userName); return m_auth.DirectRequest(method, false).first == OsmOAuth::HTTP::OK; } @@ -176,8 +179,9 @@ OsmOAuth::Response ServerApi06::GetXmlFeaturesInRect(double minLat, double minLo // Digits After Comma. static constexpr double kDAC = 7; - string const url = "/map?bbox=" + to_string_dac(minLon, kDAC) + ',' + to_string_dac(minLat, kDAC) + ',' + - to_string_dac(maxLon, kDAC) + ',' + to_string_dac(maxLat, kDAC); + std::string const url = "/map?bbox=" + to_string_dac(minLon, kDAC) + ',' + + to_string_dac(minLat, kDAC) + ',' + to_string_dac(maxLon, kDAC) + ',' + + to_string_dac(maxLat, kDAC); return m_auth.DirectRequest(url); } diff --git a/editor/server_api.hpp b/editor/server_api.hpp index d5cfaa5380..1a0a766d4b 100644 --- a/editor/server_api.hpp +++ b/editor/server_api.hpp @@ -8,17 +8,17 @@ #include "base/exception.hpp" -#include "std/map.hpp" -#include "std/string.hpp" +#include <map> +#include <string> namespace osm { struct UserPreferences { uint64_t m_id; - string m_displayName; + std::string m_displayName; time_t m_accountCreated; - string m_imageUrl; + std::string m_imageUrl; uint32_t m_changesets; }; @@ -28,7 +28,7 @@ class ServerApi06 { public: // k= and v= tags used in OSM. - using TKeyValueTags = map<string, string>; + using TKeyValueTags = std::map<std::string, std::string>; DECLARE_EXCEPTION(ServerApi06Exception, RootException); DECLARE_EXCEPTION(NotAuthorized, ServerApi06Exception); @@ -49,7 +49,7 @@ public: /// This function can be used to check if user did not confirm email validation link after registration. /// Throws if there is no connection. /// @returns true if user have registered/signed up even if his email address was not confirmed yet. - bool TestOSMUser(string const & userName); + bool TestOSMUser(std::string const & userName); /// Get OSM user preferences in a convenient struct. /// Throws in case of any error. UserPreferences GetUserPreferences() const; @@ -74,7 +74,7 @@ public: void UpdateChangeSet(uint64_t changesetId, TKeyValueTags const & kvTags) const; void CloseChangeSet(uint64_t changesetId) const; /// @returns id of a created note. - uint64_t CreateNote(ms::LatLon const & ll, string const & message) const; + uint64_t CreateNote(ms::LatLon const & ll, std::string const & message) const; void CloseNote(uint64_t const id) const; /// @returns OSM xml string with features in the bounding box or empty string on error. diff --git a/editor/ui2oh.cpp b/editor/ui2oh.cpp index 2121936501..b55db2e60c 100644 --- a/editor/ui2oh.cpp +++ b/editor/ui2oh.cpp @@ -2,9 +2,9 @@ #include "base/assert.hpp" -#include "std/algorithm.hpp" -#include "std/array.hpp" -#include "std/string.hpp" +#include <algorithm> +#include <set> +#include <string> #include "3party/opening_hours/opening_hours.hpp" @@ -16,7 +16,7 @@ osmoh::Timespan const kTwentyFourHours = {0_h, 24_h}; editor::ui::TOpeningDays MakeOpeningDays(osmoh::Weekdays const & wds) { - set<osmoh::Weekday> openingDays; + std::set<osmoh::Weekday> openingDays; for (auto const & wd : wds.GetWeekdayRanges()) { if (wd.HasSunday()) @@ -50,13 +50,12 @@ void SetUpTimeTable(osmoh::TTimespans spans, editor::ui::TimeTable & tt) for (auto & span : spans) span.ExpandPlus(); - sort(begin(spans), end(spans), [](Timespan const & a, Timespan const & b) - { - auto const start1 = a.GetStart().GetHourMinutes().GetDuration(); - auto const start2 = b.GetStart().GetHourMinutes().GetDuration(); + std::sort(std::begin(spans), std::end(spans), [](Timespan const & a, Timespan const & b) { + auto const start1 = a.GetStart().GetHourMinutes().GetDuration(); + auto const start2 = b.GetStart().GetHourMinutes().GetDuration(); - return start1 < start2; - }); + return start1 < start2; + }); // Take first start and last end as opening time span. tt.SetOpeningTime({spans.front().GetStart(), spans.back().GetEnd()}); @@ -86,9 +85,9 @@ int32_t NextWeekdayNumber(osmoh::Weekday const wd) // Exampls: // su, mo, we -> mo, we, su; // su, mo, fr, sa -> fr, sa, su, mo. -vector<osmoh::Weekday> RemoveInversion(editor::ui::TOpeningDays const & days) +std::vector<osmoh::Weekday> RemoveInversion(editor::ui::TOpeningDays const & days) { - vector<osmoh::Weekday> result(begin(days), end(days)); + std::vector<osmoh::Weekday> result(begin(days), end(days)); if ((NextWeekdayNumber(result.back()) != WeekdayNumber(result.front()) && result.back() != osmoh::Weekday::Sunday) || result.size() < 2) return result; @@ -108,12 +107,12 @@ vector<osmoh::Weekday> RemoveInversion(editor::ui::TOpeningDays const & days) return result; } -using TWeekdays = vector<osmoh::Weekday>; +using TWeekdays = std::vector<osmoh::Weekday>; -vector<TWeekdays> SplitIntoIntervals(editor::ui::TOpeningDays const & days) +std::vector<TWeekdays> SplitIntoIntervals(editor::ui::TOpeningDays const & days) { ASSERT_GREATER(days.size(), 0, ("At least one day must present.")); - vector<TWeekdays> result; + std::vector<TWeekdays> result; auto const & noInversionDays = RemoveInversion(days); ASSERT(!noInversionDays.empty(), ()); @@ -181,7 +180,7 @@ editor::ui::TOpeningDays GetCommonDays(editor::ui::TOpeningDays const & a, editor::ui::TOpeningDays const & b) { editor::ui::TOpeningDays result; - set_intersection(begin(a), end(a), begin(b), end(b), inserter(result, begin(result))); + std::set_intersection(begin(a), end(a), begin(b), end(b), inserter(result, begin(result))); return result; } diff --git a/editor/ui2oh.hpp b/editor/ui2oh.hpp index 1cf223514c..65b774fd77 100644 --- a/editor/ui2oh.hpp +++ b/editor/ui2oh.hpp @@ -2,8 +2,6 @@ #include "editor/opening_hours_ui.hpp" -#include "std/string.hpp" - namespace osmoh { class OpeningHours; diff --git a/editor/user_stats.cpp b/editor/user_stats.cpp index f26b19a220..6153f8224c 100644 --- a/editor/user_stats.cpp +++ b/editor/user_stats.cpp @@ -14,7 +14,7 @@ namespace { -string const kUserStatsUrl = "https://editor-api.maps.me/user?format=xml"; +std::string const kUserStatsUrl = "https://editor-api.maps.me/user?format=xml"; int32_t constexpr kUninitialized = -1; auto constexpr kSettingsUserName = "LastLoggedUser"; @@ -35,10 +35,12 @@ UserStats::UserStats() { } -UserStats::UserStats(time_t const updateTime, uint32_t const rating, - uint32_t const changesCount, string const & levelUpFeat) - : m_changesCount(changesCount), m_rank(rating) - , m_updateTime(updateTime), m_levelUpRequiredFeat(levelUpFeat) +UserStats::UserStats(time_t const updateTime, uint32_t const rating, uint32_t const changesCount, + std::string const & levelUpFeat) + : m_changesCount(changesCount) + , m_rank(rating) + , m_updateTime(updateTime) + , m_levelUpRequiredFeat(levelUpFeat) , m_valid(true) { } @@ -59,7 +61,7 @@ bool UserStats::GetRank(int32_t & rank) const return true; } -bool UserStats::GetLevelUpRequiredFeat(string & levelUpFeat) const +bool UserStats::GetLevelUpRequiredFeat(std::string & levelUpFeat) const { if (m_levelUpRequiredFeat.empty()) return false; @@ -78,13 +80,13 @@ UserStatsLoader::UserStatsLoader() LOG(LINFO, ("User stats info was loaded successfully")); } -bool UserStatsLoader::Update(string const & userName) +bool UserStatsLoader::Update(std::string const & userName) { if (userName.empty()) return false; { - lock_guard<mutex> g(m_mutex); + std::lock_guard<std::mutex> g(m_mutex); m_userName = userName; } @@ -117,7 +119,7 @@ bool UserStatsLoader::Update(string const & userName) auto rank = document.select_node("mmwatch/rank/@value").attribute().as_int(-1); auto levelUpFeat = document.select_node("mmwatch/levelUpFeat/@value").attribute().as_string(); - lock_guard<mutex> g(m_mutex); + std::lock_guard<std::mutex> g(m_mutex); if (m_userName != userName) return false; @@ -128,13 +130,13 @@ bool UserStatsLoader::Update(string const & userName) return true; } -void UserStatsLoader::Update(string const & userName, UpdatePolicy const policy, +void UserStatsLoader::Update(std::string const & userName, UpdatePolicy const policy, TOnUpdateCallback fn) { auto nothingToUpdate = false; if (policy == UpdatePolicy::Lazy) { - lock_guard<mutex> g(m_mutex); + std::lock_guard<std::mutex> g(m_mutex); nothingToUpdate = m_userStats && m_userName == userName && difftime(time(nullptr), m_lastUpdate) < kSecondsInHour; } @@ -152,31 +154,31 @@ void UserStatsLoader::Update(string const & userName, UpdatePolicy const policy, }); } -void UserStatsLoader::Update(string const & userName, TOnUpdateCallback fn) +void UserStatsLoader::Update(std::string const & userName, TOnUpdateCallback fn) { Update(userName, UpdatePolicy::Lazy, fn); } -void UserStatsLoader::DropStats(string const & userName) +void UserStatsLoader::DropStats(std::string const & userName) { - lock_guard<mutex> g(m_mutex); + std::lock_guard<std::mutex> g(m_mutex); if (m_userName != userName) return; m_userStats = {}; DropSettings(); } -UserStats UserStatsLoader::GetStats(string const & userName) const +UserStats UserStatsLoader::GetStats(std::string const & userName) const { - lock_guard<mutex> g(m_mutex); + std::lock_guard<std::mutex> g(m_mutex); if (m_userName == userName) return m_userStats; return {}; } -string UserStatsLoader::GetUserName() const +std::string UserStatsLoader::GetUserName() const { - lock_guard<mutex> g(m_mutex); + std::lock_guard<std::mutex> g(m_mutex); return m_userName; } diff --git a/editor/user_stats.hpp b/editor/user_stats.hpp index 029bfb38d6..70f67b46dc 100644 --- a/editor/user_stats.hpp +++ b/editor/user_stats.hpp @@ -1,10 +1,10 @@ #pragma once -#include "std/cstdint.hpp" -#include "std/ctime.hpp" -#include "std/function.hpp" -#include "std/mutex.hpp" -#include "std/string.hpp" +#include <cstdint> +#include <ctime> +#include <functional> +#include <mutex> +#include <string> namespace editor { @@ -12,8 +12,8 @@ class UserStats { public: UserStats(); - UserStats(time_t const updateTime, uint32_t const rating, - uint32_t const changesCount, string const & levelUpFeat); + UserStats(time_t const updateTime, uint32_t const rating, uint32_t const changesCount, + std::string const & levelUpFeat); bool IsValid() const { return m_valid; } @@ -21,7 +21,7 @@ public: bool GetChangesCount(int32_t & changesCount) const; bool GetRank(int32_t & rank) const; - bool GetLevelUpRequiredFeat(string & levelUpFeat) const; + bool GetLevelUpRequiredFeat(std::string & levelUpFeat) const; time_t GetLastUpdate() const { return m_updateTime; } @@ -30,36 +30,36 @@ private: int32_t m_rank; time_t m_updateTime; /// A very doubtful field representing what a user must commit to have a better rank. - string m_levelUpRequiredFeat; + std::string m_levelUpRequiredFeat; bool m_valid; }; class UserStatsLoader { public: - using TOnUpdateCallback = function<void()>; + using TOnUpdateCallback = std::function<void()>; enum class UpdatePolicy { Lazy, Force }; UserStatsLoader(); /// Synchronously sends request to the server. Updates stats and returns true on success. - bool Update(string const & userName); + bool Update(std::string const & userName); /// Launches the update process if stats are too old or if policy is UpdatePolicy::Force. /// The process posts fn to a gui thread on success. - void Update(string const & userName, UpdatePolicy policy, TOnUpdateCallback fn); + void Update(std::string const & userName, UpdatePolicy policy, TOnUpdateCallback fn); /// Calls Update with UpdatePolicy::Lazy. - void Update(string const & userName, TOnUpdateCallback fn); + void Update(std::string const & userName, TOnUpdateCallback fn); /// Resets internal state and removes records from settings. - void DropStats(string const & userName); + void DropStats(std::string const & userName); /// Atomically returns stats if userName is still actual. - UserStats GetStats(string const & userName) const; + UserStats GetStats(std::string const & userName) const; /// Debug only. - string GetUserName() const; + std::string GetUserName() const; private: /// Not thread-safe, but called only in constructor. @@ -68,10 +68,10 @@ private: void SaveToSettings(); void DropSettings(); - string m_userName; + std::string m_userName; time_t m_lastUpdate; - mutable mutex m_mutex; + mutable std::mutex m_mutex; UserStats m_userStats; }; diff --git a/editor/xml_feature.hpp b/editor/xml_feature.hpp index abbab0388d..84c7244703 100644 --- a/editor/xml_feature.hpp +++ b/editor/xml_feature.hpp @@ -7,9 +7,10 @@ #include "base/string_utils.hpp" -#include "std/ctime.hpp" -#include "std/iostream.hpp" -#include "std/vector.hpp" +#include <cstdint> +#include <ctime> +#include <iostream> +#include <vector> #include "3party/pugixml/src/pugixml.hpp" @@ -49,7 +50,7 @@ public: /// Creates empty node or way. XMLFeature(Type const type); - XMLFeature(string const & xml); + XMLFeature(std::string const & xml); XMLFeature(pugi::xml_document const & xml); XMLFeature(pugi::xml_node const & xml); XMLFeature(XMLFeature const & feature); @@ -57,23 +58,23 @@ public: // Strings comparison does not work if tags order is different but tags are equal. bool operator==(XMLFeature const & other) const; /// @returns nodes, ways and relations from osmXml. Vector can be empty. - static vector<XMLFeature> FromOSM(string const & osmXml); + static std::vector<XMLFeature> FromOSM(std::string const & osmXml); - void Save(ostream & ost) const; - string ToOSMString() const; + void Save(std::ostream & ost) const; + std::string ToOSMString() const; /// Tags from featureWithChanges are applied to this(osm) feature. void ApplyPatch(XMLFeature const & featureWithChanges); Type GetType() const; - string GetTypeString() const; + std::string GetTypeString() const; m2::PointD GetMercatorCenter() const; ms::LatLon GetCenter() const; void SetCenter(ms::LatLon const & ll); void SetCenter(m2::PointD const & mercatorCenter); - vector<m2::PointD> GetGeometry() const; + std::vector<m2::PointD> GetGeometry() const; /// Sets geometry in mercator to match against FeatureType's geometry in mwm /// when megrating to a new mwm build. @@ -100,8 +101,8 @@ public: SetGeometry(begin(geometry), end(geometry)); } - string GetName(string const & lang) const; - string GetName(uint8_t const langCode = StringUtf8Multilang::kDefaultCode) const; + std::string GetName(std::string const & lang) const; + std::string GetName(uint8_t const langCode = StringUtf8Multilang::kDefaultCode) const; template <typename TFunc> void ForEachName(TFunc && func) const @@ -110,7 +111,7 @@ public: auto const tags = GetRootNode().select_nodes("tag"); for (auto const & tag : tags) { - string const & key = tag.node().attribute("k").value(); + std::string const & key = tag.node().attribute("k").value(); if (strings::StartsWith(key, kLocalName)) func(key.substr(kPrefixLen), tag.node().attribute("v").value()); @@ -119,12 +120,12 @@ public: } } - void SetName(string const & name); - void SetName(string const & lang, string const & name); - void SetName(uint8_t const langCode, string const & name); + void SetName(std::string const & name); + void SetName(std::string const & lang, std::string const & name); + void SetName(uint8_t const langCode, std::string const & name); - string GetHouse() const; - void SetHouse(string const & house); + std::string GetHouse() const; + void SetHouse(std::string const & house); /// Our and OSM modification time are equal. time_t GetModificationTime() const; @@ -139,17 +140,17 @@ public: time_t GetUploadTime() const; void SetUploadTime(time_t const time); - string GetUploadStatus() const; - void SetUploadStatus(string const & status); + std::string GetUploadStatus() const; + void SetUploadStatus(std::string const & status); - string GetUploadError() const; - void SetUploadError(string const & error); + std::string GetUploadError() const; + void SetUploadError(std::string const & error); //@} bool HasAnyTags() const; - bool HasTag(string const & key) const; - bool HasAttribute(string const & key) const; - bool HasKey(string const & key) const; + bool HasTag(std::string const & key) const; + bool HasAttribute(std::string const & key) const; + bool HasKey(std::string const & key) const; template <typename TFunc> void ForEachTag(TFunc && func) const @@ -158,16 +159,16 @@ public: func(tag.node().attribute("k").value(), tag.node().attribute("v").value()); } - string GetTagValue(string const & key) const; - void SetTagValue(string const & key, string value); + std::string GetTagValue(std::string const & key) const; + void SetTagValue(std::string const & key, std::string value); - string GetAttribute(string const & key) const; - void SetAttribute(string const & key, string const & value); + std::string GetAttribute(std::string const & key) const; + void SetAttribute(std::string const & key, std::string const & value); bool AttachToParentNode(pugi::xml_node parent) const; - static string TypeToString(Type type); - static Type StringToType(string const & type); + static std::string TypeToString(Type type); + static Type StringToType(std::string const & type); private: pugi::xml_node const GetRootNode() const; @@ -189,6 +190,6 @@ XMLFeature ToXML(osm::EditableMapObject const & object, bool serializeType); /// @Note: only nodes (points) are supported at the moment. bool FromXML(XMLFeature const & xml, osm::EditableMapObject & object); -string DebugPrint(XMLFeature const & feature); -string DebugPrint(XMLFeature::Type const type); +std::string DebugPrint(XMLFeature const & feature); +std::string DebugPrint(XMLFeature::Type const type); } // namespace editor diff --git a/editor/yes_no_unknown.hpp b/editor/yes_no_unknown.hpp index c6df462fd4..61ab40cc07 100644 --- a/editor/yes_no_unknown.hpp +++ b/editor/yes_no_unknown.hpp @@ -1,7 +1,6 @@ #pragma once -#include "std/cstdint.hpp" -#include "std/string.hpp" +#include <string> /// Used to store and edit 3-state OSM information, for example, /// "This place has internet", "does not have", or "it's not specified yet". @@ -15,7 +14,7 @@ enum YesNoUnknown No = 2 }; -inline string DebugPrint(YesNoUnknown value) +inline std::string DebugPrint(YesNoUnknown value) { switch (value) { |