Welcome to mirror list, hosted at ThFree Co, Russian Federation.

uri.hpp « coding - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8d2bae7d20963c7d25df63fa433db0b4a3065220 (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:
  using TCallback = function<bool(string const &, string const &)>;

  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(TCallback const & callback) const;

private:
  void Init();
  bool Parse();

  string m_url;
  string m_scheme;
  string m_path;

  size_t m_queryStart;
};

}  // namespace url_scheme