00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 #if !defined(XMLURL_HPP)
00022 #define XMLURL_HPP
00023 
00024 #include <xercesc/util/PlatformUtils.hpp>
00025 
00026 XERCES_CPP_NAMESPACE_BEGIN
00027 
00028 class BinInputStream;
00029 
00030 
00031 
00032 
00033 
00034 class  XMLURL : public XMemory
00035 {
00036 public:
00037     
00038     
00039     
00040     
00041     
00042     
00043     enum Protocols
00044     {
00045         File
00046         , HTTP
00047         , FTP
00048 
00049         , Protocols_Count
00050         , Unknown
00051     };
00052 
00053 
00054     
00055     
00056     
00057     static Protocols lookupByName(const XMLCh* const protoName);
00058     static bool parse(const XMLCh* const urlText, XMLURL& xmlURL);
00059 
00060     
00061     
00062     
00063     XMLURL(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00064     XMLURL
00065     (
00066         const   XMLCh* const    baseURL
00067         , const XMLCh* const    relativeURL
00068         , MemoryManager* const manager  = XMLPlatformUtils::fgMemoryManager
00069     );
00070     XMLURL
00071     (
00072         const   XMLCh* const    baseURL
00073         , const char* const     relativeURL
00074         , MemoryManager* const manager  = XMLPlatformUtils::fgMemoryManager
00075     );
00076     XMLURL
00077     (
00078         const   XMLURL&         baseURL
00079         , const XMLCh* const    relativeURL
00080     );
00081     XMLURL
00082     (
00083         const   XMLURL&         baseURL
00084         , const char* const     relativeURL
00085     );
00086     XMLURL
00087     (
00088         const   XMLCh* const    urlText
00089         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00090     );
00091     XMLURL
00092     (
00093         const   char* const     urlText
00094         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00095     );
00096     XMLURL(const XMLURL& toCopy);
00097     virtual ~XMLURL();
00098 
00099 
00100     
00101     
00102     
00103     XMLURL& operator=(const XMLURL& toAssign);
00104     bool operator==(const XMLURL& toCompare) const;
00105     bool operator!=(const XMLURL& toCompare) const;
00106 
00107 
00108     
00109     
00110     
00111     const XMLCh* getFragment() const;
00112     const XMLCh* getHost() const;
00113     const XMLCh* getPassword() const;
00114     const XMLCh* getPath() const;
00115     unsigned int getPortNum() const;
00116     Protocols getProtocol() const;
00117     const XMLCh* getProtocolName() const;
00118     const XMLCh* getQuery() const;
00119     const XMLCh* getURLText() const;
00120     const XMLCh* getUser() const;
00121     MemoryManager* getMemoryManager() const;
00122 
00123 
00124     
00125     
00126     
00127     void setURL(const XMLCh* const urlText);
00128     void setURL
00129     (
00130         const   XMLCh* const    baseURL
00131         , const XMLCh* const    relativeURL
00132     );
00133     void setURL
00134     (
00135         const   XMLURL&         baseURL
00136         , const XMLCh* const    relativeURL
00137     );
00138     
00139     bool setURL(
00140         const XMLCh* const    baseURL
00141         , const XMLCh* const    relativeURL
00142         , XMLURL& xmlURL);
00143     
00144     
00145     
00146     bool isRelative() const;
00147     bool hasInvalidChar() const;
00148     BinInputStream* makeNewStream() const;
00149     void makeRelativeTo(const XMLCh* const baseURLText);
00150     void makeRelativeTo(const XMLURL& baseURL);
00151 
00152 
00153 private:
00154     
00155     
00156     
00157     void buildFullText();
00158     void cleanUp();
00159     bool conglomerateWithBase(const XMLURL& baseURL, bool useExceptions=true);
00160     void parse
00161     (
00162         const   XMLCh* const    urlText
00163     );
00164 
00165 
00166     
00167     
00168     
00169     
00170     
00171     
00172     
00173     
00174     
00175     
00176     
00177     
00178     
00179     
00180     
00181     
00182     
00183     
00184     
00185     
00186     
00187     
00188     
00189     
00190     
00191     
00192     
00193     
00194     
00195     
00196     
00197     
00198     
00199     
00200     
00201     
00202     
00203     
00204     
00205     
00206     MemoryManager*  fMemoryManager;
00207     XMLCh*          fFragment;
00208     XMLCh*          fHost;
00209     XMLCh*          fPassword;
00210     XMLCh*          fPath;
00211     unsigned int    fPortNum;
00212     Protocols       fProtocol;
00213     XMLCh*          fQuery;
00214     XMLCh*          fUser;
00215     XMLCh*          fURLText;
00216     bool            fHasInvalidChar;
00217 };
00218 
00219 
00220 
00221 
00222 
00223 inline bool XMLURL::operator!=(const XMLURL& toCompare) const
00224 {
00225     return !operator==(toCompare);
00226 }
00227 
00228 
00229 
00230 
00231 
00232 inline const XMLCh* XMLURL::getFragment() const
00233 {
00234     return fFragment;
00235 }
00236 
00237 inline const XMLCh* XMLURL::getHost() const
00238 {
00239     return fHost;
00240 }
00241 
00242 inline const XMLCh* XMLURL::getPassword() const
00243 {
00244     return fPassword;
00245 }
00246 
00247 inline const XMLCh* XMLURL::getPath() const
00248 {
00249     return fPath;
00250 }
00251 
00252 inline XMLURL::Protocols XMLURL::getProtocol() const
00253 {
00254     return fProtocol;
00255 }
00256 
00257 inline const XMLCh* XMLURL::getQuery() const
00258 {
00259     return fQuery;
00260 }
00261 
00262 inline const XMLCh* XMLURL::getUser() const
00263 {
00264     return fUser;
00265 }
00266 
00267 inline const XMLCh* XMLURL::getURLText() const
00268 {
00269     
00270     
00271     
00272     
00273     
00274     if (!fURLText)
00275         ((XMLURL*)this)->buildFullText();
00276 
00277     return fURLText;
00278 }
00279 
00280 inline MemoryManager* XMLURL::getMemoryManager() const
00281 {
00282     return fMemoryManager;
00283 }
00284 
00285 MakeXMLException(MalformedURLException, )
00286 
00287 XERCES_CPP_NAMESPACE_END
00288 
00289 
00290 #endif