| 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 |
| 40 #include <string> | 41 #include <string> |
| 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 |
| 48 namespace WebKit { | 48 namespace WebKit { |
| 49 | 49 |
| 50 class WebString; | 50 class WebString; |
| 51 | 51 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | |
| 110 { | |
| 111 size_t len = length(); | |
| 112 return len ? std::string(data(), len) : std::string(); | |
| 113 } | |
| 114 | |
| 115 template <class UTF16String> | 109 template <class UTF16String> |
| 116 static WebCString fromUTF16(const UTF16String& s) | 110 static WebCString fromUTF16(const UTF16String& s) |
| 117 { | 111 { |
| 118 return fromUTF16(s.data(), s.length()); | 112 return fromUTF16(s.data(), s.length()); |
| 119 } | 113 } |
| 120 #endif | 114 #endif |
| 121 | 115 |
| 116 operator std::string() const |
| 117 { |
| 118 size_t len = length(); |
| 119 return len ? std::string(data(), len) : std::string(); |
| 120 } |
| 121 |
| 122 private: | 122 private: |
| 123 BLINK_COMMON_EXPORT 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 |