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 #ifndef KURL_h
00027 #define KURL_h
00028
00029 #include "DeprecatedString.h"
00030 #include <wtf/Platform.h>
00031
00032 #if PLATFORM(CF)
00033 typedef const struct __CFURL * CFURLRef;
00034 #endif
00035
00036 #if PLATFORM(MAC)
00037 #ifdef __OBJC__
00038 @class NSURL;
00039 #else
00040 class NSURL;
00041 #endif
00042 #endif
00043
00044 namespace WebCore {
00045
00046 class KURL;
00047 class String;
00048 class TextEncoding;
00049
00050 bool operator==(const KURL&, const KURL&);
00051 inline bool operator!=(const KURL &a, const KURL &b) { return !(a == b); }
00052
00053 bool equalIgnoringRef(const KURL&, const KURL&);
00054
00055 class KURL {
00056 public:
00057 KURL();
00058 KURL(const char*);
00059 KURL(const KURL&, const DeprecatedString&);
00060 KURL(const KURL&, const DeprecatedString&, const TextEncoding&);
00061 KURL(const DeprecatedString&);
00062 #if PLATFORM(MAC)
00063 KURL(NSURL*);
00064 #endif
00065 #if PLATFORM(CF)
00066 KURL(CFURLRef);
00067 #endif
00068 bool isEmpty() const { return urlString.isEmpty(); }
00069 bool hasPath() const;
00070
00071 DeprecatedString url() const { return urlString; }
00072
00073 DeprecatedString protocol() const;
00074 DeprecatedString host() const;
00075 unsigned short int port() const;
00076 DeprecatedString user() const;
00077 DeprecatedString pass() const;
00078 DeprecatedString path() const;
00079 DeprecatedString lastPathComponent() const;
00080 DeprecatedString query() const;
00081 DeprecatedString ref() const;
00082 bool hasRef() const;
00083
00084 DeprecatedString encodedHtmlRef() const { return ref(); }
00085
00086 void setProtocol(const DeprecatedString &);
00087 void setHost(const DeprecatedString &);
00088 void setPort(unsigned short int);
00089 void setHostAndPort(const DeprecatedString&);
00090 void setUser(const DeprecatedString &);
00091 void setPass(const DeprecatedString &);
00092 void setPath(const DeprecatedString &);
00093 void setQuery(const DeprecatedString &);
00094 void setRef(const DeprecatedString &);
00095
00096 DeprecatedString prettyURL() const;
00097
00098 #if PLATFORM(CF)
00099 CFURLRef createCFURL() const;
00100 #endif
00101 #if PLATFORM(MAC)
00102 NSURL *getNSURL() const;
00103 #endif
00104
00105 bool isLocalFile() const;
00106
00107 static DeprecatedString decode_string(const DeprecatedString&);
00108 static DeprecatedString decode_string(const DeprecatedString&, const TextEncoding&);
00109 static DeprecatedString encode_string(const DeprecatedString&);
00110
00111 friend bool operator==(const KURL &, const KURL &);
00112
00113 #ifndef NDEBUG
00114 void print() const;
00115 #endif
00116
00117 private:
00118 bool isHierarchical() const;
00119 void init(const KURL&, const DeprecatedString&, const TextEncoding&);
00120 void parse(const char *url, const DeprecatedString *originalString);
00121
00122 DeprecatedString urlString;
00123 bool m_isValid;
00124 int schemeEndPos;
00125 int userStartPos;
00126 int userEndPos;
00127 int passwordEndPos;
00128 int hostEndPos;
00129 int portEndPos;
00130 int pathEndPos;
00131 int queryEndPos;
00132 int fragmentEndPos;
00133
00134 friend bool equalIgnoringRef(const KURL& a, const KURL& b);
00135 };
00136
00137 }
00138
00139 #endif // KURL_h