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
diff options
context:
space:
mode:
authorvng <viktor.govako@gmail.com>2013-12-03 17:24:08 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 02:08:08 +0300
commit55d0f1c27fc406da2acc2e041c6f651139e4a0e4 (patch)
treef416350050f3b1ffc9d08b242809b7f41adaa64f /indexer/categories_holder.cpp
parentea31feaa16e09b1e05938128292c9a9f0a2668e7 (diff)
Show more diagnostics in case of invalid categories.txt file.
Diffstat (limited to 'indexer/categories_holder.cpp')
-rw-r--r--indexer/categories_holder.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/indexer/categories_holder.cpp b/indexer/categories_holder.cpp
index 5714359ba2..d22ec2ddc4 100644
--- a/indexer/categories_holder.cpp
+++ b/indexer/categories_holder.cpp
@@ -70,8 +70,10 @@ void CategoriesHolder::LoadFromStream(istream & s)
Classificator const & c = classif();
+ int lineNumber = 0;
while (s.good())
{
+ ++lineNumber;
getline(s, line);
strings::SimpleTokenizer iter(line, ":|");
@@ -88,7 +90,12 @@ void CategoriesHolder::LoadFromStream(istream & s)
strings::Tokenize(*iter, "-", MakeBackInsertFunctor(v));
// get classificator type
- types.push_back(c.GetTypeByPath(v));
+ uint32_t const type = c.GetTypeByPathSafe(v);
+ if (type != 0)
+ types.push_back(type);
+ else
+ LOG(LWARNING, ("Invalid type:", v, "at line:", lineNumber));
+
++iter;
}
@@ -104,10 +111,11 @@ void CategoriesHolder::LoadFromStream(istream & s)
state = EParseTypes;
continue;
}
+
int8_t const langCode = StringUtf8Multilang::GetLangIndex(*iter);
if (langCode == StringUtf8Multilang::UNSUPPORTED_LANGUAGE_CODE)
{
- LOG(LWARNING, ("Invalid language code:", *iter));
+ LOG(LWARNING, ("Invalid language code:", *iter, "at line:", lineNumber));
continue;
}
@@ -119,7 +127,7 @@ void CategoriesHolder::LoadFromStream(istream & s)
if (name.m_name.empty())
{
- LOG(LWARNING, ("Empty category name"));
+ LOG(LWARNING, ("Empty category name at line:", lineNumber));
continue;
}