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 #if !defined(XMLURL_HPP)
00062 #define XMLURL_HPP
00063
00064 #include <xercesc/util/PlatformUtils.hpp>
00065
00066 XERCES_CPP_NAMESPACE_BEGIN
00067
00068 class BinInputStream;
00069
00070
00071
00072
00073
00074 class XMLURL : public XMemory
00075 {
00076 public:
00077
00078
00079
00080
00081
00082
00083 enum Protocols
00084 {
00085 File
00086 , HTTP
00087 , FTP
00088
00089 , Protocols_Count
00090 , Unknown
00091 };
00092
00093
00094
00095
00096
00097 static Protocols lookupByName(const XMLCh* const protoName);
00098 static bool parse(const XMLCh* const urlText, XMLURL& xmlURL);
00099
00100
00101
00102
00103 XMLURL(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00104 XMLURL
00105 (
00106 const XMLCh* const baseURL
00107 , const XMLCh* const relativeURL
00108 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00109 );
00110 XMLURL
00111 (
00112 const XMLCh* const baseURL
00113 , const char* const relativeURL
00114 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00115 );
00116 XMLURL
00117 (
00118 const XMLURL& baseURL
00119 , const XMLCh* const relativeURL
00120 );
00121 XMLURL
00122 (
00123 const XMLURL& baseURL
00124 , const char* const relativeURL
00125 );
00126 XMLURL
00127 (
00128 const XMLCh* const urlText
00129 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00130 );
00131 XMLURL
00132 (
00133 const char* const urlText
00134 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00135 );
00136 XMLURL(const XMLURL& toCopy);
00137 virtual ~XMLURL();
00138
00139
00140
00141
00142
00143 XMLURL& operator=(const XMLURL& toAssign);
00144 bool operator==(const XMLURL& toCompare) const;
00145 bool operator!=(const XMLURL& toCompare) const;
00146
00147
00148
00149
00150
00151 const XMLCh* getFragment() const;
00152 const XMLCh* getHost() const;
00153 const XMLCh* getPassword() const;
00154 const XMLCh* getPath() const;
00155 unsigned int getPortNum() const;
00156 Protocols getProtocol() const;
00157 const XMLCh* getProtocolName() const;
00158 const XMLCh* getQuery() const;
00159 const XMLCh* getURLText() const;
00160 const XMLCh* getUser() const;
00161 MemoryManager* getMemoryManager() const;
00162
00163
00164
00165
00166
00167 void setURL(const XMLCh* const urlText);
00168 void setURL
00169 (
00170 const XMLCh* const baseURL
00171 , const XMLCh* const relativeURL
00172 );
00173 void setURL
00174 (
00175 const XMLURL& baseURL
00176 , const XMLCh* const relativeURL
00177 );
00178
00179
00180
00181
00182
00183 bool isRelative() const;
00184 bool hasInvalidChar() const;
00185 BinInputStream* makeNewStream() const;
00186 void makeRelativeTo(const XMLCh* const baseURLText);
00187 void makeRelativeTo(const XMLURL& baseURL);
00188
00189
00190 private:
00191
00192
00193
00194 void buildFullText();
00195 void cleanup();
00196 bool conglomerateWithBase(const XMLURL& baseURL, bool useExceptions=true);
00197 void parse
00198 (
00199 const XMLCh* const urlText
00200 );
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243 MemoryManager* fMemoryManager;
00244 XMLCh* fFragment;
00245 XMLCh* fHost;
00246 XMLCh* fPassword;
00247 XMLCh* fPath;
00248 unsigned int fPortNum;
00249 Protocols fProtocol;
00250 XMLCh* fQuery;
00251 XMLCh* fUser;
00252 XMLCh* fURLText;
00253 bool fHasInvalidChar;
00254 };
00255
00256
00257
00258
00259
00260 inline bool XMLURL::operator!=(const XMLURL& toCompare) const
00261 {
00262 return !operator==(toCompare);
00263 }
00264
00265
00266
00267
00268
00269 inline const XMLCh* XMLURL::getFragment() const
00270 {
00271 return fFragment;
00272 }
00273
00274 inline const XMLCh* XMLURL::getHost() const
00275 {
00276 return fHost;
00277 }
00278
00279 inline const XMLCh* XMLURL::getPassword() const
00280 {
00281 return fPassword;
00282 }
00283
00284 inline const XMLCh* XMLURL::getPath() const
00285 {
00286 return fPath;
00287 }
00288
00289 inline XMLURL::Protocols XMLURL::getProtocol() const
00290 {
00291 return fProtocol;
00292 }
00293
00294 inline const XMLCh* XMLURL::getQuery() const
00295 {
00296 return fQuery;
00297 }
00298
00299 inline const XMLCh* XMLURL::getUser() const
00300 {
00301 return fUser;
00302 }
00303
00304 inline const XMLCh* XMLURL::getURLText() const
00305 {
00306
00307
00308
00309
00310
00311 if (!fURLText)
00312 ((XMLURL*)this)->buildFullText();
00313
00314 return fURLText;
00315 }
00316
00317 inline MemoryManager* XMLURL::getMemoryManager() const
00318 {
00319 return fMemoryManager;
00320 }
00321
00322 MakeXMLException(MalformedURLException, )
00323
00324 XERCES_CPP_NAMESPACE_END
00325
00326
00327 #endif