00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #if !defined(XMLURI_HPP)
00022 #define XMLURI_HPP
00023
00024 #include <xercesc/util/XMemory.hpp>
00025 #include <xercesc/util/XMLString.hpp>
00026
00027 #include <xercesc/internal/XSerializable.hpp>
00028 #include <xercesc/framework/XMLBuffer.hpp>
00029
00030 XERCES_CPP_NAMESPACE_BEGIN
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 class XMLUri : public XSerializable, public XMemory
00042 {
00043 public:
00044
00045
00046
00047
00048
00077 XMLUri(const XMLCh* const uriSpec,
00078 MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00079
00096 XMLUri(const XMLUri* const baseURI
00097 , const XMLCh* const uriSpec
00098 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00099
00103 XMLUri(const XMLUri& toCopy);
00104 XMLUri& operator=(const XMLUri& toAssign);
00105
00106 virtual ~XMLUri();
00107
00108
00109
00110
00116 const XMLCh* getUriText() const;
00117
00123 const XMLCh* getScheme() const;
00124
00130 const XMLCh* getUserInfo() const;
00131
00132
00138 const XMLCh* getHost() const;
00139
00145 int getPort() const;
00146
00152 const XMLCh* getRegBasedAuthority() const;
00153
00160 const XMLCh* getPath() const;
00161
00169 const XMLCh* getQueryString() const;
00170
00178 const XMLCh* getFragment() const;
00179
00180
00181
00182
00183
00191 void setScheme(const XMLCh* const newScheme);
00192
00200 void setUserInfo(const XMLCh* const newUserInfo);
00201
00212 void setHost(const XMLCh* const newHost);
00213
00223 void setPort(int newPort);
00224
00233 void setRegBasedAuthority(const XMLCh* const newRegAuth);
00234
00255 void setPath(const XMLCh* const newPath);
00256
00265 void setQueryString(const XMLCh* const newQueryString);
00266
00275 void setFragment(const XMLCh* const newFragment);
00276
00277
00278
00279
00280
00288 static bool isURIString(const XMLCh* const uric);
00289
00293 static bool isValidURI( const XMLUri* const baseURI
00294 , const XMLCh* const uriStr);
00298 static bool isValidURI( bool haveBaseURI
00299 , const XMLCh* const uriStr);
00300
00301
00302 static void normalizeURI(const XMLCh* const systemURI,
00303 XMLBuffer& normalizedURI);
00304
00305
00306
00307
00308 DECL_XSERIALIZABLE(XMLUri)
00309
00310 XMLUri(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00311
00312 private:
00313
00314 static const XMLCh MARK_OR_RESERVED_CHARACTERS[];
00315 static const XMLCh RESERVED_CHARACTERS[];
00316 static const XMLCh MARK_CHARACTERS[];
00317 static const XMLCh SCHEME_CHARACTERS[];
00318 static const XMLCh USERINFO_CHARACTERS[];
00319 static const XMLCh REG_NAME_CHARACTERS[];
00320 static const XMLCh PATH_CHARACTERS[];
00321
00322
00323 void buildFullText();
00324
00325
00326
00327
00328
00334 static bool isReservedCharacter(const XMLCh theChar);
00335
00341 static bool isPathCharacter(const XMLCh theChar);
00342
00348 static bool isUnreservedCharacter(const XMLCh theChar);
00349
00355 static bool isReservedOrUnreservedCharacter(const XMLCh theChar);
00356
00364 static bool isConformantSchemeName(const XMLCh* const scheme);
00365
00371 static void isConformantUserInfo(const XMLCh* const userInfo
00372 , MemoryManager* const manager);
00373
00381 static bool isValidServerBasedAuthority(const XMLCh* const host
00382 , const int hostLen
00383 , const int port
00384 , const XMLCh* const userinfo
00385 , const int userLen);
00386
00394 static bool isValidServerBasedAuthority(const XMLCh* const host
00395 , const int port
00396 , const XMLCh* const userinfo
00397 , MemoryManager* const manager);
00398
00406 static bool isValidRegistryBasedAuthority(const XMLCh* const authority
00407 , const int authLen);
00408
00416 static bool isValidRegistryBasedAuthority(const XMLCh* const authority);
00417
00435 static bool isWellFormedAddress(const XMLCh* const addr
00436 , MemoryManager* const manager);
00437
00447 static bool isWellFormedIPv4Address(const XMLCh* const addr, const int length);
00448
00462 static bool isWellFormedIPv6Reference(const XMLCh* const addr, const int length);
00463
00479 static int scanHexSequence (const XMLCh* const addr, int index, int end, int& counter);
00480
00488 bool isGenericURI();
00489
00490
00491
00492
00493
00499 void initialize(const XMLUri& toCopy);
00500
00515 void initialize(const XMLUri* const baseURI
00516 , const XMLCh* const uriSpec);
00517
00524 void initializeScheme(const XMLCh* const uriSpec);
00525
00533 void initializeAuthority(const XMLCh* const uriSpec);
00534
00541 void initializePath(const XMLCh* const uriSpec);
00542
00547 void cleanUp();
00548
00549 static bool isConformantSchemeName(const XMLCh* const scheme,
00550 const int schemeLen);
00551 static bool processScheme(const XMLCh* const uriStr, int& index);
00552 static bool processAuthority(const XMLCh* const uriStr, const int authLen);
00553 static bool isWellFormedAddress(const XMLCh* const addr, const int addrLen);
00554 static bool processPath(const XMLCh* const pathStr, const int pathStrLen,
00555 const bool isSchemePresent);
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565 int fPort;
00566 XMLCh* fScheme;
00567 XMLCh* fUserInfo;
00568 XMLCh* fHost;
00569 XMLCh* fRegAuth;
00570 XMLCh* fPath;
00571 XMLCh* fQueryString;
00572 XMLCh* fFragment;
00573 XMLCh* fURIText;
00574 MemoryManager* fMemoryManager;
00575 };
00576
00577
00578
00579
00580 inline const XMLCh* XMLUri::getScheme() const
00581 {
00582 return fScheme;
00583 }
00584
00585 inline const XMLCh* XMLUri::getUserInfo() const
00586 {
00587 return fUserInfo;
00588 }
00589
00590 inline const XMLCh* XMLUri::getHost() const
00591 {
00592 return fHost;
00593 }
00594
00595 inline int XMLUri::getPort() const
00596 {
00597 return fPort;
00598 }
00599
00600 inline const XMLCh* XMLUri::getRegBasedAuthority() const
00601 {
00602 return fRegAuth;
00603 }
00604
00605 inline const XMLCh* XMLUri::getPath() const
00606 {
00607 return fPath;
00608 }
00609
00610 inline const XMLCh* XMLUri::getQueryString() const
00611 {
00612 return fQueryString;
00613 }
00614
00615 inline const XMLCh* XMLUri::getFragment() const
00616 {
00617 return fFragment;
00618 }
00619
00620 inline const XMLCh* XMLUri::getUriText() const
00621 {
00622
00623
00624
00625
00626
00627 if (!fURIText)
00628 ((XMLUri*)this)->buildFullText();
00629
00630 return fURIText;
00631 }
00632
00633
00634
00635
00636 inline bool XMLUri::isReservedOrUnreservedCharacter(const XMLCh theChar)
00637 {
00638 return (XMLString::isAlphaNum(theChar) ||
00639 XMLString::indexOf(MARK_OR_RESERVED_CHARACTERS, theChar) != -1);
00640 }
00641
00642 inline bool XMLUri::isReservedCharacter(const XMLCh theChar)
00643 {
00644 return (XMLString::indexOf(RESERVED_CHARACTERS, theChar) != -1);
00645 }
00646
00647 inline bool XMLUri::isPathCharacter(const XMLCh theChar)
00648 {
00649 return (XMLString::indexOf(PATH_CHARACTERS, theChar) != -1);
00650 }
00651
00652 inline bool XMLUri::isUnreservedCharacter(const XMLCh theChar)
00653 {
00654 return (XMLString::isAlphaNum(theChar) ||
00655 XMLString::indexOf(MARK_CHARACTERS, theChar) != -1);
00656 }
00657
00658 XERCES_CPP_NAMESPACE_END
00659
00660 #endif