-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathUrl.h
More file actions
66 lines (52 loc) · 1.14 KB
/
Url.h
File metadata and controls
66 lines (52 loc) · 1.14 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//
// Created by Alone on 2022-7-21.
//
#ifndef MYUTIL_URL_H
#define MYUTIL_URL_H
#include <string>
#include <string_view>
#include <vector>
#include <map>
namespace http
{
using std::map;
using std::string;
using std::string_view;
using std::vector;
class Url
{
public:
using form_t = map<string, vector<string>>; // query数据
Url() = default;
static Url FromData(string_view src);
static void ParseQueryForm(string_view src, form_t &form);
form_t &From()
{
return m_form;
}
string Query(string const &key)
{
auto iter = m_form.find(key);
if (iter == m_form.end())
{
return "";
}
return iter->second.empty() ? "" : iter->second.back();
}
string &Path()
{
return m_path;
}
string &Domain()
{
return m_domain;
}
string to_string();
private:
string m_scheme;
string m_domain;
string m_path;
form_t m_form;
};
}
#endif // MYUTIL_URL_H