blob: f0ea0a7824c32675dbeadbe6cd17bc3c6ab67e5d (
plain)
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
35
36
37
|
#pragma once
#include "base/base.hpp"
#include "std/function.hpp"
#include "std/string.hpp"
namespace url_scheme
{
// Uri in format: 'scheme://path?key1=value1&key2&key3=&key4=value4'
class Uri
{
public:
typedef function<bool(string const &, string const &)> CallbackT;
explicit Uri(string const & uri) : m_url(uri) { Init(); }
Uri(char const * uri, size_t size) : m_url(uri, uri + size) { Init(); }
string const & GetScheme() const { return m_scheme; }
string const & GetPath() const { return m_path; }
bool IsValid() const { return !m_scheme.empty(); }
bool ForEachKeyValue(CallbackT const & callback) const;
private:
void Init();
bool Parse();
string m_url;
string m_scheme;
string m_path;
size_t m_queryStart;
};
} // namespace url_scheme
|