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
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134 #if !defined(XMLURI_HPP)
00135 #define XMLURI_HPP
00136
00137 #include <xercesc/util/XMemory.hpp>
00138 #include <xercesc/util/XMLString.hpp>
00139
00140 #include <xercesc/internal/XSerializable.hpp>
00141
00142 XERCES_CPP_NAMESPACE_BEGIN
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153 class XMLUri : public XSerializable, public XMemory
00154 {
00155 public:
00156
00157
00158
00159
00160
00189 XMLUri(const XMLCh* const uriSpec,
00190 MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00191
00208 XMLUri(const XMLUri* const baseURI
00209 , const XMLCh* const uriSpec
00210 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00211
00215 XMLUri(const XMLUri& toCopy);
00216 XMLUri& operator=(const XMLUri& toAssign);
00217
00218 virtual ~XMLUri();
00219
00220
00221
00222
00228 const XMLCh* getUriText() const;
00229
00235 const XMLCh* getScheme() const;
00236
00242 const XMLCh* getUserInfo() const;
00243
00244
00250 const XMLCh* getHost() const;
00251
00257 int getPort() const;
00258
00265 const XMLCh* getPath() const;
00266
00274 const XMLCh* getQueryString() const;
00275
00283 const XMLCh* getFragment() const;
00284
00285
00286
00287
00288
00296 void setScheme(const XMLCh* const newScheme);
00297
00305 void setUserInfo(const XMLCh* const newUserInfo);
00306
00314 void setHost(const XMLCh* const newHost);
00315
00325 void setPort(int newPort);
00326
00347 void setPath(const XMLCh* const newPath);
00348
00357 void setQueryString(const XMLCh* const newQueryString);
00358
00367 void setFragment(const XMLCh* const newFragment);
00368
00369
00370
00371
00372
00380 static bool isURIString(const XMLCh* const uric);
00381
00385 static bool isValidURI( const XMLUri* const baseURI
00386 , const XMLCh* const uriStr);
00387
00388
00389
00390
00391 DECL_XSERIALIZABLE(XMLUri)
00392
00393 XMLUri(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00394
00395 private:
00396
00397 static const XMLCh RESERVED_CHARACTERS[];
00398 static const XMLCh MARK_CHARACTERS[];
00399 static const XMLCh SCHEME_CHARACTERS[];
00400 static const XMLCh USERINFO_CHARACTERS[];
00401 static const XMLCh PATH_CHARACTERS[];
00402
00403
00404 void buildFullText();
00405
00406
00407
00408
00409
00415 static bool isReservedCharacter(const XMLCh theChar);
00416
00422 static bool isPathCharacter(const XMLCh theChar);
00423
00429 static bool isUnreservedCharacter(const XMLCh theChar);
00430
00438 static bool isConformantSchemeName(const XMLCh* const scheme);
00439
00445 static void isConformantUserInfo(const XMLCh* const userInfo);
00463 static bool isWellFormedAddress(const XMLCh* const addr);
00464
00474 static bool isWellFormedIPv4Address(const XMLCh* const addr, const int length);
00475
00489 static bool isWellFormedIPv6Reference(const XMLCh* const addr, const int length);
00490
00506 static int scanHexSequence (const XMLCh* const addr, int index, int end, int& counter);
00507
00515 bool isGenericURI();
00516
00517
00518
00519
00520
00526 void initialize(const XMLUri& toCopy);
00527
00542 void initialize(const XMLUri* const baseURI
00543 , const XMLCh* const uriSpec);
00544
00551 void initializeScheme(const XMLCh* const uriSpec);
00552
00560 void initializeAuthority(const XMLCh* const uriSpec);
00561
00568 void initializePath(const XMLCh* const uriSpec);
00569
00574 void cleanUp();
00575
00576 static bool isConformantSchemeName(const XMLCh* const scheme,
00577 const int schemeLen);
00578 static bool processScheme(const XMLCh* const uriStr, int& index);
00579 static bool processAuthority(const XMLCh* const uriStr, const int authLen);
00580 static bool isWellFormedAddress(const XMLCh* const addr, const int addrLen);
00581 static bool processPath(const XMLCh* const pathStr, const int pathStrLen,
00582 const bool isSchemePresent);
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592 XMLCh* fScheme;
00593 XMLCh* fUserInfo;
00594 XMLCh* fHost;
00595 int fPort;
00596 XMLCh* fPath;
00597 XMLCh* fQueryString;
00598 XMLCh* fFragment;
00599 XMLCh* fURIText;
00600 MemoryManager* fMemoryManager;
00601 };
00602
00603
00604
00605
00606 inline const XMLCh* XMLUri::getScheme() const
00607 {
00608 return fScheme;
00609 }
00610
00611 inline const XMLCh* XMLUri::getUserInfo() const
00612 {
00613 return fUserInfo;
00614 }
00615
00616 inline const XMLCh* XMLUri::getHost() const
00617 {
00618 return fHost;
00619 }
00620
00621 inline int XMLUri::getPort() const
00622 {
00623 return fPort;
00624 }
00625
00626 inline const XMLCh* XMLUri::getPath() const
00627 {
00628 return fPath;
00629 }
00630
00631 inline const XMLCh* XMLUri::getQueryString() const
00632 {
00633 return fQueryString;
00634 }
00635
00636 inline const XMLCh* XMLUri::getFragment() const
00637 {
00638 return fFragment;
00639 }
00640
00641 inline const XMLCh* XMLUri::getUriText() const
00642 {
00643
00644
00645
00646
00647
00648 if (!fURIText)
00649 ((XMLUri*)this)->buildFullText();
00650
00651 return fURIText;
00652 }
00653
00654
00655
00656
00657 inline bool XMLUri::isReservedCharacter(const XMLCh theChar)
00658 {
00659 return (XMLString::indexOf(RESERVED_CHARACTERS, theChar) != -1);
00660 }
00661
00662 inline bool XMLUri::isPathCharacter(const XMLCh theChar)
00663 {
00664 return (XMLString::indexOf(PATH_CHARACTERS, theChar) != -1);
00665 }
00666
00667 inline bool XMLUri::isUnreservedCharacter(const XMLCh theChar)
00668 {
00669 return (XMLString::isAlphaNum(theChar) ||
00670 XMLString::indexOf(MARK_CHARACTERS, theChar) != -1);
00671 }
00672
00673 XERCES_CPP_NAMESPACE_END
00674
00675 #endif