00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 #if !defined(XMLURI_HPP)
00100 #define XMLURI_HPP
00101
00102 #include <xercesc/util/XMemory.hpp>
00103 #include <xercesc/util/XMLString.hpp>
00104
00105 XERCES_CPP_NAMESPACE_BEGIN
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116 class XMLUri : public XMemory
00117 {
00118 public:
00119
00120
00121
00122
00123
00149 XMLUri(const XMLCh* const uriSpec,
00150 MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00151
00164 XMLUri(const XMLUri* const baseURI
00165 , const XMLCh* const uriSpec
00166 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00167
00171 XMLUri(const XMLUri& toCopy);
00172 XMLUri& operator=(const XMLUri& toAssign);
00173
00174 virtual ~XMLUri();
00175
00176
00177
00178
00184 const XMLCh* getUriText() const;
00185
00191 const XMLCh* getScheme() const;
00192
00198 const XMLCh* getUserInfo() const;
00199
00200
00206 const XMLCh* getHost() const;
00207
00213 int getPort() const;
00214
00221 const XMLCh* getPath() const;
00222
00230 const XMLCh* getQueryString() const;
00231
00239 const XMLCh* getFragment() const;
00240
00241
00242
00243
00244
00252 void setScheme(const XMLCh* const newScheme);
00253
00261 void setUserInfo(const XMLCh* const newUserInfo);
00262
00270 void setHost(const XMLCh* const newHost);
00271
00281 void setPort(int newPort);
00282
00303 void setPath(const XMLCh* const newPath);
00304
00313 void setQueryString(const XMLCh* const newQueryString);
00314
00323 void setFragment(const XMLCh* const newFragment);
00324
00325
00326
00327
00328
00336 static bool isURIString(const XMLCh* const uric);
00337
00338
00339 private:
00340
00341 static const XMLCh RESERVED_CHARACTERS[];
00342 static const XMLCh MARK_CHARACTERS[];
00343 static const XMLCh SCHEME_CHARACTERS[];
00344 static const XMLCh USERINFO_CHARACTERS[];
00345
00346
00347 void buildFullText();
00348
00349
00350
00351
00352
00358 static bool isReservedCharacter(const XMLCh theChar);
00359
00365 static bool isUnreservedCharacter(const XMLCh theChar);
00366
00374 static bool isConformantSchemeName(const XMLCh* const scheme);
00375
00381 static void isConformantUserInfo(const XMLCh* const userInfo);
00396 static bool isWellFormedAddress(const XMLCh* const addr);
00397
00405 bool isGenericURI();
00406
00407
00408
00409
00410
00416 void initialize(const XMLUri& toCopy);
00417
00432 void initialize(const XMLUri* const baseURI
00433 , const XMLCh* const uriSpec);
00434
00441 void initializeScheme(const XMLCh* const uriSpec);
00442
00450 void initializeAuthority(const XMLCh* const uriSpec);
00451
00458 void initializePath(const XMLCh* const uriSpec);
00459
00464 void cleanUp();
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474 XMLCh* fScheme;
00475 XMLCh* fUserInfo;
00476 XMLCh* fHost;
00477 int fPort;
00478 XMLCh* fPath;
00479 XMLCh* fQueryString;
00480 XMLCh* fFragment;
00481 XMLCh* fURIText;
00482 MemoryManager* fMemoryManager;
00483 };
00484
00485
00486
00487
00488 inline const XMLCh* XMLUri::getScheme() const
00489 {
00490 return fScheme;
00491 }
00492
00493 inline const XMLCh* XMLUri::getUserInfo() const
00494 {
00495 return fUserInfo;
00496 }
00497
00498 inline const XMLCh* XMLUri::getHost() const
00499 {
00500 return fHost;
00501 }
00502
00503 inline int XMLUri::getPort() const
00504 {
00505 return fPort;
00506 }
00507
00508 inline const XMLCh* XMLUri::getPath() const
00509 {
00510 return fPath;
00511 }
00512
00513 inline const XMLCh* XMLUri::getQueryString() const
00514 {
00515 return fQueryString;
00516 }
00517
00518 inline const XMLCh* XMLUri::getFragment() const
00519 {
00520 return fFragment;
00521 }
00522
00523 inline const XMLCh* XMLUri::getUriText() const
00524 {
00525
00526
00527
00528
00529
00530 if (!fURIText)
00531 ((XMLUri*)this)->buildFullText();
00532
00533 return fURIText;
00534 }
00535
00536
00537
00538
00539 inline bool XMLUri::isReservedCharacter(const XMLCh theChar)
00540 {
00541 return (XMLString::indexOf(RESERVED_CHARACTERS, theChar) != -1);
00542 }
00543
00544 inline bool XMLUri::isUnreservedCharacter(const XMLCh theChar)
00545 {
00546 return (XMLString::isAlphaNum(theChar) ||
00547 XMLString::indexOf(MARK_CHARACTERS, theChar) != -1);
00548 }
00549
00550 XERCES_CPP_NAMESPACE_END
00551
00552 #endif