DCL 4.0
Loading...
Searching...
No Matches
URI Class Reference

#include <URI.h>

Inheritance diagram for URI:
Object

Protected Member Functions

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 *)
Protected Member Functions inherited from Object
virtual ~Object ()
 Object ()

Protected Attributes

String __scheme
String __schemeSpecificPart
String __authority
String __userInfo
String __host
int __port
String __path
String __query
String __fragment
String __uri

Additional Inherited Members

Public Member Functions inherited from Object
virtual void destroy ()
String className () const
bool isInstanceOf (const std::type_info &typeinfo) const
virtual const std::type_info & typeInfo () const

Detailed Description

Definition at line 35 of file URI.h.

Member Function Documentation

◆ assign()

void URI::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 )
protected

Definition at line 203 of file URI.cpp.

212{
213 StringBuilder r;
214 if (_scheme)
215 {
216 r = _scheme;
217 r += __T(":");
218 }
219
220 if (_userInfo || _host || _port > -1)
221 r += __T("//");
222
223 if (_userInfo)
224 {
225 r += _userInfo;
226 r += __T("@");
227 }
228
229 if (_host)
230 r += _host;
231
232 if (_port > -1)
233 {
234 r +=__T( ":");
235 r += Integer::toString(_port);
236 }
237
238 if (_path)
239 r += _path;
240
241 if (_query)
242 {
243 r += __T("?");
244 r += _query;
245 }
246
247 if (_fragment)
248 {
249 r += __T("#");
250 r += _fragment;
251 }
252
253 parse(r);
254}
#define __T(str)
Definition Object.h:44
ByteString r
String toString(unsigned _base=10) const
Definition Numeric.inl:21
void parse(const wchar_t *_uri) __DCL_THROWS1(URISyntaxException *)
Definition URI.cpp:273

◆ parse()

void URI::parse ( const wchar_t * _uri)
protected

Definition at line 273 of file URI.cpp.

275{
276 __DCL_ASSERT(_uri && *_uri);
277
278 Regex re(__REGEXP_URI);
279 {
280 Regex::MatchResults m; // aMatch[11];
281 if (!re.match(_uri, m)) // aMatch, 11))
282 {
283 throw new URISyntaxException(
284 __T("doesn't match URI regular expression"),
285 _uri
286 );
287 }
288
289#define __MATCH_STR(m, index) m[index].first, m[index].second
290
294 __path.assign(__MATCH_STR(m, PATH_GROUP));
295 __query.assign(__MATCH_STR(m, QUERY_GROUP));
297 }
298
299 if (__authority.isEmpty())
300 return;
301
302 re.compile(__REGEXP_AUTHORITY);
303 {
304 Regex::MatchResults m;
305 if (re.match(__authority, m)) // aMatch, 6))
306 {
309 String port(__MATCH_STR(m, AUTHORITY_PORT_GROUP));
310 __port = Integer::parse(port, 10, __port);
311 }
312 }
313 __uri = _uri;
314}
#define __DCL_ASSERT(expr)
Definition Object.h:371
#define QUERY_GROUP
Definition URI.cpp:266
#define AUTHORITY_USERINFO_GROUP
Definition URI.cpp:269
#define FRAGMENT_GROUP
Definition URI.cpp:267
#define SCHEME_SPEC_PART_GROUP
Definition URI.cpp:263
#define SCHEME_GROUP
Definition URI.cpp:262
#define AUTHORITY_GROUP
Definition URI.cpp:264
#define AUTHORITY_HOST_GROUP
Definition URI.cpp:270
#define AUTHORITY_PORT_GROUP
Definition URI.cpp:271
#define PATH_GROUP
Definition URI.cpp:265
#define __MATCH_STR(m, index)
static int parse(const wchar_t *_number, unsigned _base=10) __DCL_THROWS1(NumericConvertException *)
Definition Numeric.inl:36
int __port
Definition URI.h:89
String __uri
Definition URI.h:94
String __authority
Definition URI.h:86
String __userInfo
Definition URI.h:87
String __fragment
Definition URI.h:92
String __query
Definition URI.h:91
String __scheme
Definition URI.h:84
String __schemeSpecificPart
Definition URI.h:85
String __host
Definition URI.h:88
String __path
Definition URI.h:90

Member Data Documentation

◆ __authority

String URI::__authority
protected

Definition at line 86 of file URI.h.

◆ __fragment

String URI::__fragment
protected

Definition at line 92 of file URI.h.

◆ __host

String URI::__host
protected

Definition at line 88 of file URI.h.

◆ __path

String URI::__path
protected

Definition at line 90 of file URI.h.

◆ __port

int URI::__port
protected

Definition at line 89 of file URI.h.

◆ __query

String URI::__query
protected

Definition at line 91 of file URI.h.

◆ __scheme

String URI::__scheme
protected

Definition at line 84 of file URI.h.

◆ __schemeSpecificPart

String URI::__schemeSpecificPart
protected

Definition at line 85 of file URI.h.

◆ __uri

String URI::__uri
protected

Definition at line 94 of file URI.h.

◆ __userInfo

String URI::__userInfo
protected

Definition at line 87 of file URI.h.


The documentation for this class was generated from the following files: