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

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: Back to String::toUTF8StdString Created 5 years, 2 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 | « no previous file | third_party/WebKit/Source/wtf/text/CStringTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..e881f9ed4e9cbcfc8158d8360eeb5e6294f25120 100644
--- a/third_party/WebKit/Source/wtf/text/CString.h
+++ b/third_party/WebKit/Source/wtf/text/CString.h
@@ -29,6 +29,7 @@
#include "wtf/RefCounted.h"
#include "wtf/RefPtr.h"
#include "wtf/WTFExport.h"
+#include <string>
namespace WTF {
@@ -64,6 +65,13 @@ public:
CString(CStringBuffer* buffer) : m_buffer(buffer) { }
static CString newUninitialized(size_t length, char*& characterBuffer);
+ // This method should be used ONLY to pass a WTFString to methods outside
+ // of blink which take a std::string as an argument.
+ std::string toStdString() const
+ {
+ return std::string(data(), length());
+ }
+
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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698