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 18 matching lines...) Expand all Loading... | |
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 INSIDE_WEBKIT | 37 #if INSIDE_WEBKIT |
38 #include <wtf/Forward.h> | 38 #include <wtf/Forward.h> |
39 #else | 39 #endif |
40 #if !INSIDE_WEBKIT || defined(UNIT_TEST) | |
40 #include <string> | 41 #include <string> |
41 #endif | 42 #endif |
42 | 43 |
43 namespace WTF { | 44 namespace WTF { |
44 class CString; | 45 class CString; |
45 class CStringBuffer; | 46 class CStringBuffer; |
46 } | 47 } |
47 | 48 |
48 namespace WebKit { | 49 namespace WebKit { |
49 | 50 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 bool isEmpty() const { return !length(); } | 89 bool isEmpty() const { return !length(); } |
89 bool isNull() const { return m_private.isNull(); } | 90 bool isNull() const { return m_private.isNull(); } |
90 | 91 |
91 BLINK_COMMON_EXPORT WebString utf16() const; | 92 BLINK_COMMON_EXPORT WebString utf16() const; |
92 | 93 |
93 #if INSIDE_WEBKIT | 94 #if INSIDE_WEBKIT |
94 BLINK_COMMON_EXPORT WebCString(const WTF::CString&); | 95 BLINK_COMMON_EXPORT WebCString(const WTF::CString&); |
95 BLINK_COMMON_EXPORT WebCString& operator=(const WTF::CString&); | 96 BLINK_COMMON_EXPORT WebCString& operator=(const WTF::CString&); |
96 BLINK_COMMON_EXPORT operator WTF::CString() const; | 97 BLINK_COMMON_EXPORT operator WTF::CString() const; |
97 #else | 98 #else |
98 WebCString(const std::string& s) | 99 WebCString(const std::string& s) |
Jeffrey Yasskin
2013/07/11 20:32:40
Defining these constructors in webkit tests causes
| |
99 { | 100 { |
100 assign(s.data(), s.length()); | 101 assign(s.data(), s.length()); |
101 } | 102 } |
102 | 103 |
103 WebCString& operator=(const std::string& s) | 104 WebCString& operator=(const std::string& s) |
104 { | 105 { |
105 assign(s.data(), s.length()); | 106 assign(s.data(), s.length()); |
106 return *this; | 107 return *this; |
107 } | 108 } |
108 | 109 #endif |
110 #if !INSIDE_WEBKIT || defined(UNIT_TEST) | |
109 operator std::string() const | 111 operator std::string() const |
110 { | 112 { |
111 size_t len = length(); | 113 size_t len = length(); |
112 return len ? std::string(data(), len) : std::string(); | 114 return len ? std::string(data(), len) : std::string(); |
113 } | 115 } |
114 | 116 |
115 template <class UTF16String> | 117 template <class UTF16String> |
116 static WebCString fromUTF16(const UTF16String& s) | 118 static WebCString fromUTF16(const UTF16String& s) |
117 { | 119 { |
118 return fromUTF16(s.data(), s.length()); | 120 return fromUTF16(s.data(), s.length()); |
119 } | 121 } |
120 #endif | 122 #endif |
121 | 123 |
122 private: | 124 private: |
123 BLINK_COMMON_EXPORT void assign(WTF::CStringBuffer*); | 125 BLINK_COMMON_EXPORT void assign(WTF::CStringBuffer*); |
124 WebPrivatePtr<WTF::CStringBuffer> m_private; | 126 WebPrivatePtr<WTF::CStringBuffer> m_private; |
125 }; | 127 }; |
126 | 128 |
127 inline bool operator<(const WebCString& a, const WebCString& b) | 129 inline bool operator<(const WebCString& a, const WebCString& b) |
128 { | 130 { |
129 return a.compare(b) < 0; | 131 return a.compare(b) < 0; |
130 } | 132 } |
131 | 133 |
132 } // namespace WebKit | 134 } // namespace WebKit |
133 | 135 |
134 #endif | 136 #endif |
OLD | NEW |