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

Unified Diff: base/values.h

Issue 13230: Added std::string to Value via Set/GetString overloading. (Closed)
Patch Set: Final upload check. Created 12 years 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 | base/values.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/values.h
diff --git a/base/values.h b/base/values.h
index 4786ff64fd8662352b6608941f2457af53635bf1..2f28f11eaf8d63cd2a6ae606860ce99ab0296f3b 100644
--- a/base/values.h
+++ b/base/values.h
@@ -52,6 +52,7 @@ class Value {
static Value* CreateBooleanValue(bool in_value);
static Value* CreateIntegerValue(int in_value);
static Value* CreateRealValue(double in_value);
+ static Value* CreateStringValue(const std::string& in_value);
static Value* CreateStringValue(const std::wstring& in_value);
// This one can return NULL if the input isn't valid. If the return value
@@ -86,6 +87,7 @@ class Value {
virtual bool GetAsBoolean(bool* out_value) const;
virtual bool GetAsInteger(int* out_value) const;
virtual bool GetAsReal(double* out_value) const;
+ virtual bool GetAsString(std::string* out_value) const;
virtual bool GetAsString(std::wstring* out_value) const;
// This creates a deep copy of the entire Value tree, and returns a pointer
@@ -137,11 +139,16 @@ class FundamentalValue : public Value {
class StringValue : public Value {
public:
- StringValue(const std::wstring& in_value)
- : Value(TYPE_STRING), value_(in_value) {}
+ // Initializes a StringValue with a UTF-8 narrow character string.
+ StringValue(const std::string& in_value);
+
+ // Initializes a StringValue with a wide character string.
+ StringValue(const std::wstring& in_value);
+
~StringValue();
// Subclassed methods
+ bool GetAsString(std::string* out_value) const;
bool GetAsString(std::wstring* out_value) const;
Value* DeepCopy() const;
virtual bool Equals(const Value* other) const;
@@ -149,7 +156,7 @@ class StringValue : public Value {
private:
DISALLOW_EVIL_CONSTRUCTORS(StringValue);
- std::wstring value_;
+ std::string value_;
};
class BinaryValue: public Value {
@@ -216,6 +223,7 @@ class DictionaryValue : public Value {
bool SetBoolean(const std::wstring& path, bool in_value);
bool SetInteger(const std::wstring& path, int in_value);
bool SetReal(const std::wstring& path, double in_value);
+ bool SetString(const std::wstring& path, const std::string& in_value);
bool SetString(const std::wstring& path, const std::wstring& in_value);
// Gets the Value associated with the given path starting from this object.
@@ -233,6 +241,7 @@ class DictionaryValue : public Value {
bool GetBoolean(const std::wstring& path, bool* out_value) const;
bool GetInteger(const std::wstring& path, int* out_value) const;
bool GetReal(const std::wstring& path, double* out_value) const;
+ bool GetString(const std::wstring& path, std::string* out_value) const;
bool GetString(const std::wstring& path, std::wstring* out_value) const;
bool GetBinary(const std::wstring& path, BinaryValue** out_value) const;
bool GetDictionary(const std::wstring& path,
« no previous file with comments | « no previous file | base/values.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698