| 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 16 matching lines...) Expand all Loading... |
| 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 "WebCommon.h" |
| 35 #include "WebPrivatePtr.h" | 35 #include "WebPrivatePtr.h" |
| 36 | 36 |
| 37 #if WEBKIT_IMPLEMENTATION | 37 #if INSIDE_WEBKIT |
| 38 #include <wtf/Forward.h> | 38 #include <wtf/Forward.h> |
| 39 #else | 39 #else |
| 40 #include <string> | 40 #include <string> |
| 41 #endif | 41 #endif |
| 42 | 42 |
| 43 namespace WTF { | 43 namespace WTF { |
| 44 class CString; | 44 class CString; |
| 45 class CStringBuffer; | 45 class CStringBuffer; |
| 46 } | 46 } |
| 47 | 47 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 69 | 69 |
| 70 WebCString& operator=(const WebCString& s) | 70 WebCString& operator=(const WebCString& s) |
| 71 { | 71 { |
| 72 assign(s); | 72 assign(s); |
| 73 return *this; | 73 return *this; |
| 74 } | 74 } |
| 75 | 75 |
| 76 // Returns 0 if both strings are equals, a value greater than zero if the | 76 // 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 | 77 // 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. | 78 // than in |other|, or a value less than zero to indicate the opposite. |
| 79 WEBKIT_EXPORT int compare(const WebCString& other) const; | 79 BLINK_COMMON_EXPORT int compare(const WebCString& other) const; |
| 80 | 80 |
| 81 WEBKIT_EXPORT void reset(); | 81 BLINK_COMMON_EXPORT void reset(); |
| 82 WEBKIT_EXPORT void assign(const WebCString&); | 82 BLINK_COMMON_EXPORT void assign(const WebCString&); |
| 83 WEBKIT_EXPORT void assign(const char* data, size_t len); | 83 BLINK_COMMON_EXPORT void assign(const char* data, size_t len); |
| 84 | 84 |
| 85 WEBKIT_EXPORT size_t length() const; | 85 BLINK_COMMON_EXPORT size_t length() const; |
| 86 WEBKIT_EXPORT const char* data() const; | 86 BLINK_COMMON_EXPORT const char* data() const; |
| 87 | 87 |
| 88 bool isEmpty() const { return !length(); } | 88 bool isEmpty() const { return !length(); } |
| 89 bool isNull() const { return m_private.isNull(); } | 89 bool isNull() const { return m_private.isNull(); } |
| 90 | 90 |
| 91 WEBKIT_EXPORT WebString utf16() const; | 91 BLINK_COMMON_EXPORT WebString utf16() const; |
| 92 | 92 |
| 93 #if WEBKIT_IMPLEMENTATION | 93 #if INSIDE_WEBKIT |
| 94 WebCString(const WTF::CString&); | 94 BLINK_COMMON_EXPORT WebCString(const WTF::CString&); |
| 95 WebCString& operator=(const WTF::CString&); | 95 BLINK_COMMON_EXPORT WebCString& operator=(const WTF::CString&); |
| 96 operator WTF::CString() const; | 96 BLINK_COMMON_EXPORT operator WTF::CString() const; |
| 97 #else | 97 #else |
| 98 WebCString(const std::string& s) | 98 WebCString(const std::string& s) |
| 99 { | 99 { |
| 100 assign(s.data(), s.length()); | 100 assign(s.data(), s.length()); |
| 101 } | 101 } |
| 102 | 102 |
| 103 WebCString& operator=(const std::string& s) | 103 WebCString& operator=(const std::string& s) |
| 104 { | 104 { |
| 105 assign(s.data(), s.length()); | 105 assign(s.data(), s.length()); |
| 106 return *this; | 106 return *this; |
| 107 } | 107 } |
| 108 | 108 |
| 109 operator std::string() const | 109 operator std::string() const |
| 110 { | 110 { |
| 111 size_t len = length(); | 111 size_t len = length(); |
| 112 return len ? std::string(data(), len) : std::string(); | 112 return len ? std::string(data(), len) : std::string(); |
| 113 } | 113 } |
| 114 | 114 |
| 115 template <class UTF16String> | 115 template <class UTF16String> |
| 116 static WebCString fromUTF16(const UTF16String& s) | 116 static WebCString fromUTF16(const UTF16String& s) |
| 117 { | 117 { |
| 118 return fromUTF16(s.data(), s.length()); | 118 return fromUTF16(s.data(), s.length()); |
| 119 } | 119 } |
| 120 #endif | 120 #endif |
| 121 | 121 |
| 122 private: | 122 private: |
| 123 void assign(WTF::CStringBuffer*); | 123 BLINK_COMMON_EXPORT void assign(WTF::CStringBuffer*); |
| 124 WebPrivatePtr<WTF::CStringBuffer> m_private; | 124 WebPrivatePtr<WTF::CStringBuffer> m_private; |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 inline bool operator<(const WebCString& a, const WebCString& b) | 127 inline bool operator<(const WebCString& a, const WebCString& b) |
| 128 { | 128 { |
| 129 return a.compare(b) < 0; | 129 return a.compare(b) < 0; |
| 130 } | 130 } |
| 131 | 131 |
| 132 } // namespace WebKit | 132 } // namespace WebKit |
| 133 | 133 |
| 134 #endif | 134 #endif |
| OLD | NEW |