Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Unified Diff: webkit/api/public/WebString.h

Issue 174484: Add a nullable string16 class to base. It combines a string16 + a null param... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ipc/ipc_message_utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/api/public/WebString.h
===================================================================
--- webkit/api/public/WebString.h (revision 24540)
+++ webkit/api/public/WebString.h (working copy)
@@ -36,6 +36,7 @@
#if WEBKIT_IMPLEMENTATION
namespace WebCore { class String; class AtomicString; }
#else
+#include <base/nullable_string16.h>
#include <base/string16.h>
#endif
@@ -108,6 +109,31 @@
return len ? string16(data(), len) : string16();
}
+ WebString(const NullableString16& s) : m_private(0)
+ {
+ if (s.is_null())
+ assign(0);
+ else
+ assign(s.string().data(), s.string().length());
+ }
+
+ WebString& operator=(const NullableString16& s)
+ {
+ if (s.is_null())
+ assign(0);
+ else
+ assign(s.string().data(), s.string().length());
+ return *this;
+ }
+
+ operator NullableString16() const
+ {
+ if (!m_private)
+ return NullableString16(string16(), true);
+ size_t len = length();
+ return NullableString16(len ? string16(data(), len) : string16(), false);
+ }
+
template <class UTF8String>
static WebString fromUTF8(const UTF8String& s)
{
« no previous file with comments | « ipc/ipc_message_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698