12
12
#include < errno.h>
13
13
#include < limits>
14
14
15
- using namespace std ;
15
+ static const std::string CHARS_ALPHA_NUM = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 " ;
16
16
17
- static const string CHARS_ALPHA_NUM = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" ;
18
-
19
- static const string SAFE_CHARS[] =
17
+ static const std::string SAFE_CHARS[] =
20
18
{
21
19
CHARS_ALPHA_NUM + " .,;-_/:?@()" , // SAFE_CHARS_DEFAULT
22
20
CHARS_ALPHA_NUM + " .,;-_?@" , // SAFE_CHARS_UA_COMMENT
23
21
CHARS_ALPHA_NUM + " .-_" , // SAFE_CHARS_FILENAME
24
22
};
25
23
26
- string SanitizeString (const string& str, int rule)
24
+ std:: string SanitizeString (const std:: string& str, int rule)
27
25
{
28
- string strResult;
26
+ std:: string strResult;
29
27
for (std::string::size_type i = 0 ; i < str.size (); i++)
30
28
{
31
29
if (SAFE_CHARS[rule].find (str[i]) != std::string::npos)
@@ -57,7 +55,7 @@ signed char HexDigit(char c)
57
55
return p_util_hexdigit[(unsigned char )c];
58
56
}
59
57
60
- bool IsHex (const string& str)
58
+ bool IsHex (const std:: string& str)
61
59
{
62
60
for (std::string::const_iterator it (str.begin ()); it != str.end (); ++it)
63
61
{
@@ -67,10 +65,10 @@ bool IsHex(const string& str)
67
65
return (str.size () > 0 ) && (str.size ()%2 == 0 );
68
66
}
69
67
70
- vector<unsigned char > ParseHex (const char * psz)
68
+ std:: vector<unsigned char > ParseHex (const char * psz)
71
69
{
72
70
// convert hex dump to vector
73
- vector<unsigned char > vch;
71
+ std:: vector<unsigned char > vch;
74
72
while (true )
75
73
{
76
74
while (isspace (*psz))
@@ -88,16 +86,16 @@ vector<unsigned char> ParseHex(const char* psz)
88
86
return vch;
89
87
}
90
88
91
- vector<unsigned char > ParseHex (const string& str)
89
+ std:: vector<unsigned char > ParseHex (const std:: string& str)
92
90
{
93
91
return ParseHex (str.c_str ());
94
92
}
95
93
96
- string EncodeBase64 (const unsigned char * pch, size_t len)
94
+ std:: string EncodeBase64 (const unsigned char * pch, size_t len)
97
95
{
98
96
static const char *pbase64 = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ;
99
97
100
- string strRet= " " ;
98
+ std:: string strRet = " " ;
101
99
strRet.reserve ((len+2 )/3 *4 );
102
100
103
101
int mode=0 , left=0 ;
@@ -139,12 +137,12 @@ string EncodeBase64(const unsigned char* pch, size_t len)
139
137
return strRet;
140
138
}
141
139
142
- string EncodeBase64 (const string& str)
140
+ std:: string EncodeBase64 (const std:: string& str)
143
141
{
144
142
return EncodeBase64 ((const unsigned char *)str.c_str (), str.size ());
145
143
}
146
144
147
- vector<unsigned char > DecodeBase64 (const char * p, bool * pfInvalid)
145
+ std:: vector<unsigned char > DecodeBase64 (const char * p, bool * pfInvalid)
148
146
{
149
147
static const int decode64_table[256 ] =
150
148
{
@@ -166,7 +164,7 @@ vector<unsigned char> DecodeBase64(const char* p, bool* pfInvalid)
166
164
if (pfInvalid)
167
165
*pfInvalid = false ;
168
166
169
- vector<unsigned char > vchRet;
167
+ std:: vector<unsigned char > vchRet;
170
168
vchRet.reserve (strlen (p)*3 /4 );
171
169
172
170
int mode = 0 ;
@@ -227,17 +225,17 @@ vector<unsigned char> DecodeBase64(const char* p, bool* pfInvalid)
227
225
return vchRet;
228
226
}
229
227
230
- string DecodeBase64 (const string& str)
228
+ std:: string DecodeBase64 (const std:: string& str)
231
229
{
232
- vector<unsigned char > vchRet = DecodeBase64 (str.c_str ());
233
- return (vchRet.size () == 0 ) ? string () : string ((const char *)&vchRet[0 ], vchRet.size ());
230
+ std:: vector<unsigned char > vchRet = DecodeBase64 (str.c_str ());
231
+ return (vchRet.size () == 0 ) ? std:: string () : std:: string ((const char *)&vchRet[0 ], vchRet.size ());
234
232
}
235
233
236
- string EncodeBase32 (const unsigned char * pch, size_t len)
234
+ std:: string EncodeBase32 (const unsigned char * pch, size_t len)
237
235
{
238
236
static const char *pbase32 = " abcdefghijklmnopqrstuvwxyz234567" ;
239
237
240
- string strRet=" " ;
238
+ std:: string strRet=" " ;
241
239
strRet.reserve ((len+4 )/5 *8 );
242
240
243
241
int mode=0 , left=0 ;
@@ -292,12 +290,12 @@ string EncodeBase32(const unsigned char* pch, size_t len)
292
290
return strRet;
293
291
}
294
292
295
- string EncodeBase32 (const string& str)
293
+ std:: string EncodeBase32 (const std:: string& str)
296
294
{
297
295
return EncodeBase32 ((const unsigned char *)str.c_str (), str.size ());
298
296
}
299
297
300
- vector<unsigned char > DecodeBase32 (const char * p, bool * pfInvalid)
298
+ std:: vector<unsigned char > DecodeBase32 (const char * p, bool * pfInvalid)
301
299
{
302
300
static const int decode32_table[256 ] =
303
301
{
@@ -319,7 +317,7 @@ vector<unsigned char> DecodeBase32(const char* p, bool* pfInvalid)
319
317
if (pfInvalid)
320
318
*pfInvalid = false ;
321
319
322
- vector<unsigned char > vchRet;
320
+ std:: vector<unsigned char > vchRet;
323
321
vchRet.reserve ((strlen (p))*5 /8 );
324
322
325
323
int mode = 0 ;
@@ -414,10 +412,10 @@ vector<unsigned char> DecodeBase32(const char* p, bool* pfInvalid)
414
412
return vchRet;
415
413
}
416
414
417
- string DecodeBase32 (const string& str)
415
+ std:: string DecodeBase32 (const std:: string& str)
418
416
{
419
- vector<unsigned char > vchRet = DecodeBase32 (str.c_str ());
420
- return (vchRet.size () == 0 ) ? string () : string ((const char *)&vchRet[0 ], vchRet.size ());
417
+ std:: vector<unsigned char > vchRet = DecodeBase32 (str.c_str ());
418
+ return (vchRet.size () == 0 ) ? std:: string () : std:: string ((const char *)&vchRet[0 ], vchRet.size ());
421
419
}
422
420
423
421
static bool ParsePrechecks (const std::string& str)
0 commit comments