-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuri.hpp
40 lines (28 loc) · 788 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
35
36
37
38
39
#pragma once
#include <string>
using namespace std;
namespace jdd{
//example: scheme:path/over/there?key=val&key=val#fragment
class URI
{
friend ostream& operator<<(ostream& os, const URI& uri);
public:
//constructor
URI(string uri);
//convert to string
operator string () const;
//convert from string
string operator = (const string &rhv);
//get protocol from uri
string scheme() const;
//get the uri minus the protocol
string path() const;
//get all of the key/value pairs together as one string
string query() const;
//return the value that goes with the given key. if the key/value pair
//does not exsist, return the defaultVal
string queryVal(string key, string defaultVal="") const;
private:
string uri;//the actual uri in string form
};
}//namespace