libcamgm
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
src
ca-mgm
UrlUtils.hpp
Go to the documentation of this file.
1
/*---------------------------------------------------------------------\
2
| |
3
| _ _ _ _ __ _ |
4
| | | | | | \_/ | / \ | | |
5
| | | | | | |_| | / /\ \ | | |
6
| | |__ | | | | | | / ____ \ | |__ |
7
| |____||_| |_| |_|/ / \ \|____| |
8
| |
9
| core library |
10
| |
11
| (C) SUSE Linux Products GmbH |
12
\----------------------------------------------------------------------/
13
14
File: UrlUtils.hpp
15
16
Author: Marius Tomaschewski
17
Maintainer: Marius Tomaschewski
18
19
/-*/
24
#ifndef CA_MGM_URLUTILS_HPP
25
#define CA_MGM_URLUTILS_HPP
26
27
#include <ca-mgm/config.h>
28
#include <
ca-mgm/ByteBuffer.hpp
>
29
#include <
ca-mgm/Exception.hpp
>
30
#include <
ca-mgm/String.hpp
>
31
32
#include <map>
33
#include <vector>
34
35
// -------------------------------------------------------------------
36
namespace
CA_MGM_NAMESPACE
37
{
38
namespace
url
39
{
40
41
// -------------------------------------------------------------------
46
CA_MGM_DECLARE_EXCEPTION
(Url);
47
48
49
// -------------------------------------------------------------------
54
CA_MGM_DECLARE_EXCEPTION2
(UrlParsing,
UrlException
);
55
56
57
// -------------------------------------------------------------------
62
CA_MGM_DECLARE_EXCEPTION2
(UrlDecoding,
UrlException
);
63
64
65
// -------------------------------------------------------------------
70
CA_MGM_DECLARE_EXCEPTION2
(UrlBadComponent,
UrlException
);
71
72
73
// -------------------------------------------------------------------
78
CA_MGM_DECLARE_EXCEPTION2
(UrlNotAllowed,
UrlException
);
79
80
81
// -------------------------------------------------------------------
87
CA_MGM_DECLARE_EXCEPTION2
(UrlNotSupported,
UrlException
);
88
89
90
// -------------------------------------------------------------------
95
typedef
std::map<std::string,std::string>
ParamMap
;
96
97
98
// -------------------------------------------------------------------
102
struct
UrlComponents
103
{
104
std::string
scheme
;
105
std::string
authority
;
106
std::string
pathdata
;
107
std::string
querystr
;
108
std::string
fragment
;
109
bool
has_scheme
;
110
bool
has_authority
;
111
bool
has_querystr
;
112
bool
has_fragment
;
113
};
114
115
116
// -------------------------------------------------------------------
120
struct
UrlAuthority
121
{
122
std::string
user
;
123
std::string
pass
;
124
std::string
host
;
125
std::string
port
;
126
bool
has_user
;
127
bool
has_pass
;
128
bool
has_port
;
129
};
130
131
132
// -------------------------------------------------------------------
135
typedef
enum
{
136
E_ENCODED
,
137
E_DECODED
138
}
EEncoding
;
139
140
141
// -------------------------------------------------------------------
167
std::string
168
encode
(
const
std::string &str,
169
const
std::string &safe =
""
,
170
ca_mgm::url::EEncoding
eflag =
E_DECODED
);
171
172
173
// -------------------------------------------------------------------
184
std::string
185
encode_buf
(
const
ca_mgm::ByteBuffer
&buf,
186
const
std::string &safe =
""
,
187
ca_mgm::url::EEncoding
eflag =
E_DECODED
);
188
189
190
// -------------------------------------------------------------------
204
std::string
205
decode
(
const
std::string &str);
206
207
208
// -------------------------------------------------------------------
224
ca_mgm::ByteBuffer
225
decode_buf
(
const
std::string &str,
bool
allowNUL);
226
227
228
// -------------------------------------------------------------------
238
std::string
239
encode_octet
(
const
unsigned
char
c);
240
241
242
// -------------------------------------------------------------------
261
int
262
decode_octet
(
const
char
*hex);
263
264
265
// -------------------------------------------------------------------
279
std::vector<std::string>
280
split
(
const
std::string &pstr,
281
const
std::string &psep);
282
283
284
// -------------------------------------------------------------------
312
ca_mgm::url::ParamMap
313
split
(
const
std::string &pstr,
314
const
std::string &psep,
315
const
std::string &vsep,
316
EEncoding
eflag =
E_ENCODED
);
317
318
319
// -------------------------------------------------------------------
333
std::string
334
join
(
const
std::vector<std::string> &parr,
335
const
std::string &psep);
336
337
338
// -------------------------------------------------------------------
360
std::string
361
join
(
const
ca_mgm::url::ParamMap
&pmap,
362
const
std::string &psep,
363
const
std::string &vsep,
364
const
std::string &safe);
365
366
367
// -------------------------------------------------------------------
368
/*
369
* Parse the @p url string by common URL separator characters
370
* and return an url main component structure.
371
* @returns An url components structure.
372
*/
373
UrlComponents
374
parse_url_string
(
const
std::string &url);
375
376
377
// -------------------------------------------------------------------
378
/*
379
* Parse the @p authority string and return the URL authority
380
* components structure.
381
* @returns An string array containing authority components.
382
*/
383
UrlAuthority
384
parse_url_authority
(
const
std::string &authority);
385
386
387
// -------------------------------------------------------------------
388
}
// End url namespace
389
}
// End of CA_MGM_NAMESPACE
390
#endif // CA_MGM_URLUTILS_HPP
391
// vim: set ts=8 sts=8 sw=8 ai noet:
Generated by
1.8.2