| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef WebCString_h | 31 #ifndef WebCString_h |
| 32 #define WebCString_h | 32 #define WebCString_h |
| 33 | 33 |
| 34 #include "WebCommon.h" | 34 #include "WebCommonExport.h" |
| 35 #include "WebPrivatePtr.h" | 35 #include "WebPrivatePtr.h" |
| 36 | 36 |
| 37 #if WEBKIT_IMPLEMENTATION | 37 #if !defined(INSIDE_WEBKIT) |
| 38 #include <wtf/Forward.h> | |
| 39 #else | |
| 40 #include <string> | 38 #include <string> |
| 41 #endif | 39 #endif |
| 42 | 40 |
| 43 namespace WTF { | 41 namespace WTF { |
| 44 class CString; | 42 class CString; |
| 45 class CStringBuffer; | 43 class CStringBuffer; |
| 46 } | 44 } |
| 47 | 45 |
| 48 namespace WebKit { | 46 namespace WebKit { |
| 49 | 47 |
| 50 class WebString; | 48 class WebString; |
| 51 | 49 |
| 52 // A single-byte string container with unspecified encoding. It is | 50 // A single-byte string container with unspecified encoding. It is |
| 53 // inexpensive to copy a WebCString object. | 51 // inexpensive to copy a WebCString object. |
| 54 // | 52 // |
| 55 // WARNING: It is not safe to pass a WebCString across threads!!! | 53 // WARNING: It is not safe to pass a WebCString across threads!!! |
| 56 // | 54 // |
| 57 class WebCString { | 55 class WebCString { |
| 58 public: | 56 public: |
| 59 ~WebCString() { reset(); } | 57 ~WebCString() { reset(); } |
| 60 | 58 |
| 61 WebCString() { } | 59 WebCString() { } |
| 62 | 60 |
| 63 WebCString(const char* data, size_t len) | 61 WebCString(const char* data, size_t len) |
| 64 { | 62 { |
| 65 assign(data, len); | 63 assign(data, len); |
| 66 } | 64 } |
| 67 | 65 |
| 68 WebCString(const WebCString& s) { assign(s); } | 66 WebCString(const WebCString& s) { assign(s); } |
| 69 | 67 |
| 70 WebCString& operator=(const WebCString& s) | 68 WebCString& operator=(const WebCString& s) |
| 71 { | 69 { |
| 72 assign(s); | 70 assign(s); |
| 73 return *this; | 71 return *this; |
| 74 } | 72 } |
| 75 | 73 |
| 76 // Returns 0 if both strings are equals, a value greater than zero if the | 74 // Returns 0 if both strings are equals, a value greater than zero if the |
| 77 // first character that does not match has a greater value in this string | 75 // first character that does not match has a greater value in this string |
| 78 // than in |other|, or a value less than zero to indicate the opposite. | 76 // than in |other|, or a value less than zero to indicate the opposite. |
| 79 WEBKIT_EXPORT int compare(const WebCString& other) const; | 77 BLINK_COMMON_EXPORT int compare(const WebCString& other) const; |
| 80 | 78 |
| 81 WEBKIT_EXPORT void reset(); | 79 BLINK_COMMON_EXPORT void reset(); |
| 82 WEBKIT_EXPORT void assign(const WebCString&); | 80 BLINK_COMMON_EXPORT void assign(const WebCString&); |
| 83 WEBKIT_EXPORT void assign(const char* data, size_t len); | 81 BLINK_COMMON_EXPORT void assign(const char* data, size_t len); |
| 84 | 82 |
| 85 WEBKIT_EXPORT size_t length() const; | 83 BLINK_COMMON_EXPORT size_t length() const; |
| 86 WEBKIT_EXPORT const char* data() const; | 84 BLINK_COMMON_EXPORT const char* data() const; |
| 87 | 85 |
| 88 bool isEmpty() const { return !length(); } | 86 bool isEmpty() const { return !length(); } |
| 89 bool isNull() const { return m_private.isNull(); } | 87 bool isNull() const { return m_private.isNull(); } |
| 90 | 88 |
| 91 WEBKIT_EXPORT WebString utf16() const; | 89 BLINK_COMMON_EXPORT WebString utf16() const; |
| 92 | 90 |
| 93 #if WEBKIT_IMPLEMENTATION | 91 #if defined(INSIDE_WEBKIT) |
| 94 WebCString(const WTF::CString&); | 92 BLINK_COMMON_EXPORT WebCString(const WTF::CString&); |
| 95 WebCString& operator=(const WTF::CString&); | 93 BLINK_COMMON_EXPORT WebCString& operator=(const WTF::CString&); |
| 96 operator WTF::CString() const; | 94 BLINK_COMMON_EXPORT operator WTF::CString() const; |
| 97 #else | 95 #else |
| 98 WebCString(const std::string& s) | 96 WebCString(const std::string& s) |
| 99 { | 97 { |
| 100 assign(s.data(), s.length()); | 98 assign(s.data(), s.length()); |
| 101 } | 99 } |
| 102 | 100 |
| 103 WebCString& operator=(const std::string& s) | 101 WebCString& operator=(const std::string& s) |
| 104 { | 102 { |
| 105 assign(s.data(), s.length()); | 103 assign(s.data(), s.length()); |
| 106 return *this; | 104 return *this; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 125 }; | 123 }; |
| 126 | 124 |
| 127 inline bool operator<(const WebCString& a, const WebCString& b) | 125 inline bool operator<(const WebCString& a, const WebCString& b) |
| 128 { | 126 { |
| 129 return a.compare(b) < 0; | 127 return a.compare(b) < 0; |
| 130 } | 128 } |
| 131 | 129 |
| 132 } // namespace WebKit | 130 } // namespace WebKit |
| 133 | 131 |
| 134 #endif | 132 #endif |
| OLD | NEW |