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/coding
diff options
context:
space:
mode:
authorMaxim Pimenov <m@maps.me>2020-01-31 15:21:20 +0300
committerArsentiy Milchakov <milcars@mapswithme.com>2020-02-11 14:45:02 +0300
commit6b32cab458355c4c86219ed8f4ae81cdea7a6696 (patch)
treeeae84661820c050ba13d18bc11b5e724a7121915 /coding
parent0263d9cefd3ad8de604d3154d3e8b83a0ed119a6 (diff)
Review fixes.
Diffstat (limited to 'coding')
-rw-r--r--coding/coding_tests/url_helpers_tests.cpp3
-rw-r--r--coding/url_helpers.cpp26
-rw-r--r--coding/url_helpers.hpp4
3 files changed, 19 insertions, 14 deletions
diff --git a/coding/coding_tests/url_helpers_tests.cpp b/coding/coding_tests/url_helpers_tests.cpp
index c5e954b261..8897f0a0b6 100644
--- a/coding/coding_tests/url_helpers_tests.cpp
+++ b/coding/coding_tests/url_helpers_tests.cpp
@@ -175,8 +175,7 @@ UNIT_TEST(ProcessURL_GoogleMaps)
UNIT_TEST(UriValidScheme)
{
- char const uriS[] = "mapswithme://map?ll=10.3,12.3223&n=Hello%20World";
- Uri uri(uriS, ARRAY_SIZE(uriS) - 1);
+ Uri uri("mapswithme://map?ll=10.3,12.3223&n=Hello%20World");
TEST_EQUAL(uri.GetScheme(), "mapswithme", ());
}
diff --git a/coding/url_helpers.cpp b/coding/url_helpers.cpp
index 2ff16904c8..67d58479e4 100644
--- a/coding/url_helpers.cpp
+++ b/coding/url_helpers.cpp
@@ -90,18 +90,24 @@ private:
void operator()(string const & token) const
{
- double lat, lon;
+ double lat;
+ double lon;
string::size_type n = token.find(',');
- ASSERT(n != string::npos, ());
+ if (n == string::npos)
+ return;
VERIFY(strings::to_double(token.substr(0, n), lat), ());
n = token.find_first_not_of(", ", n);
- ASSERT(n != string::npos, ());
+ if (n == string::npos)
+ return;
VERIFY(strings::to_double(token.substr(n, token.size() - n), lon), ());
if (m_parser.m_info.SetLat(lat) && m_parser.m_info.SetLon(lon))
- m_parser.m_latPriority = m_parser.m_lonPriority = m_priority;
+ {
+ m_parser.m_latPriority = m_priority;
+ m_parser.m_lonPriority = m_priority;
+ }
}
private:
@@ -142,7 +148,7 @@ private:
namespace coding::url
{
-void Uri::Init()
+Uri::Uri(std::string const & uri) : m_url(uri)
{
if (!Parse())
{
@@ -153,14 +159,16 @@ void Uri::Init()
bool Uri::Parse()
{
- // get url scheme
+ // Get url scheme.
size_t pathStart = m_url.find(':');
if (pathStart == string::npos || pathStart == 0)
return false;
m_scheme.assign(m_url, 0, pathStart);
- // skip slashes
- while (++pathStart < m_url.size() && m_url[pathStart] == '/') {}
+ // Skip slashes.
+ while (++pathStart < m_url.size() && m_url[pathStart] == '/')
+ {
+ }
// Find query starting point for (key, value) parsing.
m_queryStart = m_url.find('?', pathStart);
@@ -184,7 +192,7 @@ bool Uri::Parse()
bool Uri::ForEachKeyValue(Callback const & callback) const
{
- // parse query for keys and values
+ // Parse query for keys and values.
size_t const count = m_url.size();
size_t const queryStart = m_queryStart;
diff --git a/coding/url_helpers.hpp b/coding/url_helpers.hpp
index d131d9cb68..2ceae04494 100644
--- a/coding/url_helpers.hpp
+++ b/coding/url_helpers.hpp
@@ -13,8 +13,7 @@ class Uri
public:
using Callback = std::function<bool(std::string const &, std::string const &)>;
- explicit Uri(std::string const & uri) : m_url(uri) { Init(); }
- Uri(char const * uri, size_t size) : m_url(uri, uri + size) { Init(); }
+ explicit Uri(std::string const & uri);
std::string const & GetScheme() const { return m_scheme; }
std::string const & GetPath() const { return m_path; }
@@ -22,7 +21,6 @@ public:
bool ForEachKeyValue(Callback const & callback) const;
private:
- void Init();
bool Parse();
std::string m_url;