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

Unified Diff: third_party/WebKit/Source/wtf/text/CString.h

Issue 1382583002: Add toStdString methods to CString and WTF::String (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
Index: third_party/WebKit/Source/wtf/text/CString.h
diff --git a/third_party/WebKit/Source/wtf/text/CString.h b/third_party/WebKit/Source/wtf/text/CString.h
index 08e51027e774748d32f6336d76d19f32af7a41e7..cec3fce820e75905da27600e8abedebf27d0e4b1 100644
--- a/third_party/WebKit/Source/wtf/text/CString.h
+++ b/third_party/WebKit/Source/wtf/text/CString.h
@@ -64,6 +64,11 @@ public:
CString(CStringBuffer* buffer) : m_buffer(buffer) { }
static CString newUninitialized(size_t length, char*& characterBuffer);
+ std::string toStdString() const
+ {
+ return std::string(data(), length());
Mikhail 2015/09/30 14:02:01 length() includes NULL terminator, so should be 'l
Primiano Tucci (use gerrit) 2015/09/30 15:08:28 Just tried: String("").length() returns 0 not 1.
Mikhail 2015/09/30 15:58:39 Right. CStringBuffer's length != its size, sorry f
+ }
+
const char* data() const
{
return m_buffer ? m_buffer->data() : 0;
« no previous file with comments | « no previous file | third_party/WebKit/Source/wtf/text/CStringTest.cpp » ('j') | third_party/WebKit/Source/wtf/text/WTFString.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698