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