pleyo.com

/src/trunk2/BAL/Interfaces/KURL.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
00003  *
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions
00006  * are met:
00007  * 1. Redistributions of source code must retain the above copyright
00008  *    notice, this list of conditions and the following disclaimer.
00009  * 2. Redistributions in binary form must reproduce the above copyright
00010  *    notice, this list of conditions and the following disclaimer in the
00011  *    documentation and/or other materials provided with the distribution.
00012  *
00013  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
00014  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00015  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00016  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
00017  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00018  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00019  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00020  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00021  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00022  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00023  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
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

Generated on Wed Nov 21 20:04:17 2007 for Origyn Web Browser by Doxygen 1.5.3

pleyo.com
pleyo.com