Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/ugc
diff options
context:
space:
mode:
authorMaxim Pimenov <m@maps.me>2018-09-14 21:08:09 +0300
committerVlad Mihaylenko <vxmihaylenko@gmail.com>2018-09-18 14:46:56 +0300
commit412387c84eefba2ec4c267ee2748bf78f03ce327 (patch)
tree8d79b6b480fb91a5458a21aec10ac689de54db9f /ugc
parentbef147b46fb8fd5160fc8e3b13f3548906ae5ef7 (diff)
[base] Replaced the namespace my with base.
Diffstat (limited to 'ugc')
-rw-r--r--ugc/index_migration/utility.cpp2
-rw-r--r--ugc/serdes_json.hpp18
-rw-r--r--ugc/storage.cpp38
-rw-r--r--ugc/types.hpp2
-rw-r--r--ugc/ugc_tests/migration/generate_migration_files.cpp12
-rw-r--r--ugc/ugc_tests/storage_tests.cpp30
6 files changed, 51 insertions, 51 deletions
diff --git a/ugc/index_migration/utility.cpp b/ugc/index_migration/utility.cpp
index 0275c0a38a..2f8806c44b 100644
--- a/ugc/index_migration/utility.cpp
+++ b/ugc/index_migration/utility.cpp
@@ -26,7 +26,7 @@ using MigrationTables = unordered_map<int64_t, MigrationTable>;
bool GetMigrationTable(int64_t tableVersion, MigrationTable & t)
{
- auto const fileName = my::JoinPath(kMigrationDirName, to_string(tableVersion) + kBinExt);
+ auto const fileName = base::JoinPath(kMigrationDirName, to_string(tableVersion) + kBinExt);
try
{
auto reader = GetPlatform().GetReader(fileName);
diff --git a/ugc/serdes_json.hpp b/ugc/serdes_json.hpp
index 5986343bc1..80458046af 100644
--- a/ugc/serdes_json.hpp
+++ b/ugc/serdes_json.hpp
@@ -58,7 +58,7 @@ public:
template <typename T>
void operator()(vector<T> const & vs, char const * name = nullptr)
{
- NewScopeWith(my::NewJSONArray(), name, [this, &vs] {
+ NewScopeWith(base::NewJSONArray(), name, [this, &vs] {
for (auto const & v : vs)
(*this)(v);
});
@@ -67,7 +67,7 @@ public:
template <typename R, EnableIfNotEnum<R> * = nullptr>
void operator()(R const & r, char const * name = nullptr)
{
- NewScopeWith(my::NewJSONObject(), name, [this, &r] { r.Visit(*this); });
+ NewScopeWith(base::NewJSONObject(), name, [this, &r] { r.Visit(*this); });
}
template <typename T, EnableIfEnum<T> * = nullptr>
@@ -116,9 +116,9 @@ public:
private:
template <typename Fn>
- void NewScopeWith(my::JSONPtr json_object, char const * name, Fn && fn)
+ void NewScopeWith(base::JSONPtr json_object, char const * name, Fn && fn)
{
- my::JSONPtr safe_json = std::move(m_json);
+ base::JSONPtr safe_json = std::move(m_json);
m_json = std::move(json_object);
fn();
@@ -132,7 +132,7 @@ private:
m_json = std::move(safe_json);
}
- my::JSONPtr m_json = nullptr;
+ base::JSONPtr m_json = nullptr;
Sink & m_sink;
};
@@ -189,7 +189,7 @@ public:
json_t * context = SaveContext(name);
if (!json_is_array(m_json))
- MYTHROW(my::Json::Exception, ("The field", name, "must contain a json array."));
+ MYTHROW(base::Json::Exception, ("The field", name, "must contain a json array."));
vs.resize(json_array_size(m_json));
for (size_t index = 0; index < vs.size(); ++index)
@@ -257,7 +257,7 @@ public:
template <typename Optional>
void operator()(Optional & opt, Optional const & defaultValue, char const * name = nullptr)
{
- auto json = my::GetJSONOptionalField(m_json, name);
+ auto json = base::GetJSONOptionalField(m_json, name);
if (!json)
{
opt = defaultValue;
@@ -272,7 +272,7 @@ private:
{
json_t * context = m_json;
if (name)
- m_json = my::GetJSONObligatoryField(context, name);
+ m_json = base::GetJSONObligatoryField(context, name);
return context;
}
@@ -282,7 +282,7 @@ private:
m_json = context;
}
- my::Json m_jsonObject;
+ base::Json m_jsonObject;
json_t * m_json = nullptr;
};
} // namespace ugc
diff --git a/ugc/storage.cpp b/ugc/storage.cpp
index d475b54620..41f3a477a0 100644
--- a/ugc/storage.cpp
+++ b/ugc/storage.cpp
@@ -38,9 +38,9 @@ string const kTmpFileExtension = ".tmp";
using Sink = MemWriter<string>;
-string GetUGCFilePath() { return my::JoinPath(GetPlatform().SettingsDir(), kUGCUpdateFileName); }
+string GetUGCFilePath() { return base::JoinPath(GetPlatform().SettingsDir(), kUGCUpdateFileName); }
-string GetIndexFilePath() { return my::JoinPath(GetPlatform().SettingsDir(), kIndexFileName); }
+string GetIndexFilePath() { return base::JoinPath(GetPlatform().SettingsDir(), kIndexFileName); }
bool GetUGCFileSize(uint64_t & size)
{
@@ -71,7 +71,7 @@ string SerializeIndexes(ugc::UpdateIndexes const & indexes)
if (indexes.empty())
return string();
- auto array = my::NewJSONArray();
+ auto array = base::NewJSONArray();
for (auto const & index : indexes)
{
string data;
@@ -81,7 +81,7 @@ string SerializeIndexes(ugc::UpdateIndexes const & indexes)
ser(index);
}
- my::Json node(data);
+ base::Json node(data);
json_array_append_new(array.get(), node.get_deep_copy());
}
@@ -255,15 +255,15 @@ void Storage::Migrate(string const & indexFilePath)
// Backup existing files
auto const v0IndexFilePath = indexFilePath + suffix;
auto const v0UGCFilePath = ugcFilePath + suffix;
- if (!my::CopyFileX(indexFilePath, v0IndexFilePath))
+ if (!base::CopyFileX(indexFilePath, v0IndexFilePath))
{
LOG(LERROR, ("Can't backup UGC index file"));
return;
}
- if (!my::CopyFileX(ugcFilePath, v0UGCFilePath))
+ if (!base::CopyFileX(ugcFilePath, v0UGCFilePath))
{
- my::DeleteFileX(v0IndexFilePath);
+ base::DeleteFileX(v0IndexFilePath);
LOG(LERROR, ("Can't backup UGC update file"));
return;
}
@@ -277,10 +277,10 @@ void Storage::Migrate(string const & indexFilePath)
case migration::Result::Success:
if (!SaveIndex(indexFilePath))
{
- my::DeleteFileX(indexFilePath);
- my::DeleteFileX(ugcFilePath);
- my::RenameFileX(v0UGCFilePath, ugcFilePath);
- my::RenameFileX(v0IndexFilePath, indexFilePath);
+ base::DeleteFileX(indexFilePath);
+ base::DeleteFileX(ugcFilePath);
+ base::RenameFileX(v0UGCFilePath, ugcFilePath);
+ base::RenameFileX(v0IndexFilePath, indexFilePath);
m_indexes.clear();
LOG(LERROR, ("Can't save UGC index after migration"));
return;
@@ -306,7 +306,7 @@ bool Storage::SaveIndex(std::string const & pathToTargetFile /* = "" */) const
catch (FileWriter::Exception const & exception)
{
LOG(LERROR, ("Exception while writing file:", indexFilePath, "reason:", exception.what()));
- my::DeleteFileX(indexFilePath);
+ base::DeleteFileX(indexFilePath);
return false;
}
@@ -360,8 +360,8 @@ void Storage::DefragmentationImpl(bool force)
}
base::EraseIf(m_indexes, [](UpdateIndex const & i) -> bool { return i.m_deleted; });
- CHECK(my::DeleteFileX(ugcFilePath), ());
- CHECK(my::RenameFileX(tmpUGCFilePath, ugcFilePath), ());
+ CHECK(base::DeleteFileX(ugcFilePath), ());
+ CHECK(base::RenameFileX(tmpUGCFilePath, ugcFilePath), ());
m_numberOfDeleted = 0;
}
@@ -371,7 +371,7 @@ string Storage::GetUGCToSend() const
if (m_indexes.empty())
return string();
- auto array = my::NewJSONArray();
+ auto array = base::NewJSONArray();
auto const indexesSize = m_indexes.size();
auto const ugcFilePath = GetUGCFilePath();
FileReader r(ugcFilePath);
@@ -408,8 +408,8 @@ string Storage::GetUGCToSend() const
ser(update);
}
- my::Json serializedUgc(data);
- auto embeddedNode = my::NewJSONObject();
+ base::Json serializedUgc(data);
+ auto embeddedNode = base::NewJSONObject();
ToJSONObject(*embeddedNode.get(), "data_version", index.m_dataVersion);
ToJSONObject(*embeddedNode.get(), "mwm_name", index.m_mwmName);
ToJSONObject(*embeddedNode.get(), "feature_id", index.m_featureId);
@@ -423,7 +423,7 @@ string Storage::GetUGCToSend() const
if (json_array_size(array.get()) == 0)
return string();
- auto reviewsNode = my::NewJSONObject();
+ auto reviewsNode = base::NewJSONObject();
ToJSONObject(*reviewsNode.get(), "reviews", *array.release());
unique_ptr<char, JSONFreeDeleter> buffer(json_dumps(reviewsNode.get(), JSON_COMPACT | JSON_ENSURE_ASCII));
@@ -461,7 +461,7 @@ void Storage::MarkAllAsSynchronized()
return;
auto const indexPath = GetIndexFilePath();
- my::DeleteFileX(indexPath);
+ base::DeleteFileX(indexPath);
SaveIndex();
}
diff --git a/ugc/types.hpp b/ugc/types.hpp
index 327b174280..d1581d9cb9 100644
--- a/ugc/types.hpp
+++ b/ugc/types.hpp
@@ -332,7 +332,7 @@ struct UGC
bool operator==(UGC const & rhs) const
{
return m_ratings == rhs.m_ratings && m_reviews == rhs.m_reviews &&
- my::AlmostEqualAbs(m_totalRating, rhs.m_totalRating, 1e-6f) && m_basedOn == rhs.m_basedOn;
+ base::AlmostEqualAbs(m_totalRating, rhs.m_totalRating, 1e-6f) && m_basedOn == rhs.m_basedOn;
}
bool IsEmpty() const
diff --git a/ugc/ugc_tests/migration/generate_migration_files.cpp b/ugc/ugc_tests/migration/generate_migration_files.cpp
index f903a86cb5..8d125672aa 100644
--- a/ugc/ugc_tests/migration/generate_migration_files.cpp
+++ b/ugc/ugc_tests/migration/generate_migration_files.cpp
@@ -41,19 +41,19 @@ string const kBinFileExtension = ".bin";
string GetUGCDirPath()
{
- return my::JoinPath(GetPlatform().WritableDir(), "ugc_migration");
+ return base::JoinPath(GetPlatform().WritableDir(), "ugc_migration");
}
void LoadClassificatorTypesForVersion(string const & version)
{
- auto const folderPath = my::JoinPath("ugc_migration_supported_files", version);
+ auto const folderPath = base::JoinPath("ugc_migration_supported_files", version);
auto const & p = GetPlatform();
using Inflate = coding::ZLib::Inflate;
string classificator;
{
- auto const r = p.GetReader(my::JoinPath(folderPath, kClassificatorFileName));
+ auto const r = p.GetReader(base::JoinPath(folderPath, kClassificatorFileName));
string data;
r->ReadAsString(data);
Inflate inflate(Inflate::Format::GZip);
@@ -62,7 +62,7 @@ void LoadClassificatorTypesForVersion(string const & version)
string types;
{
- auto const r = p.GetReader(my::JoinPath(folderPath, kTypesFileName));
+ auto const r = p.GetReader(base::JoinPath(folderPath, kTypesFileName));
string data;
r->ReadAsString(data);
Inflate inflate(Inflate::Format::GZip);
@@ -74,7 +74,7 @@ void LoadClassificatorTypesForVersion(string const & version)
void LoadTableForVersion(string const & version, MigrationTable & table)
{
- Source source(FileReader(my::JoinPath(GetUGCDirPath(), version + kBinFileExtension)));
+ Source source(FileReader(base::JoinPath(GetUGCDirPath(), version + kBinFileExtension)));
ugc::DeserializerV0<Source> des(source);
des(table);
}
@@ -98,7 +98,7 @@ UNIT_TEST(UGC_GenerateMigrationFiles)
c.ForEachTree(parse);
auto const fileName = v + kBinFileExtension;
- auto const filePath = my::JoinPath(ugcDirPath, fileName);
+ auto const filePath = base::JoinPath(ugcDirPath, fileName);
{
FileWriter sink(filePath, FileWriter::Op::OP_WRITE_TRUNCATE);
ugc::Serializer<FileWriter> ser(sink);
diff --git a/ugc/ugc_tests/storage_tests.cpp b/ugc/ugc_tests/storage_tests.cpp
index 3efd701dd8..e7e0e6ec56 100644
--- a/ugc/ugc_tests/storage_tests.cpp
+++ b/ugc/ugc_tests/storage_tests.cpp
@@ -47,7 +47,7 @@ string const kTestMwmName = "ugc storage test";
bool DeleteIndexFile(ugc::IndexVersion v = ugc::IndexVersion::Latest)
{
if (v == ugc::IndexVersion::Latest)
- return my::DeleteFileX(my::JoinPath(GetPlatform().WritableDir(), "index.json"));
+ return base::DeleteFileX(base::JoinPath(GetPlatform().WritableDir(), "index.json"));
string version;
switch (v)
@@ -60,13 +60,13 @@ bool DeleteIndexFile(ugc::IndexVersion v = ugc::IndexVersion::Latest)
break;
}
- return my::DeleteFileX(my::JoinPath(GetPlatform().WritableDir(), "index.json." + version));
+ return base::DeleteFileX(base::JoinPath(GetPlatform().WritableDir(), "index.json." + version));
}
bool DeleteUGCFile(ugc::IndexVersion v = ugc::IndexVersion::Latest)
{
if (v == ugc::IndexVersion::Latest)
- return my::DeleteFileX(my::JoinPath(GetPlatform().WritableDir(), "ugc.update.bin"));
+ return base::DeleteFileX(base::JoinPath(GetPlatform().WritableDir(), "ugc.update.bin"));
string version;
@@ -80,7 +80,7 @@ bool DeleteUGCFile(ugc::IndexVersion v = ugc::IndexVersion::Latest)
break;
}
- return my::DeleteFileX(my::JoinPath(GetPlatform().WritableDir(), "ugc.update.bin." + version));
+ return base::DeleteFileX(base::JoinPath(GetPlatform().WritableDir(), "ugc.update.bin." + version));
}
} // namespace
@@ -329,7 +329,7 @@ UNIT_CLASS_TEST(StorageTest, ContentTest)
ser(newUGC);
}
- my::Json ugcNode(data);
+ base::Json ugcNode(data);
auto const & indexes = storage.GetIndexesForTesting();
TEST_EQUAL(indexes.size(), 2, ());
auto const & firstIndex = indexes.front();
@@ -339,7 +339,7 @@ UNIT_CLASS_TEST(StorageTest, ContentTest)
TEST(!firstIndex.m_synchronized, ());
TEST(!lastIndex.m_synchronized, ());
- auto embeddedNode = my::NewJSONObject();
+ auto embeddedNode = base::NewJSONObject();
ToJSONObject(*embeddedNode.get(), "data_version", lastIndex.m_dataVersion);
ToJSONObject(*embeddedNode.get(), "mwm_name", lastIndex.m_mwmName);
ToJSONObject(*embeddedNode.get(), "feature_id", lastIndex.m_featureId);
@@ -347,9 +347,9 @@ UNIT_CLASS_TEST(StorageTest, ContentTest)
ToJSONObject(*embeddedNode.get(), "feature_type", c.GetReadableObjectName(c.GetTypeForIndex(lastIndex.m_matchingType)));
ToJSONObject(*ugcNode.get(), "feature", *embeddedNode.release());
- auto array = my::NewJSONArray();
+ auto array = base::NewJSONArray();
json_array_append_new(array.get(), ugcNode.get_deep_copy());
- auto reviewsNode = my::NewJSONObject();
+ auto reviewsNode = base::NewJSONObject();
ToJSONObject(*reviewsNode.get(), "reviews", *array.release());
unique_ptr<char, JSONFreeDeleter> buffer(json_dumps(reviewsNode.get(), JSON_COMPACT | JSON_ENSURE_ASCII));
string const toSendExpected(buffer.get());
@@ -476,11 +476,11 @@ UNIT_TEST(UGC_IndexMigrationFromV0ToV1Smoke)
auto & p = GetPlatform();
auto const version = "v0";
auto const indexFileName = "index.json";
- auto const folder = my::JoinPath(p.WritableDir(), "ugc_migration_supported_files", "test_index", version);
- auto const indexFilePath = my::JoinPath(folder, indexFileName);
+ auto const folder = base::JoinPath(p.WritableDir(), "ugc_migration_supported_files", "test_index", version);
+ auto const indexFilePath = base::JoinPath(folder, indexFileName);
{
using Inflate = coding::ZLib::Inflate;
- auto const r = p.GetReader(my::JoinPath(folder, "index.gz"));
+ auto const r = p.GetReader(base::JoinPath(folder, "index.gz"));
string data;
r->ReadAsString(data);
Inflate inflate(Inflate::Format::GZip);
@@ -499,8 +499,8 @@ UNIT_TEST(UGC_IndexMigrationFromV0ToV1Smoke)
s.LoadForTesting(indexFilePath);
uint64_t migratedIndexFileSize = 0;
uint64_t v0IndexFileSize = 0;
- TEST(my::GetFileSize(indexFilePath, migratedIndexFileSize), ());
- TEST(my::GetFileSize(v0IndexFilePath, v0IndexFileSize), ());
+ TEST(base::GetFileSize(indexFilePath, migratedIndexFileSize), ());
+ TEST(base::GetFileSize(v0IndexFilePath, v0IndexFileSize), ());
TEST_GREATER(migratedIndexFileSize, 0, ());
TEST_GREATER(v0IndexFileSize, 0, ());
auto const & indexes = s.GetIndexesForTesting();
@@ -525,8 +525,8 @@ UNIT_TEST(UGC_IndexMigrationFromV0ToV1Smoke)
}
}
- my::DeleteFileX(indexFilePath);
- my::DeleteFileX(v0IndexFilePath);
+ base::DeleteFileX(indexFilePath);
+ base::DeleteFileX(v0IndexFilePath);
}
UNIT_TEST(UGC_NoReviews)