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:
authorIlya Zverev <zverik@textual.ru>2015-10-27 18:16:44 +0300
committerIlya Zverev <zverik@textual.ru>2015-10-27 18:16:44 +0300
commitbdbfddd3108a7399f643f43da44f078b124ec185 (patch)
tree046164b4812c52f2c5dc2e82172d29256f49a014 /indexer/feature_meta.cpp
parentd7b6f00519a9dde41c15b72b005176d00a2a7a50 (diff)
[metadata] More review fixes
Diffstat (limited to 'indexer/feature_meta.cpp')
-rw-r--r--indexer/feature_meta.cpp49
1 files changed, 21 insertions, 28 deletions
diff --git a/indexer/feature_meta.cpp b/indexer/feature_meta.cpp
index fb20f3675a..f7d1df0e0b 100644
--- a/indexer/feature_meta.cpp
+++ b/indexer/feature_meta.cpp
@@ -1,16 +1,5 @@
#include "indexer/feature_meta.hpp"
-namespace feature
-{
-string Metadata::GetWikiURL() const
-{
- string value = this->Get(FMD_WIKIPEDIA);
- string::size_type i = value.find(':');
- if (i == string::npos)
- return string();
- return "https://" + value.substr(0, i) + ".wikipedia.org/wiki/" + value.substr(i + 1);
-}
-
namespace
{
char HexToDec(char ch)
@@ -33,43 +22,47 @@ string UriDecode(string const & sSrc)
// sign but are not followed by two hexadecimal characters
// (0-9, A-F) are reserved for future extension"
- unsigned char const * pSrc = (unsigned char const *)sSrc.c_str();
- string::size_type const srcLen = sSrc.length();
- unsigned char const * const srcEnd = pSrc + srcLen;
- // last decodable '%'
- unsigned char const * const srcLastDec = srcEnd - 2;
-
- char * const pStart = new char[srcLen];
+ char * const pStart = new char[sSrc.length()];
char * pEnd = pStart;
- while (pSrc < srcEnd)
+ for (auto it = sSrc.begin(); it != sSrc.end(); ++it)
{
- if (*pSrc == '%')
+ if (*it == '%')
{
- if (pSrc < srcLastDec)
+ if (distance(it, sSrc.end()) > 2)
{
- char dec1 = HexToDec(*(pSrc + 1));
- char dec2 = HexToDec(*(pSrc + 2));
+ char dec1 = HexToDec(*(it + 1));
+ char dec2 = HexToDec(*(it + 2));
if (-1 != dec1 && -1 != dec2)
{
*pEnd++ = (dec1 << 4) + dec2;
- pSrc += 3;
+ it += 2;
continue;
}
}
}
- if (*pSrc == '_')
+ if (*it == '_')
*pEnd++ = ' ';
else
- *pEnd++ = *pSrc;
- pSrc++;
+ *pEnd++ = *it;
}
string sResult(pStart, pEnd);
- delete [] pStart;
+ delete[] pStart;
return sResult;
}
+} // namespace
+
+namespace feature
+{
+string Metadata::GetWikiURL() const
+{
+ string value = this->Get(FMD_WIKIPEDIA);
+ string::size_type i = value.find(':');
+ if (i == string::npos)
+ return string();
+ return "https://" + value.substr(0, i) + ".wikipedia.org/wiki/" + value.substr(i + 1);
}
string Metadata::GetWikiTitle() const