7#if __DCL_HAVE_ALLOC_DEBUG
8#undef __DCL_ALLOC_LEVEL
9#define __DCL_ALLOC_LEVEL __DCL_ALLOC_INTERNAL
18#if __DCL_HAVE_THIS_FILE__
25static int hextoi(
const char* _s)
34 int r = ((
'0' <= c && c <=
'9') ? c -
'0' : c -
'a' + 10) * 16;
41 r += (
'0' <= c && c <=
'9') ? c -
'0' : c -
'a' + 10;
49 while (_begin < _end) {
54 && (_begin + 2) < _end
55 && isxdigit(*(_begin +1))
56 && isxdigit(*(_begin + 2))
58 r += (char)hextoi(_begin + 1);
75 return UTF8Decoder::decode(
77 UTF8Encoder::encode(_str)
84 static unsigned char hexchars[] =
"0123456789ABCDEF";
88 const char* psz = _str.data();
90 unsigned char c = (
unsigned char)*psz;
93 else if ((c <
'0' && c !=
'-' && c !=
'.')
94 || (c <
'A' && c >
'9')
95 || (c >
'Z' && c <
'a' && c !=
'_')
99 r += (char)hexchars[c >> 4];
100 r += (char)hexchars[c & 15];
112 UTF8Encoder::encode(_str)
119URI::URI(
const wchar_t* _uri)
126URI::URI(
const wchar_t* _scheme,
127 const wchar_t* _schemeSpecificPart,
128 const wchar_t* _fragment
143URI::URI(
const wchar_t* _scheme,
144 const wchar_t* _userInfo,
145 const wchar_t* _host,
147 const wchar_t* _path,
148 const wchar_t* _query,
149 const wchar_t* _fragment
164URI::URI(
const wchar_t* _scheme,
165 const wchar_t* _host,
166 const wchar_t* _path,
167 const wchar_t* _fragment
182URI::URI(
const wchar_t* _scheme,
183 const wchar_t* _authority,
184 const wchar_t* _path,
185 const wchar_t* _query,
186 const wchar_t* _fragment
202 const wchar_t* _scheme,
203 const wchar_t* _userInfo,
204 const wchar_t* _host,
206 const wchar_t* _path,
207 const wchar_t* _query,
208 const wchar_t* _fragment
217 if (_userInfo || _host || _port > -1)
249static const wchar_t*
const __REGEXP_URI =
250 __T(
"^(([^:/?#]+):)?((//([^/?#]*))?([^?#]*)(\\?([^#]*))?)?(#(.*))?");
252static const wchar_t*
const __REGEXP_AUTHORITY =
253 __T(
"^(([^?#]*)@)?([^?#:]*)(:([^?#]*))?");
255#define SCHEME_GROUP 2
256#define SCHEME_SPEC_PART_GROUP 3
257#define AUTHORITY_GROUP 5
260#define FRAGMENT_GROUP 10
262#define AUTHORITY_USERINFO_GROUP 2
263#define AUTHORITY_HOST_GROUP 3
264#define AUTHORITY_PORT_GROUP 5
271 Regex re(__REGEXP_URI);
274 if (!re.
match(_uri, m)) {
276 __T(
"doesn't match URI regular expression"),
281#define __MATCH_STR(m, index) m[index].first, m[index].second
294 re.
compile(__REGEXP_AUTHORITY);
309URISyntaxException::URISyntaxException(
310 const String& _reason,
311 const String& _source
314 __message = _reason +
__T(
": ") + _source;
#define __DCL_ASSERT(expr)
#define IMPLEMENT_CLASSINFO(class_name, base_class_name)
#define AUTHORITY_USERINFO_GROUP
#define SCHEME_SPEC_PART_GROUP
#define AUTHORITY_HOST_GROUP
#define AUTHORITY_PORT_GROUP
#define __MATCH_STR(m, index)
static String decode(const char *_mbs, size_t _mbslen=(size_t) -1)
virtual String toString() const
String toString(unsigned _base=10) const
static int parse(const wchar_t *_number, unsigned _base=10) __DCL_THROWS1(NumericConvertException *)
bool match(const wchar_t *_begin, const wchar_t *_end, unsigned int _flags) __DCL_THROWS1(RegexException *)
void compile(const wchar_t *_pattern, size_t _n, unsigned int _flags=0) __DCL_THROWS1(RegexException *)
void parse(const wchar_t *_uri) __DCL_THROWS1(URISyntaxException *)
void assign(const wchar_t *_scheme, const wchar_t *_userInfo, const wchar_t *_host, int _port, const wchar_t *_path, const wchar_t *_query, const wchar_t *_fragment) __DCL_THROWS1(URISyntaxException *)
String __schemeSpecificPart
static ByteString decode(const char *_begin, const char *_end)
static ByteString encode(const ByteString &_str)