diff options
author | Arsentiy Milchakov <milcars@mapswithme.com> | 2019-03-01 13:51:06 +0300 |
---|---|---|
committer | mpimenov <mpimenov@users.noreply.github.com> | 2019-03-03 00:03:13 +0300 |
commit | f4dafc1f243710e7647f25eadc3caa08d229b22e (patch) | |
tree | 956f50a737e083f258528d242df12601c2cf81e3 /editor | |
parent | ccda0f4bc85354528fed7099ac0bfcbcd01099b5 (diff) |
[editor] get rid of T prefix
Diffstat (limited to 'editor')
-rw-r--r-- | editor/changeset_wrapper.cpp | 6 | ||||
-rw-r--r-- | editor/changeset_wrapper.hpp | 16 | ||||
-rw-r--r-- | editor/editor_config.hpp | 6 | ||||
-rw-r--r-- | editor/editor_tests/editor_config_test.cpp | 8 | ||||
-rw-r--r-- | editor/editor_tests/osm_editor_test.cpp | 4 | ||||
-rw-r--r-- | editor/editor_tests/osm_editor_test.hpp | 10 | ||||
-rw-r--r-- | editor/editor_tests/ui2oh_test.cpp | 35 | ||||
-rw-r--r-- | editor/editor_tests_support/helpers.hpp | 4 | ||||
-rw-r--r-- | editor/opening_hours_ui.cpp | 8 | ||||
-rw-r--r-- | editor/opening_hours_ui.hpp | 58 | ||||
-rw-r--r-- | editor/osm_auth.cpp | 31 | ||||
-rw-r--r-- | editor/osm_auth.hpp | 34 | ||||
-rw-r--r-- | editor/osm_auth_tests/osm_auth_tests.cpp | 2 | ||||
-rw-r--r-- | editor/server_api.cpp | 6 | ||||
-rw-r--r-- | editor/server_api.hpp | 6 | ||||
-rw-r--r-- | editor/ui2oh.cpp | 20 | ||||
-rw-r--r-- | editor/user_stats.cpp | 4 | ||||
-rw-r--r-- | editor/user_stats.hpp | 6 | ||||
-rw-r--r-- | editor/xml_feature.hpp | 16 |
19 files changed, 137 insertions, 143 deletions
diff --git a/editor/changeset_wrapper.cpp b/editor/changeset_wrapper.cpp index e997b04fc6..ae14f40889 100644 --- a/editor/changeset_wrapper.cpp +++ b/editor/changeset_wrapper.cpp @@ -104,8 +104,8 @@ string DebugPrint(xml_document const & doc) namespace osm { -ChangesetWrapper::ChangesetWrapper(TKeySecret const & keySecret, - ServerApi06::TKeyValueTags const & comments) noexcept +ChangesetWrapper::ChangesetWrapper(KeySecret const & keySecret, + ServerApi06::KeyValueTags const & comments) noexcept : m_changesetComments(comments), m_api(OsmOAuth::ServerAuth(keySecret)) { } @@ -252,7 +252,7 @@ void ChangesetWrapper::Delete(XMLFeature node) m_deleted_types[GetTypeForFeature(node)]++; } -string ChangesetWrapper::TypeCountToString(TTypeCount const & typeCount) +string ChangesetWrapper::TypeCountToString(TypeCount const & typeCount) { if (typeCount.empty()) return string(); diff --git a/editor/changeset_wrapper.hpp b/editor/changeset_wrapper.hpp index ca2a76687f..46e502969d 100644 --- a/editor/changeset_wrapper.hpp +++ b/editor/changeset_wrapper.hpp @@ -19,7 +19,7 @@ struct ClientToken; class ChangesetWrapper { - using TTypeCount = std::map<std::string, size_t>; + using TypeCount = std::map<std::string, size_t>; public: DECLARE_EXCEPTION(ChangesetWrapperException, RootException); @@ -32,8 +32,8 @@ public: DECLARE_EXCEPTION(LinearFeaturesAreNotSupportedException, ChangesetWrapperException); DECLARE_EXCEPTION(EmptyFeatureException, ChangesetWrapperException); - ChangesetWrapper(TKeySecret const & keySecret, - ServerApi06::TKeyValueTags const & comments) noexcept; + ChangesetWrapper(KeySecret const & keySecret, + ServerApi06::KeyValueTags const & comments) noexcept; ~ChangesetWrapper(); /// Throws many exceptions from above list, plus including XMLNode's parsing ones. @@ -59,15 +59,15 @@ private: void LoadXmlFromOSM(ms::LatLon const & ll, pugi::xml_document & doc, double radiusInMeters = 1.0); void LoadXmlFromOSM(ms::LatLon const & min, ms::LatLon const & max, pugi::xml_document & doc); - ServerApi06::TKeyValueTags m_changesetComments; + ServerApi06::KeyValueTags m_changesetComments; ServerApi06 m_api; static constexpr uint64_t kInvalidChangesetId = 0; uint64_t m_changesetId = kInvalidChangesetId; - TTypeCount m_modified_types; - TTypeCount m_created_types; - TTypeCount m_deleted_types; - static std::string TypeCountToString(TTypeCount const & typeCount); + TypeCount m_modified_types; + TypeCount m_created_types; + TypeCount m_deleted_types; + static std::string TypeCountToString(TypeCount const & typeCount); std::string GetDescription() const; }; diff --git a/editor/editor_config.hpp b/editor/editor_config.hpp index 1b3ae152e9..9749156892 100644 --- a/editor/editor_config.hpp +++ b/editor/editor_config.hpp @@ -14,19 +14,19 @@ namespace editor struct TypeAggregatedDescription { using EType = feature::Metadata::EType; - using TFeatureFields = std::vector<EType>; + using FeatureFields = std::vector<EType>; bool IsEmpty() const { return IsNameEditable() || IsAddressEditable() || !m_editableFields.empty(); } - TFeatureFields const & GetEditableFields() const { return m_editableFields; } + FeatureFields const & GetEditableFields() const { return m_editableFields; } bool IsNameEditable() const { return m_name; } bool IsAddressEditable() const { return m_address; } - TFeatureFields m_editableFields; + FeatureFields m_editableFields; bool m_name = false; bool m_address = false; diff --git a/editor/editor_tests/editor_config_test.cpp b/editor/editor_tests/editor_config_test.cpp index acfa7d2508..c1f40f2150 100644 --- a/editor/editor_tests/editor_config_test.cpp +++ b/editor/editor_tests/editor_config_test.cpp @@ -10,9 +10,9 @@ using namespace editor; UNIT_TEST(EditorConfig_TypeDescription) { using EType = feature::Metadata::EType; - using TFields = editor::TypeAggregatedDescription::TFeatureFields; + using Fields = editor::TypeAggregatedDescription::FeatureFields; - TFields const poi = { + Fields const poi = { feature::Metadata::FMD_OPEN_HOURS, feature::Metadata::FMD_PHONE_NUMBER, feature::Metadata::FMD_WEBSITE, @@ -35,7 +35,7 @@ UNIT_TEST(EditorConfig_TypeDescription) TEST(config.GetTypeDescription({"amenity-hunting_stand"}, desc), ()); TEST(desc.IsNameEditable(), ()); TEST(!desc.IsAddressEditable(), ()); - TEST_EQUAL(desc.GetEditableFields(), TFields {EType::FMD_HEIGHT}, ()); + TEST_EQUAL(desc.GetEditableFields(), Fields{EType::FMD_HEIGHT}, ()); } { editor::TypeAggregatedDescription desc; @@ -70,7 +70,7 @@ UNIT_TEST(EditorConfig_TypeDescription) editor::TypeAggregatedDescription desc; TEST(config.GetTypeDescription({"tourism-artwork-impresionism-monet"}, desc), ()); TEST(desc.IsNameEditable(), ()); - TEST_EQUAL(desc.GetEditableFields(), TFields {}, ()); + TEST_EQUAL(desc.GetEditableFields(), Fields{}, ()); } // TODO(mgsergio): Test case with priority="high" when there is one on editor.config. } diff --git a/editor/editor_tests/osm_editor_test.cpp b/editor/editor_tests/osm_editor_test.cpp index e01336581a..1f932f1e43 100644 --- a/editor/editor_tests/osm_editor_test.cpp +++ b/editor/editor_tests/osm_editor_test.cpp @@ -107,8 +107,8 @@ private: OptionalSaveStorage * m_storage = new OptionalSaveStorage; }; -template <typename TFn> -void ForEachCafeAtPoint(DataSource & dataSource, m2::PointD const & mercator, TFn && fn) +template <typename Fn> +void ForEachCafeAtPoint(DataSource & dataSource, m2::PointD const & mercator, Fn && fn) { m2::RectD const rect = MercatorBounds::RectByCenterXYAndSizeInMeters(mercator, 0.2 /* rect width */); diff --git a/editor/editor_tests/osm_editor_test.hpp b/editor/editor_tests/osm_editor_test.hpp index 9656d042a0..2a5479d95a 100644 --- a/editor/editor_tests/osm_editor_test.hpp +++ b/editor/editor_tests/osm_editor_test.hpp @@ -49,14 +49,14 @@ public: void SaveTransactionTest(); private: - template <typename TBuildFn> - MwmSet::MwmId ConstructTestMwm(TBuildFn && fn) + template <typename BuildFn> + MwmSet::MwmId ConstructTestMwm(BuildFn && fn) { - return BuildMwm("TestCountry", std::forward<TBuildFn>(fn)); + return BuildMwm("TestCountry", std::forward<BuildFn>(fn)); } - template <typename TBuildFn> - MwmSet::MwmId BuildMwm(std::string const & name, TBuildFn && fn, int64_t version = 0) + template <typename BuildFn> + MwmSet::MwmId BuildMwm(std::string const & name, BuildFn && fn, int64_t version = 0) { m_mwmFiles.emplace_back(GetPlatform().WritableDir(), platform::CountryFile(name), version); auto & file = m_mwmFiles.back(); diff --git a/editor/editor_tests/ui2oh_test.cpp b/editor/editor_tests/ui2oh_test.cpp index 3f5bcfe0ea..c9e09a6bcc 100644 --- a/editor/editor_tests/ui2oh_test.cpp +++ b/editor/editor_tests/ui2oh_test.cpp @@ -214,7 +214,7 @@ UNIT_TEST(OpeningHours2TimeTableSet_off) TimeTableSet tts; TEST(MakeTimeTableSet(oh, tts), ()); - TEST_EQUAL(tts.GetUnhandledDays(), TOpeningDays({osmoh::Weekday::Saturday}), ()); + TEST_EQUAL(tts.GetUnhandledDays(), OpeningDays({osmoh::Weekday::Saturday}), ()); } { OpeningHours oh("Sa; Su; Sa off"); @@ -223,13 +223,11 @@ UNIT_TEST(OpeningHours2TimeTableSet_off) TimeTableSet tts; TEST(MakeTimeTableSet(oh, tts), ()); - TEST_EQUAL(tts.GetUnhandledDays(), - TOpeningDays({osmoh::Weekday::Monday, - osmoh::Weekday::Tuesday, - osmoh::Weekday::Wednesday, - osmoh::Weekday::Thursday, - osmoh::Weekday::Friday, - osmoh::Weekday::Saturday}), ()); + TEST_EQUAL( + tts.GetUnhandledDays(), + OpeningDays({osmoh::Weekday::Monday, osmoh::Weekday::Tuesday, osmoh::Weekday::Wednesday, + osmoh::Weekday::Thursday, osmoh::Weekday::Friday, osmoh::Weekday::Saturday}), + ()); } { OpeningHours oh("Mo-Su 08:00-13:00,14:00-20:00; Sa 10:00-11:00 off"); @@ -241,7 +239,7 @@ UNIT_TEST(OpeningHours2TimeTableSet_off) TEST_EQUAL(tts.Size(), 2, ()); auto const tt = tts.Get(1); - TEST_EQUAL(tt.GetOpeningDays(), TOpeningDays({osmoh::Weekday::Saturday}), ()); + TEST_EQUAL(tt.GetOpeningDays(), OpeningDays({osmoh::Weekday::Saturday}), ()); TEST_EQUAL(tt.GetOpeningTime().GetStart().GetHourMinutes().GetHoursCount(), 8, ()); TEST_EQUAL(tt.GetOpeningTime().GetEnd().GetHourMinutes().GetHoursCount(), 20, ()); TEST_EQUAL(tt.GetExcludeTime()[0].GetStart().GetHourMinutes().GetHoursCount(), 10, ()); @@ -263,7 +261,7 @@ UNIT_TEST(OpeningHours2TimeTableSet_off) TEST_EQUAL(tt.GetOpeningTime().GetStart().GetHourMinutes().GetHoursCount(), 0, ()); TEST_EQUAL(tt.GetOpeningTime().GetEnd().GetHourMinutes().GetHoursCount(), 24, ()); - TEST_EQUAL(tt.GetOpeningDays(), TOpeningDays({osmoh::Weekday::Saturday}), ()); + TEST_EQUAL(tt.GetOpeningDays(), OpeningDays({osmoh::Weekday::Saturday}), ()); TEST_EQUAL(tt.GetExcludeTime()[0].GetStart().GetHourMinutes().GetHoursCount(), 10, ()); TEST_EQUAL(tt.GetExcludeTime()[0].GetEnd().GetHourMinutes().GetHoursCount(), 11, ()); } @@ -275,7 +273,7 @@ UNIT_TEST(OpeningHours2TimeTableSet_off) TEST(MakeTimeTableSet(oh, tts), ()); TEST_EQUAL(tts.Size(), 2, ()); - TEST_EQUAL(tts.GetUnhandledDays(), TOpeningDays({osmoh::Weekday::Tuesday}), ()); + TEST_EQUAL(tts.GetUnhandledDays(), OpeningDays({osmoh::Weekday::Tuesday}), ()); } { OpeningHours oh("Mo-Fr 11:00-17:00; Sa-Su 12:00-16:00; Mo-Fr off"); @@ -286,12 +284,11 @@ UNIT_TEST(OpeningHours2TimeTableSet_off) TEST(MakeTimeTableSet(oh, tts), ()); TEST_EQUAL(tts.Size(), 1, ()); - TEST_EQUAL(tts.GetUnhandledDays(), - TOpeningDays({osmoh::Weekday::Monday, - osmoh::Weekday::Tuesday, - osmoh::Weekday::Wednesday, - osmoh::Weekday::Thursday, - osmoh::Weekday::Friday}), ()); + TEST_EQUAL( + tts.GetUnhandledDays(), + OpeningDays({osmoh::Weekday::Monday, osmoh::Weekday::Tuesday, osmoh::Weekday::Wednesday, + osmoh::Weekday::Thursday, osmoh::Weekday::Friday}), + ()); } { OpeningHours oh("Mo-Fr 11:00-17:00; Sa-Su 12:00-16:00; Mo-Fr 11:00-13:00 off"); @@ -303,7 +300,7 @@ UNIT_TEST(OpeningHours2TimeTableSet_off) TEST_EQUAL(tts.Size(), 2, ()); auto const tt = tts.Get(0); - TEST_EQUAL(tts.GetUnhandledDays(), TOpeningDays(), ()); + TEST_EQUAL(tts.GetUnhandledDays(), OpeningDays(), ()); TEST_EQUAL(tt.GetOpeningTime().GetStart().GetHourMinutes().GetHoursCount(), 11, ()); TEST_EQUAL(tt.GetOpeningTime().GetEnd().GetHourMinutes().GetHoursCount(), 17, ()); @@ -323,7 +320,7 @@ UNIT_TEST(OpeningHours2TimeTableSet_plus) TEST_EQUAL(tts.Size(), 1, ()); auto const tt = tts.Get(0); - TEST_EQUAL(tts.GetUnhandledDays(), TOpeningDays(), ()); + TEST_EQUAL(tts.GetUnhandledDays(), OpeningDays(), ()); TEST_EQUAL(tt.GetOpeningTime().GetStart().GetHourMinutes().GetHoursCount(), 11, ()); TEST_EQUAL(tt.GetOpeningTime().GetEnd().GetHourMinutes().GetHoursCount(), 24, ()); diff --git a/editor/editor_tests_support/helpers.hpp b/editor/editor_tests_support/helpers.hpp index 67686e90bb..7b82ad4b84 100644 --- a/editor/editor_tests_support/helpers.hpp +++ b/editor/editor_tests_support/helpers.hpp @@ -15,8 +15,8 @@ namespace tests_support void SetUpEditorForTesting(std::unique_ptr<osm::Editor::Delegate> delegate); void TearDownEditorForTesting(); -template <typename TFn> -void EditFeature(FeatureType & ft, TFn && fn) +template <typename Fn> +void EditFeature(FeatureType & ft, Fn && fn) { auto & editor = osm::Editor::Instance(); diff --git a/editor/opening_hours_ui.cpp b/editor/opening_hours_ui.cpp index f39ae494f0..8c6c4bef55 100644 --- a/editor/opening_hours_ui.cpp +++ b/editor/opening_hours_ui.cpp @@ -144,7 +144,7 @@ TimeTable TimeTable::GetPredefinedTimeTable() return tt; } -bool TimeTable::SetOpeningDays(TOpeningDays const & days) +bool TimeTable::SetOpeningDays(OpeningDays const & days) { if (days.empty()) return false; @@ -292,9 +292,9 @@ TimeTableSet::TimeTableSet() m_table.push_back(TimeTable::GetPredefinedTimeTable()); } -TOpeningDays TimeTableSet::GetUnhandledDays() const +OpeningDays TimeTableSet::GetUnhandledDays() const { - TOpeningDays days = { + OpeningDays days = { osmoh::Weekday::Sunday, osmoh::Weekday::Monday, osmoh::Weekday::Tuesday, @@ -381,7 +381,7 @@ 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; + OpeningDays 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))); diff --git a/editor/opening_hours_ui.hpp b/editor/opening_hours_ui.hpp index e62de24ffd..8025ff8405 100644 --- a/editor/opening_hours_ui.hpp +++ b/editor/opening_hours_ui.hpp @@ -9,7 +9,7 @@ namespace editor { namespace ui { -using TOpeningDays = std::set<osmoh::Weekday>; +using OpeningDays = std::set<osmoh::Weekday>; class TimeTable { @@ -20,8 +20,8 @@ public: bool IsTwentyFourHours() const { return m_isTwentyFourHours; } void SetTwentyFourHours(bool const on) { m_isTwentyFourHours = on; } - TOpeningDays const & GetOpeningDays() const { return m_weekdays; } - bool SetOpeningDays(TOpeningDays const & days); + OpeningDays const & GetOpeningDays() const { return m_weekdays; } + bool SetOpeningDays(OpeningDays const & days); void AddWorkingDay(osmoh::Weekday const wd); bool RemoveWorkingDay(osmoh::Weekday const wd); @@ -44,46 +44,42 @@ private: TimeTable() = default; bool m_isTwentyFourHours; - TOpeningDays m_weekdays; + OpeningDays m_weekdays; osmoh::Timespan m_openingTime; osmoh::TTimespans m_excludeTime; }; -template <typename TTimeTableSet> -class TimeTableProxyBase : public TimeTable +class TimeTableProxy; + +class TimeTableSet { + using TimeTableSetImpl = std::vector<TimeTable>; + public: - TimeTableProxyBase(TTimeTableSet & tts, size_t const index, TimeTable const & tt): - TimeTable(tt), - m_index(index), - m_tts(tts) + class Proxy : public TimeTable { - } - - bool Commit() { return m_tts.Replace(*this, m_index); } // Slice base class on copy. - -private: - size_t const m_index; - TTimeTableSet & m_tts; -}; + public: + Proxy(TimeTableSet & tts, size_t const index, TimeTable const & tt) + : TimeTable(tt), m_index(index), m_tts(tts) + { + } -class TimeTableSet; -using TTimeTableProxy = TimeTableProxyBase<TimeTableSet>; + bool Commit() { return m_tts.Replace(*this, m_index); } // Slice base class on copy. -class TimeTableSet -{ - using TTimeTableSetImpl = std::vector<TimeTable>; + private: + size_t const m_index; + TimeTableSet & m_tts; + }; -public: TimeTableSet(); - TOpeningDays GetUnhandledDays() const; + OpeningDays GetUnhandledDays() const; TimeTable GetComplementTimeTable() const; - TTimeTableProxy Get(size_t const index) { return TTimeTableProxy(*this, index, m_table[index]); } - TTimeTableProxy Front() { return Get(0); } - TTimeTableProxy Back() { return Get(Size() - 1); } + Proxy Get(size_t const index) { return Proxy(*this, index, m_table[index]); } + Proxy Front() { return Get(0); } + Proxy Back() { return Get(Size() - 1); } size_t Size() const { return m_table.size(); } bool Empty() const { return m_table.empty(); } @@ -95,13 +91,13 @@ public: bool Replace(TimeTable const & tt, size_t const index); - TTimeTableSetImpl::const_iterator begin() const { return m_table.begin(); } - TTimeTableSetImpl::const_iterator end() const { return m_table.end(); } + TimeTableSetImpl::const_iterator begin() const { return m_table.begin(); } + TimeTableSetImpl::const_iterator end() const { return m_table.end(); } private: static bool UpdateByIndex(TimeTableSet & ttSet, size_t const index); - TTimeTableSetImpl m_table; + TimeTableSetImpl m_table; }; } // namespace ui } // namespace editor diff --git a/editor/osm_auth.cpp b/editor/osm_auth.cpp index 6326077d45..a883347353 100644 --- a/editor/osm_auth.cpp +++ b/editor/osm_auth.cpp @@ -58,12 +58,12 @@ string BuildPostRequest(map<string, string> const & params) } // namespace // static -bool OsmOAuth::IsValid(TKeySecret const & ks) noexcept +bool OsmOAuth::IsValid(KeySecret const & ks) noexcept { return !(ks.first.empty() || ks.second.empty()); } // static -bool OsmOAuth::IsValid(TUrlRequestToken const & urt) noexcept +bool OsmOAuth::IsValid(UrlRequestToken const & urt) noexcept { return !(urt.first.empty() || urt.second.first.empty() || urt.second.second.empty()); } @@ -83,7 +83,7 @@ OsmOAuth OsmOAuth::ServerAuth() noexcept #endif } // static -OsmOAuth OsmOAuth::ServerAuth(TKeySecret const & userKeySecret) noexcept +OsmOAuth OsmOAuth::ServerAuth(KeySecret const & userKeySecret) noexcept { OsmOAuth auth = ServerAuth(); auth.SetKeySecret(userKeySecret); @@ -113,9 +113,9 @@ OsmOAuth OsmOAuth::ProductionServerAuth() noexcept return OsmOAuth(OSM_CONSUMER_KEY, OSM_CONSUMER_SECRET, kOsmMainSiteURL, kOsmApiURL); } -void OsmOAuth::SetKeySecret(TKeySecret const & keySecret) noexcept { m_tokenKeySecret = keySecret; } +void OsmOAuth::SetKeySecret(KeySecret const & keySecret) noexcept { m_tokenKeySecret = keySecret; } -TKeySecret const & OsmOAuth::GetKeySecret() const noexcept { return m_tokenKeySecret; } +KeySecret const & OsmOAuth::GetKeySecret() const noexcept { return m_tokenKeySecret; } bool OsmOAuth::IsAuthorized() const noexcept{ return IsValid(m_tokenKeySecret); } @@ -239,7 +239,7 @@ string OsmOAuth::SendAuthRequest(string const & requestTokenKey, SessionID const return callbackURL.substr(pos + vKey.length(), end == string::npos ? end : end - pos - vKey.length()); } -TRequestToken OsmOAuth::FetchRequestToken() const +RequestToken OsmOAuth::FetchRequestToken() const { OAuth::Consumer const consumer(m_consumerKeySecret.first, m_consumerKeySecret.second); OAuth::Client oauth(&consumer); @@ -258,7 +258,8 @@ TRequestToken OsmOAuth::FetchRequestToken() const return { reqToken.key(), reqToken.secret() }; } -TKeySecret OsmOAuth::FinishAuthorization(TRequestToken const & requestToken, string const & verifier) const +KeySecret OsmOAuth::FinishAuthorization(RequestToken const & requestToken, + string const & verifier) const { OAuth::Consumer const consumer(m_consumerKeySecret.first, m_consumerKeySecret.second); OAuth::Token const reqToken(requestToken.first, requestToken.second, verifier); @@ -280,10 +281,10 @@ TKeySecret OsmOAuth::FinishAuthorization(TRequestToken const & requestToken, str } // Given a web session id, fetches an OAuth access token. -TKeySecret OsmOAuth::FetchAccessToken(SessionID const & sid) const +KeySecret OsmOAuth::FetchAccessToken(SessionID const & sid) const { // Aquire a request token. - TRequestToken const requestToken = FetchRequestToken(); + RequestToken const requestToken = FetchRequestToken(); // Faking a button press for access rights. string const pin = SendAuthRequest(requestToken.first, sid); @@ -320,18 +321,18 @@ bool OsmOAuth::AuthorizeGoogle(string const & googleToken) return true; } -OsmOAuth::TUrlRequestToken OsmOAuth::GetFacebookOAuthURL() const +OsmOAuth::UrlRequestToken OsmOAuth::GetFacebookOAuthURL() const { - TRequestToken const requestToken = FetchRequestToken(); + RequestToken const requestToken = FetchRequestToken(); string const url = m_baseUrl + kFacebookOAuthPart + requestToken.first; - return TUrlRequestToken(url, requestToken); + return UrlRequestToken(url, requestToken); } -OsmOAuth::TUrlRequestToken OsmOAuth::GetGoogleOAuthURL() const +OsmOAuth::UrlRequestToken OsmOAuth::GetGoogleOAuthURL() const { - TRequestToken const requestToken = FetchRequestToken(); + RequestToken const requestToken = FetchRequestToken(); string const url = m_baseUrl + kGoogleOAuthPart + requestToken.first; - return TUrlRequestToken(url, requestToken); + return UrlRequestToken(url, requestToken); } bool OsmOAuth::ResetPassword(string const & email) const diff --git a/editor/osm_auth.hpp b/editor/osm_auth.hpp index 7bc872085f..903a191963 100644 --- a/editor/osm_auth.hpp +++ b/editor/osm_auth.hpp @@ -7,8 +7,8 @@ namespace osm { -using TKeySecret = std::pair<std::string /*key*/, std::string /*secret*/>; -using TRequestToken = TKeySecret; +using KeySecret = std::pair<std::string /*key*/, std::string /*secret*/>; +using RequestToken = KeySecret; /// All methods that interact with the OSM server are blocking and not asynchronous. class OsmOAuth @@ -35,7 +35,7 @@ public: /// A pair of <http error code, response contents>. using Response = std::pair<int, std::string>; /// A pair of <url, key-secret>. - using TUrlRequestToken = std::pair<std::string, TRequestToken>; + using UrlRequestToken = std::pair<std::string, RequestToken>; DECLARE_EXCEPTION(OsmOAuthException, RootException); DECLARE_EXCEPTION(NetworkError, OsmOAuthException); @@ -53,8 +53,8 @@ public: DECLARE_EXCEPTION(FinishAuthorizationServerError, OsmOAuthException); DECLARE_EXCEPTION(ResetPasswordServerError, OsmOAuthException); - static bool IsValid(TKeySecret const & ks) noexcept; - static bool IsValid(TUrlRequestToken const & urt) noexcept; + static bool IsValid(KeySecret const & ks) noexcept; + static bool IsValid(UrlRequestToken const & urt) noexcept; /// The constructor. Simply stores a lot of strings in fields. OsmOAuth(std::string const & consumerKey, std::string const & consumerSecret, @@ -62,7 +62,7 @@ public: /// Should be used everywhere in production code instead of servers below. static OsmOAuth ServerAuth() noexcept; - static OsmOAuth ServerAuth(TKeySecret const & userKeySecret) noexcept; + static OsmOAuth ServerAuth(KeySecret const & userKeySecret) noexcept; /// Ilya Zverev's test server. static OsmOAuth IZServerAuth() noexcept; @@ -71,8 +71,8 @@ public: /// api.openstreetmap.org static OsmOAuth ProductionServerAuth() noexcept; - void SetKeySecret(TKeySecret const & keySecret) noexcept; - TKeySecret const & GetKeySecret() const noexcept; + void SetKeySecret(KeySecret const & keySecret) noexcept; + KeySecret const & GetKeySecret() const noexcept; bool IsAuthorized() const noexcept; /// @returns false if login and/or password are invalid. @@ -94,11 +94,11 @@ public: /// @name Methods for WebView-based authentication. //@{ - TUrlRequestToken GetFacebookOAuthURL() const; - TUrlRequestToken GetGoogleOAuthURL() const; - TKeySecret FinishAuthorization(TRequestToken const & requestToken, - std::string const & verifier) const; - //AuthResult FinishAuthorization(TKeySecret const & requestToken, string const & verifier); + UrlRequestToken GetFacebookOAuthURL() const; + UrlRequestToken GetGoogleOAuthURL() const; + KeySecret FinishAuthorization(RequestToken const & requestToken, + std::string const & verifier) const; + // AuthResult FinishAuthorization(KeySecret const & requestToken, string const & verifier); std::string GetRegistrationURL() const noexcept { return m_baseUrl + "/user/new"; } std::string GetResetPasswordURL() const noexcept { return m_baseUrl + "/user/forgot-password"; } //@} @@ -111,11 +111,11 @@ private: }; /// Key and secret for application. - TKeySecret const m_consumerKeySecret; + KeySecret const m_consumerKeySecret; std::string const m_baseUrl; std::string const m_apiUrl; /// Key and secret to sign every OAuth request. - TKeySecret m_tokenKeySecret; + KeySecret m_tokenKeySecret; SessionID FetchSessionId(std::string const & subUrl = "/login", std::string const & cookies = "") const; @@ -132,8 +132,8 @@ private: /// @returns non-empty string with oauth_verifier value. 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; + RequestToken FetchRequestToken() const; + KeySecret FetchAccessToken(SessionID const & sid) const; //AuthResult FetchAccessToken(SessionID const & sid); }; diff --git a/editor/osm_auth_tests/osm_auth_tests.cpp b/editor/osm_auth_tests/osm_auth_tests.cpp index 82eaa74dee..2336e87546 100644 --- a/editor/osm_auth_tests/osm_auth_tests.cpp +++ b/editor/osm_auth_tests/osm_auth_tests.cpp @@ -5,7 +5,7 @@ #include <string> using osm::OsmOAuth; -using osm::TKeySecret; +using osm::KeySecret; namespace { diff --git a/editor/server_api.cpp b/editor/server_api.cpp index d0c4397a2b..49d93700be 100644 --- a/editor/server_api.cpp +++ b/editor/server_api.cpp @@ -16,7 +16,7 @@ namespace { -std::string KeyValueTagsToXML(osm::ServerApi06::TKeyValueTags const & kvTags) +std::string KeyValueTagsToXML(osm::ServerApi06::KeyValueTags const & kvTags) { std::ostringstream stream; stream << "<osm>\n" @@ -37,7 +37,7 @@ ServerApi06::ServerApi06(OsmOAuth const & auth) { } -uint64_t ServerApi06::CreateChangeSet(TKeyValueTags const & kvTags) const +uint64_t ServerApi06::CreateChangeSet(KeyValueTags const & kvTags) const { if (!m_auth.IsAuthorized()) MYTHROW(NotAuthorized, ("Not authorized.")); @@ -105,7 +105,7 @@ void ServerApi06::DeleteElement(editor::XMLFeature const & element) const MYTHROW(ErrorDeletingElement, ("Could not delete an element:", response)); } -void ServerApi06::UpdateChangeSet(uint64_t changesetId, TKeyValueTags const & kvTags) const +void ServerApi06::UpdateChangeSet(uint64_t changesetId, KeyValueTags const & kvTags) const { OsmOAuth::Response const response = m_auth.Request("/changeset/" + strings::to_string(changesetId), "PUT", KeyValueTagsToXML(kvTags)); if (response.first != OsmOAuth::HTTP::OK) diff --git a/editor/server_api.hpp b/editor/server_api.hpp index 1a0a766d4b..c0a26a69d3 100644 --- a/editor/server_api.hpp +++ b/editor/server_api.hpp @@ -28,7 +28,7 @@ class ServerApi06 { public: // k= and v= tags used in OSM. - using TKeyValueTags = std::map<std::string, std::string>; + using KeyValueTags = std::map<std::string, std::string>; DECLARE_EXCEPTION(ServerApi06Exception, RootException); DECLARE_EXCEPTION(NotAuthorized, ServerApi06Exception); @@ -55,7 +55,7 @@ public: UserPreferences GetUserPreferences() const; /// Please use at least created_by=* and comment=* tags. /// @returns created changeset ID. - uint64_t CreateChangeSet(TKeyValueTags const & kvTags) const; + uint64_t CreateChangeSet(KeyValueTags const & kvTags) const; /// <node>, <way> or <relation> are supported. /// Only one element per call is supported. /// @returns id of created element. @@ -71,7 +71,7 @@ public: /// @param element should already have all attributes set, including "id", "version", "changeset". /// @returns true if element was successfully deleted (or was already deleted). void DeleteElement(editor::XMLFeature const & element) const; - void UpdateChangeSet(uint64_t changesetId, TKeyValueTags const & kvTags) const; + void UpdateChangeSet(uint64_t changesetId, KeyValueTags const & kvTags) const; void CloseChangeSet(uint64_t changesetId) const; /// @returns id of a created note. uint64_t CreateNote(ms::LatLon const & ll, std::string const & message) const; diff --git a/editor/ui2oh.cpp b/editor/ui2oh.cpp index b55db2e60c..dfe4f93ef8 100644 --- a/editor/ui2oh.cpp +++ b/editor/ui2oh.cpp @@ -14,7 +14,7 @@ using osmoh::operator ""_h; osmoh::Timespan const kTwentyFourHours = {0_h, 24_h}; -editor::ui::TOpeningDays MakeOpeningDays(osmoh::Weekdays const & wds) +editor::ui::OpeningDays MakeOpeningDays(osmoh::Weekdays const & wds) { std::set<osmoh::Weekday> openingDays; for (auto const & wd : wds.GetWeekdayRanges()) @@ -85,7 +85,7 @@ int32_t NextWeekdayNumber(osmoh::Weekday const wd) // Exampls: // su, mo, we -> mo, we, su; // su, mo, fr, sa -> fr, sa, su, mo. -std::vector<osmoh::Weekday> RemoveInversion(editor::ui::TOpeningDays const & days) +std::vector<osmoh::Weekday> RemoveInversion(editor::ui::OpeningDays const & days) { std::vector<osmoh::Weekday> result(begin(days), end(days)); if ((NextWeekdayNumber(result.back()) != WeekdayNumber(result.front()) && @@ -107,12 +107,12 @@ std::vector<osmoh::Weekday> RemoveInversion(editor::ui::TOpeningDays const & day return result; } -using TWeekdays = std::vector<osmoh::Weekday>; +using Weekdays = std::vector<osmoh::Weekday>; -std::vector<TWeekdays> SplitIntoIntervals(editor::ui::TOpeningDays const & days) +std::vector<Weekdays> SplitIntoIntervals(editor::ui::OpeningDays const & days) { ASSERT_GREATER(days.size(), 0, ("At least one day must present.")); - std::vector<TWeekdays> result; + std::vector<Weekdays> result; auto const & noInversionDays = RemoveInversion(days); ASSERT(!noInversionDays.empty(), ()); @@ -166,7 +166,7 @@ osmoh::TTimespans MakeTimespans(editor::ui::TimeTable const & tt) return spans; } -editor::ui::TOpeningDays const kWholeWeek = { +editor::ui::OpeningDays const kWholeWeek = { osmoh::Weekday::Monday, osmoh::Weekday::Tuesday, osmoh::Weekday::Wednesday, @@ -176,10 +176,10 @@ editor::ui::TOpeningDays const kWholeWeek = { osmoh::Weekday::Sunday }; -editor::ui::TOpeningDays GetCommonDays(editor::ui::TOpeningDays const & a, - editor::ui::TOpeningDays const & b) +editor::ui::OpeningDays GetCommonDays(editor::ui::OpeningDays const & a, + editor::ui::OpeningDays const & b) { - editor::ui::TOpeningDays result; + editor::ui::OpeningDays result; std::set_intersection(begin(a), end(a), begin(b), end(b), inserter(result, begin(result))); return result; } @@ -205,7 +205,7 @@ bool ExcludeRulePart(osmoh::RuleSequence const & rulePart, editor::ui::TimeTable auto const commonDays = GetCommonDays(ttOpeningDays, MakeOpeningDays(rulePart.GetWeekdays())); - auto const removeCommonDays = [&commonDays](editor::ui::TTimeTableProxy & tt) + auto const removeCommonDays = [&commonDays](editor::ui::TimeTableSet::Proxy & tt) { for (auto const day : commonDays) VERIFY(tt.RemoveWorkingDay(day), ("Can't remove working day")); diff --git a/editor/user_stats.cpp b/editor/user_stats.cpp index 6153f8224c..2a102dc4a4 100644 --- a/editor/user_stats.cpp +++ b/editor/user_stats.cpp @@ -131,7 +131,7 @@ bool UserStatsLoader::Update(std::string const & userName) } void UserStatsLoader::Update(std::string const & userName, UpdatePolicy const policy, - TOnUpdateCallback fn) + OnUpdateCallback fn) { auto nothingToUpdate = false; if (policy == UpdatePolicy::Lazy) @@ -154,7 +154,7 @@ void UserStatsLoader::Update(std::string const & userName, UpdatePolicy const po }); } -void UserStatsLoader::Update(std::string const & userName, TOnUpdateCallback fn) +void UserStatsLoader::Update(std::string const & userName, OnUpdateCallback fn) { Update(userName, UpdatePolicy::Lazy, fn); } diff --git a/editor/user_stats.hpp b/editor/user_stats.hpp index 70f67b46dc..20b52df0cb 100644 --- a/editor/user_stats.hpp +++ b/editor/user_stats.hpp @@ -37,7 +37,7 @@ private: class UserStatsLoader { public: - using TOnUpdateCallback = std::function<void()>; + using OnUpdateCallback = std::function<void()>; enum class UpdatePolicy { Lazy, Force }; @@ -48,9 +48,9 @@ public: /// 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(std::string const & userName, UpdatePolicy policy, TOnUpdateCallback fn); + void Update(std::string const & userName, UpdatePolicy policy, OnUpdateCallback fn); /// Calls Update with UpdatePolicy::Lazy. - void Update(std::string const & userName, TOnUpdateCallback fn); + void Update(std::string const & userName, OnUpdateCallback fn); /// Resets internal state and removes records from settings. void DropStats(std::string const & userName); diff --git a/editor/xml_feature.hpp b/editor/xml_feature.hpp index 84c7244703..ce8e565464 100644 --- a/editor/xml_feature.hpp +++ b/editor/xml_feature.hpp @@ -81,8 +81,8 @@ public: /// Geometry points are now stored in <nd x="..." y="..." /> nodes like in osm <way>. /// But they are not the same as osm's. I.e. osm's one stores reference to a <node> /// with it's own data and lat, lon. Here we store only cooridanes in mercator. - template <typename TIterator> - void SetGeometry(TIterator begin, TIterator end) + template <typename Iterator> + void SetGeometry(Iterator begin, Iterator end) { ASSERT_NOT_EQUAL(GetType(), Type::Unknown, ()); ASSERT_NOT_EQUAL(GetType(), Type::Node, ()); @@ -95,8 +95,8 @@ public: } } - template <typename TCollection> - void SetGeometry(TCollection const & geometry) + template <typename Collection> + void SetGeometry(Collection const & geometry) { SetGeometry(begin(geometry), end(geometry)); } @@ -104,8 +104,8 @@ public: 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 + template <typename Fn> + void ForEachName(Fn && func) const { static auto const kPrefixLen = strlen(kLocalName); auto const tags = GetRootNode().select_nodes("tag"); @@ -152,8 +152,8 @@ public: bool HasAttribute(std::string const & key) const; bool HasKey(std::string const & key) const; - template <typename TFunc> - void ForEachTag(TFunc && func) const + template <typename Fn> + void ForEachTag(Fn && func) const { for (auto const & tag : GetRootNode().select_nodes("tag")) func(tag.node().attribute("k").value(), tag.node().attribute("v").value()); |