|
Revision 43f521291669f483d361949fa6c886c0fbd94daf, 2.4 KB
(checked in by Antti-Juhani Kaijanaho <antti-juhani@…>, 21 months ago)
|
|
Add support for paginating thread and article lists.
Signed-off-by: Antti-Juhani Kaijanaho <antti-juhani@…>
|
-
Property mode set to
100644
|
| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | #ifndef GUARD_URI_HH |
|---|
| 21 | #define GUARD_URI_HH |
|---|
| 22 | |
|---|
| 23 | #include <string> |
|---|
| 24 | |
|---|
| 25 | class uri |
|---|
| 26 | { |
|---|
| 27 | public: |
|---|
| 28 | class invalid : public std::exception |
|---|
| 29 | { |
|---|
| 30 | static const char msgprefix[]; |
|---|
| 31 | const std::string msg; |
|---|
| 32 | public: |
|---|
| 33 | invalid() : msg(msgprefix) {} |
|---|
| 34 | invalid(std::string msg) |
|---|
| 35 | : msg(std::string(msgprefix) + ": " + msg) |
|---|
| 36 | {} |
|---|
| 37 | ~invalid() throw () {} |
|---|
| 38 | const char *what() const throw () { return msg.c_str(); } |
|---|
| 39 | }; |
|---|
| 40 | |
|---|
| 41 | uri() : port(-1) {} |
|---|
| 42 | uri(std::string str); |
|---|
| 43 | |
|---|
| 44 | static std::string percent_decode(std::string); |
|---|
| 45 | |
|---|
| 46 | |
|---|
| 47 | static std::string percent_encode(std::string); |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | std::string get_scheme() const { return scheme; } |
|---|
| 52 | std::string get_userinfo() const { return userinfo; } |
|---|
| 53 | std::string get_host() const { return host; } |
|---|
| 54 | int get_port() const { return port; } |
|---|
| 55 | std::string get_path() const { return path; } |
|---|
| 56 | std::string get_query() const { return query; } |
|---|
| 57 | |
|---|
| 58 | std::string get_query_param(std::string name) const; |
|---|
| 59 | void replace_query_param(std::string name, std::string new_value); |
|---|
| 60 | void replace_query_param(std::string name, int new_value); |
|---|
| 61 | void remove_query_param(std::string name); |
|---|
| 62 | |
|---|
| 63 | std::string to_string() const; |
|---|
| 64 | |
|---|
| 65 | private: |
|---|
| 66 | std::string scheme; |
|---|
| 67 | std::string userinfo; |
|---|
| 68 | std::string host; |
|---|
| 69 | int port; |
|---|
| 70 | std::string path; |
|---|
| 71 | std::string query; |
|---|
| 72 | }; |
|---|
| 73 | |
|---|
| 74 | #endif |
|---|