summaryrefslogtreecommitdiffabout
path: root/include/kingate/util.h
Unidiff
Diffstat (limited to 'include/kingate/util.h') (more/less context) (ignore whitespace changes)
-rw-r--r--include/kingate/util.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/kingate/util.h b/include/kingate/util.h
index 6024ccf..3fd96f6 100644
--- a/include/kingate/util.h
+++ b/include/kingate/util.h
@@ -1,49 +1,62 @@
1#ifndef __KINGATE_UTIL_H 1#ifndef __KINGATE_UTIL_H
2#define __KINGATE_UTIL_H 2#define __KINGATE_UTIL_H
3 3
4#include <string> 4#include <string>
5 5
6#ifndef __deprecated 6#ifndef __deprecated
7#if ( __GNUC__ == 3 && __GNUC_MINOR__ > 0 ) || __GNUC__ > 3 7#if ( __GNUC__ == 3 && __GNUC_MINOR__ > 0 ) || __GNUC__ > 3
8#define __deprecated __attribute__((deprecated)) 8#define __deprecated __attribute__((deprecated))
9#else 9#else
10#define __deprecated 10#define __deprecated
11#endif 11#endif
12#endif 12#endif
13 13
14namespace kingate { 14namespace kingate {
15 using namespace std; 15 using namespace std;
16 16
17 /** 17 /**
18 * Encode string for passing via URL. 18 * Encode string for passing via URL.
19 * @param str string unencoded. 19 * @param str string unencoded.
20 * @return the encoded string. 20 * @return the encoded string.
21 */ 21 */
22 string url_encode(const string& str); 22 string url_encode(const string& str);
23 /** 23 /**
24 * Remove URL-encoding from the string. 24 * Remove URL-encoding from the string.
25 * @param str the URL-encoded string. 25 * @param str the URL-encoded string.
26 * @return the decoded string. 26 * @return the decoded string.
27 */ 27 */
28 string url_decode(const string& str); 28 string url_decode(const string& str);
29 29
30 /** 30 /**
31 * Quote string for use in HTTP header.
32 * @param str the string to quote.
33 * @return the quoted string.
34 */
35 string http_quoted_string(const string& str);
36 /**
37 * Quote string for use in HTTP header if necessary.
38 * @param str the string to quote.
39 * @return the quoted string or token left as is.
40 */
41 string http_quote(const string& str);
42
43 /**
31 * deprecated alias to url_encode. 44 * deprecated alias to url_encode.
32 * @see url_encode 45 * @see url_encode
33 */ 46 */
34 inline string __deprecated url_escape(const string& str) { 47 inline string __deprecated url_escape(const string& str) {
35 return url_encode(str); 48 return url_encode(str);
36 } 49 }
37 /** 50 /**
38 * deprecated alias to url_decode. 51 * deprecated alias to url_decode.
39 * @see url_decode 52 * @see url_decode
40 */ 53 */
41 inline string __deprecated url_unescape(const string& str) { 54 inline string __deprecated url_unescape(const string& str) {
42 return url_decode(str); 55 return url_decode(str);
43 } 56 }
44} 57}
45 58
46#endif /* __KINGATE_UTIL_H */ 59#endif /* __KINGATE_UTIL_H */
47/* 60/*
48 * vim:set ft=cpp: 61 * vim:set ft=cpp:
49 */ 62 */