forked from mapsme/omim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uri.hpp
34 lines (26 loc) · 807 Bytes
/
uri.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#pragma once
#include "base/base.hpp"
#include <functional>
#include <string>
namespace url_scheme
{
// Uri in format: 'scheme://path?key1=value1&key2&key3=&key4=value4'
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(); }
std::string const & GetScheme() const { return m_scheme; }
std::string const & GetPath() const { return m_path; }
bool IsValid() const { return !m_scheme.empty(); }
bool ForEachKeyValue(Callback const & callback) const;
private:
void Init();
bool Parse();
std::string m_url;
std::string m_scheme;
std::string m_path;
size_t m_queryStart;
};
} // namespace url_scheme