summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-30 19:47:47 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-30 19:47:47 +0000
commite7b418bc2ddad0832b849de9e9594745ee180d03 (patch)
tree16ad06a92cbfc71e1bc5a4e3254abcb54c40f3c3 /base
parent813fd51fbd13972fb52b46ef7c1606be80af0fd4 (diff)
downloadchromium_src-e7b418bc2ddad0832b849de9e9594745ee180d03.zip
chromium_src-e7b418bc2ddad0832b849de9e9594745ee180d03.tar.gz
chromium_src-e7b418bc2ddad0832b849de9e9594745ee180d03.tar.bz2
Convert DictionaryValue's keys to std::string (from wstring).
Everything now needs to be changed to avoid the deprecated wstring methods; this includes the unit tests. BUG=23581 TEST=all our tests still pass Review URL: http://codereview.chromium.org/3075010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54359 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/json/json_writer.cc8
-rw-r--r--base/json/json_writer.h6
-rw-r--r--base/values.cc291
-rw-r--r--base/values.h118
4 files changed, 309 insertions, 114 deletions
diff --git a/base/json/json_writer.cc b/base/json/json_writer.cc
index fa43953..dbf43ec 100644
--- a/base/json/json_writer.cc
+++ b/base/json/json_writer.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -188,8 +188,10 @@ void JSONWriter::BuildJSONString(const Value* const node,
}
}
-void JSONWriter::AppendQuotedString(const std::wstring& str) {
- JsonDoubleQuote(WideToUTF16Hack(str), true, json_string_);
+void JSONWriter::AppendQuotedString(const std::string& str) {
+ // TODO(viettrungluu): |str| is UTF-8, not ASCII, so to properly escape it we
+ // have to convert it to UTF-16. This round-trip is suboptimal.
+ JsonDoubleQuote(UTF8ToUTF16(str), true, json_string_);
}
void JSONWriter::IndentLine(int depth) {
diff --git a/base/json/json_writer.h b/base/json/json_writer.h
index db24718..eb17145 100644
--- a/base/json/json_writer.h
+++ b/base/json/json_writer.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -45,8 +45,8 @@ class JSONWriter {
// json_string_ will contain the JSON.
void BuildJSONString(const Value* const node, int depth, bool escape);
- // Appends a quoted, escaped, version of str to json_string_.
- void AppendQuotedString(const std::wstring& str);
+ // Appends a quoted, escaped, version of (UTF-8) str to json_string_.
+ void AppendQuotedString(const std::string& str);
// Adds space to json_string_ for the indent level.
void IndentLine(int depth);
diff --git a/base/values.cc b/base/values.cc
index eebd7eb..3688c35 100644
--- a/base/values.cc
+++ b/base/values.cc
@@ -323,7 +323,7 @@ bool BinaryValue::Equals(const Value* other) const {
///////////////////// DictionaryValue ////////////////////
DictionaryValue::DictionaryValue()
- : Value(TYPE_DICTIONARY) {
+ : Value(TYPE_DICTIONARY) {
}
DictionaryValue::~DictionaryValue() {
@@ -367,14 +367,20 @@ bool DictionaryValue::Equals(const Value* other) const {
return true;
}
-bool DictionaryValue::HasKey(const std::wstring& key) const {
+bool DictionaryValue::HasKey(const std::string& key) const {
ValueMap::const_iterator current_entry = dictionary_.find(key);
DCHECK((current_entry == dictionary_.end()) || current_entry->second);
return current_entry != dictionary_.end();
}
+// TODO(viettrungluu): Deprecated and to be removed:
bool DictionaryValue::HasKeyASCII(const std::string& key) const {
- return HasKey(ASCIIToWide(key));
+ return HasKey(key);
+}
+
+// TODO(viettrungluu): Deprecated and to be removed:
+bool DictionaryValue::HasKey(const std::wstring& key) const {
+ return HasKey(WideToUTF8(key));
}
void DictionaryValue::Clear() {
@@ -387,16 +393,16 @@ void DictionaryValue::Clear() {
dictionary_.clear();
}
-void DictionaryValue::Set(const std::wstring& path, Value* in_value) {
+void DictionaryValue::Set(const std::string& path, Value* in_value) {
DCHECK(in_value);
- std::wstring current_path(path);
+ std::string current_path(path);
DictionaryValue* current_dictionary = this;
for (size_t delimiter_position = current_path.find('.');
- delimiter_position != std::wstring::npos;
+ delimiter_position != std::string::npos;
delimiter_position = current_path.find('.')) {
// Assume that we're indexing into a dictionary.
- std::wstring key(current_path, 0, delimiter_position);
+ std::string key(current_path, 0, delimiter_position);
DictionaryValue* child_dictionary = NULL;
if (!current_dictionary->GetDictionary(key, &child_dictionary)) {
child_dictionary = new DictionaryValue;
@@ -410,34 +416,67 @@ void DictionaryValue::Set(const std::wstring& path, Value* in_value) {
current_dictionary->SetWithoutPathExpansion(current_path, in_value);
}
+// TODO(viettrungluu): Deprecated and to be removed:
+void DictionaryValue::Set(const std::wstring& path, Value* in_value) {
+ Set(WideToUTF8(path), in_value);
+}
+
+void DictionaryValue::SetBoolean(const std::string& path, bool in_value) {
+ Set(path, CreateBooleanValue(in_value));
+}
+
+void DictionaryValue::SetInteger(const std::string& path, int in_value) {
+ Set(path, CreateIntegerValue(in_value));
+}
+
+void DictionaryValue::SetReal(const std::string& path, double in_value) {
+ Set(path, CreateRealValue(in_value));
+}
+
+void DictionaryValue::SetString(const std::string& path,
+ const std::string& in_value) {
+ Set(path, CreateStringValue(in_value));
+}
+
+void DictionaryValue::SetStringFromUTF16(const std::string& path,
+ const string16& in_value) {
+ Set(path, CreateStringValueFromUTF16(in_value));
+}
+
+// TODO(viettrungluu): Deprecated and to be removed:
void DictionaryValue::SetBoolean(const std::wstring& path, bool in_value) {
Set(path, CreateBooleanValue(in_value));
}
+// TODO(viettrungluu): Deprecated and to be removed:
void DictionaryValue::SetInteger(const std::wstring& path, int in_value) {
Set(path, CreateIntegerValue(in_value));
}
+// TODO(viettrungluu): Deprecated and to be removed:
void DictionaryValue::SetReal(const std::wstring& path, double in_value) {
Set(path, CreateRealValue(in_value));
}
+// TODO(viettrungluu): Deprecated and to be removed:
void DictionaryValue::SetString(const std::wstring& path,
const std::string& in_value) {
Set(path, CreateStringValue(in_value));
}
+// TODO(viettrungluu): Deprecated and to be removed:
void DictionaryValue::SetString(const std::wstring& path,
const std::wstring& in_value) {
Set(path, CreateStringValue(in_value));
}
+// TODO(viettrungluu): Deprecated and to be removed:
void DictionaryValue::SetStringFromUTF16(const std::wstring& path,
const string16& in_value) {
Set(path, CreateStringValueFromUTF16(in_value));
}
-void DictionaryValue::SetWithoutPathExpansion(const std::wstring& key,
+void DictionaryValue::SetWithoutPathExpansion(const std::string& key,
Value* in_value) {
// If there's an existing value here, we need to delete it, because
// we own all our children.
@@ -449,11 +488,17 @@ void DictionaryValue::SetWithoutPathExpansion(const std::wstring& key,
dictionary_[key] = in_value;
}
-bool DictionaryValue::Get(const std::wstring& path, Value** out_value) const {
- std::wstring current_path(path);
+// TODO(viettrungluu): Deprecated and to be removed:
+void DictionaryValue::SetWithoutPathExpansion(const std::wstring& key,
+ Value* in_value) {
+ SetWithoutPathExpansion(WideToUTF8(key), in_value);
+}
+
+bool DictionaryValue::Get(const std::string& path, Value** out_value) const {
+ std::string current_path(path);
const DictionaryValue* current_dictionary = this;
for (size_t delimiter_position = current_path.find('.');
- delimiter_position != std::wstring::npos;
+ delimiter_position != std::string::npos;
delimiter_position = current_path.find('.')) {
DictionaryValue* child_dictionary = NULL;
if (!current_dictionary->GetDictionary(
@@ -467,7 +512,12 @@ bool DictionaryValue::Get(const std::wstring& path, Value** out_value) const {
return current_dictionary->GetWithoutPathExpansion(current_path, out_value);
}
-bool DictionaryValue::GetBoolean(const std::wstring& path,
+// TODO(viettrungluu): Deprecated and to be removed:
+bool DictionaryValue::Get(const std::wstring& path, Value** out_value) const {
+ return Get(WideToUTF8(path), out_value);
+}
+
+bool DictionaryValue::GetBoolean(const std::string& path,
bool* bool_value) const {
Value* value;
if (!Get(path, &value))
@@ -476,7 +526,7 @@ bool DictionaryValue::GetBoolean(const std::wstring& path,
return value->GetAsBoolean(bool_value);
}
-bool DictionaryValue::GetInteger(const std::wstring& path,
+bool DictionaryValue::GetInteger(const std::string& path,
int* out_value) const {
Value* value;
if (!Get(path, &value))
@@ -485,7 +535,7 @@ bool DictionaryValue::GetInteger(const std::wstring& path,
return value->GetAsInteger(out_value);
}
-bool DictionaryValue::GetReal(const std::wstring& path,
+bool DictionaryValue::GetReal(const std::string& path,
double* out_value) const {
Value* value;
if (!Get(path, &value))
@@ -495,26 +545,6 @@ bool DictionaryValue::GetReal(const std::wstring& path,
}
bool DictionaryValue::GetString(const std::string& path,
- string16* out_value) const {
- return GetStringAsUTF16(ASCIIToWide(path), out_value);
-}
-
-bool DictionaryValue::GetStringASCII(const std::string& path,
- std::string* out_value) const {
- std::string out;
- if (!GetString(ASCIIToWide(path), &out))
- return false;
-
- if (!IsStringASCII(out)) {
- NOTREACHED();
- return false;
- }
-
- out_value->assign(out);
- return true;
-}
-
-bool DictionaryValue::GetString(const std::wstring& path,
std::string* out_value) const {
Value* value;
if (!Get(path, &value))
@@ -523,25 +553,31 @@ bool DictionaryValue::GetString(const std::wstring& path,
return value->GetAsString(out_value);
}
-bool DictionaryValue::GetString(const std::wstring& path,
- std::wstring* out_value) const {
+bool DictionaryValue::GetStringAsUTF16(const std::string& path,
+ string16* out_value) const {
Value* value;
if (!Get(path, &value))
return false;
- return value->GetAsString(out_value);
+ return value->GetAsUTF16(out_value);
}
-bool DictionaryValue::GetStringAsUTF16(const std::wstring& path,
- string16* out_value) const {
- Value* value;
- if (!Get(path, &value))
+bool DictionaryValue::GetStringASCII(const std::string& path,
+ std::string* out_value) const {
+ std::string out;
+ if (!GetString(path, &out))
return false;
- return value->GetAsUTF16(out_value);
+ if (!IsStringASCII(out)) {
+ NOTREACHED();
+ return false;
+ }
+
+ out_value->assign(out);
+ return true;
}
-bool DictionaryValue::GetBinary(const std::wstring& path,
+bool DictionaryValue::GetBinary(const std::string& path,
BinaryValue** out_value) const {
Value* value;
bool result = Get(path, &value);
@@ -554,7 +590,7 @@ bool DictionaryValue::GetBinary(const std::wstring& path,
return true;
}
-bool DictionaryValue::GetDictionary(const std::wstring& path,
+bool DictionaryValue::GetDictionary(const std::string& path,
DictionaryValue** out_value) const {
Value* value;
bool result = Get(path, &value);
@@ -567,7 +603,7 @@ bool DictionaryValue::GetDictionary(const std::wstring& path,
return true;
}
-bool DictionaryValue::GetList(const std::wstring& path,
+bool DictionaryValue::GetList(const std::string& path,
ListValue** out_value) const {
Value* value;
bool result = Get(path, &value);
@@ -580,7 +616,71 @@ bool DictionaryValue::GetList(const std::wstring& path,
return true;
}
-bool DictionaryValue::GetWithoutPathExpansion(const std::wstring& key,
+// TODO(viettrungluu): Deprecated and to be removed:
+bool DictionaryValue::GetBoolean(const std::wstring& path,
+ bool* out_value) const {
+ return GetBoolean(WideToUTF8(path), out_value);
+}
+
+// TODO(viettrungluu): Deprecated and to be removed:
+bool DictionaryValue::GetInteger(const std::wstring& path,
+ int* out_value) const {
+ return GetInteger(WideToUTF8(path), out_value);
+}
+
+// TODO(viettrungluu): Deprecated and to be removed:
+bool DictionaryValue::GetReal(const std::wstring& path,
+ double* out_value) const {
+ return GetReal(WideToUTF8(path), out_value);
+}
+
+// TODO(viettrungluu): or maybe we should get rid of the "AsUTF16" version?
+bool DictionaryValue::GetString(const std::string& path,
+ string16* out_value) const {
+ return GetStringAsUTF16(path, out_value);
+}
+
+// TODO(viettrungluu): Deprecated and to be removed:
+bool DictionaryValue::GetString(const std::wstring& path,
+ std::string* out_value) const {
+ return GetString(WideToUTF8(path), out_value);
+}
+
+// TODO(viettrungluu): Deprecated and to be removed:
+bool DictionaryValue::GetString(const std::wstring& path,
+ std::wstring* out_value) const {
+ Value* value;
+ if (!Get(WideToUTF8(path), &value))
+ return false;
+
+ return value->GetAsString(out_value);
+}
+
+// TODO(viettrungluu): Deprecated and to be removed:
+bool DictionaryValue::GetStringAsUTF16(const std::wstring& path,
+ string16* out_value) const {
+ return GetStringAsUTF16(WideToUTF8(path), out_value);
+}
+
+// TODO(viettrungluu): Deprecated and to be removed:
+bool DictionaryValue::GetBinary(const std::wstring& path,
+ BinaryValue** out_value) const {
+ return GetBinary(WideToUTF8(path), out_value);
+}
+
+// TODO(viettrungluu): Deprecated and to be removed:
+bool DictionaryValue::GetDictionary(const std::wstring& path,
+ DictionaryValue** out_value) const {
+ return GetDictionary(WideToUTF8(path), out_value);
+}
+
+// TODO(viettrungluu): Deprecated and to be removed:
+bool DictionaryValue::GetList(const std::wstring& path,
+ ListValue** out_value) const {
+ return GetList(WideToUTF8(path), out_value);
+}
+
+bool DictionaryValue::GetWithoutPathExpansion(const std::string& key,
Value** out_value) const {
ValueMap::const_iterator entry_iterator = dictionary_.find(key);
if (entry_iterator == dictionary_.end())
@@ -592,50 +692,40 @@ bool DictionaryValue::GetWithoutPathExpansion(const std::wstring& key,
return true;
}
-bool DictionaryValue::GetIntegerWithoutPathExpansion(const std::wstring& path,
+bool DictionaryValue::GetIntegerWithoutPathExpansion(const std::string& key,
int* out_value) const {
Value* value;
- if (!GetWithoutPathExpansion(path, &value))
+ if (!GetWithoutPathExpansion(key, &value))
return false;
return value->GetAsInteger(out_value);
}
bool DictionaryValue::GetStringWithoutPathExpansion(
- const std::wstring& path,
+ const std::string& key,
std::string* out_value) const {
Value* value;
- if (!GetWithoutPathExpansion(path, &value))
- return false;
-
- return value->GetAsString(out_value);
-}
-
-bool DictionaryValue::GetStringWithoutPathExpansion(
- const std::wstring& path,
- std::wstring* out_value) const {
- Value* value;
- if (!GetWithoutPathExpansion(path, &value))
+ if (!GetWithoutPathExpansion(key, &value))
return false;
return value->GetAsString(out_value);
}
bool DictionaryValue::GetStringAsUTF16WithoutPathExpansion(
- const std::wstring& path,
+ const std::string& key,
string16* out_value) const {
Value* value;
- if (!GetWithoutPathExpansion(path, &value))
+ if (!GetWithoutPathExpansion(key, &value))
return false;
return value->GetAsUTF16(out_value);
}
bool DictionaryValue::GetDictionaryWithoutPathExpansion(
- const std::wstring& path,
+ const std::string& key,
DictionaryValue** out_value) const {
Value* value;
- bool result = GetWithoutPathExpansion(path, &value);
+ bool result = GetWithoutPathExpansion(key, &value);
if (!result || !value->IsType(TYPE_DICTIONARY))
return false;
@@ -645,10 +735,10 @@ bool DictionaryValue::GetDictionaryWithoutPathExpansion(
return true;
}
-bool DictionaryValue::GetListWithoutPathExpansion(const std::wstring& path,
+bool DictionaryValue::GetListWithoutPathExpansion(const std::string& key,
ListValue** out_value) const {
Value* value;
- bool result = GetWithoutPathExpansion(path, &value);
+ bool result = GetWithoutPathExpansion(key, &value);
if (!result || !value->IsType(TYPE_LIST))
return false;
@@ -658,11 +748,61 @@ bool DictionaryValue::GetListWithoutPathExpansion(const std::wstring& path,
return true;
}
-bool DictionaryValue::Remove(const std::wstring& path, Value** out_value) {
- std::wstring current_path(path);
+// TODO(viettrungluu): Deprecated and to be removed:
+bool DictionaryValue::GetWithoutPathExpansion(const std::wstring& key,
+ Value** out_value) const {
+ return GetWithoutPathExpansion(WideToUTF8(key), out_value);
+}
+
+// TODO(viettrungluu): Deprecated and to be removed:
+bool DictionaryValue::GetIntegerWithoutPathExpansion(const std::wstring& key,
+ int* out_value) const {
+ return GetIntegerWithoutPathExpansion(WideToUTF8(key), out_value);
+}
+
+// TODO(viettrungluu): Deprecated and to be removed:
+bool DictionaryValue::GetStringWithoutPathExpansion(
+ const std::wstring& key,
+ std::string* out_value) const {
+ return GetStringWithoutPathExpansion(WideToUTF8(key), out_value);
+}
+
+// TODO(viettrungluu): Deprecated and to be removed:
+bool DictionaryValue::GetStringWithoutPathExpansion(
+ const std::wstring& key,
+ std::wstring* out_value) const {
+ Value* value;
+ if (!GetWithoutPathExpansion(WideToUTF8(key), &value))
+ return false;
+
+ return value->GetAsString(out_value);
+}
+
+// TODO(viettrungluu): Deprecated and to be removed:
+bool DictionaryValue::GetStringAsUTF16WithoutPathExpansion(
+ const std::wstring& key,
+ string16* out_value) const {
+ return GetStringAsUTF16WithoutPathExpansion(WideToUTF8(key), out_value);
+}
+
+// TODO(viettrungluu): Deprecated and to be removed:
+bool DictionaryValue::GetDictionaryWithoutPathExpansion(
+ const std::wstring& key,
+ DictionaryValue** out_value) const {
+ return GetDictionaryWithoutPathExpansion(WideToUTF8(key), out_value);
+}
+
+// TODO(viettrungluu): Deprecated and to be removed:
+bool DictionaryValue::GetListWithoutPathExpansion(const std::wstring& key,
+ ListValue** out_value) const {
+ return GetListWithoutPathExpansion(WideToUTF8(key), out_value);
+}
+
+bool DictionaryValue::Remove(const std::string& path, Value** out_value) {
+ std::string current_path(path);
DictionaryValue* current_dictionary = this;
size_t delimiter_position = current_path.rfind('.');
- if (delimiter_position != std::wstring::npos) {
+ if (delimiter_position != std::string::npos) {
if (!GetDictionary(current_path.substr(0, delimiter_position),
&current_dictionary))
return false;
@@ -673,7 +813,12 @@ bool DictionaryValue::Remove(const std::wstring& path, Value** out_value) {
out_value);
}
-bool DictionaryValue::RemoveWithoutPathExpansion(const std::wstring& key,
+// TODO(viettrungluu): Deprecated and to be removed:
+bool DictionaryValue::Remove(const std::wstring& path, Value** out_value) {
+ return Remove(WideToUTF8(path), out_value);
+}
+
+bool DictionaryValue::RemoveWithoutPathExpansion(const std::string& key,
Value** out_value) {
ValueMap::iterator entry_iterator = dictionary_.find(key);
if (entry_iterator == dictionary_.end())
@@ -688,6 +833,12 @@ bool DictionaryValue::RemoveWithoutPathExpansion(const std::wstring& key,
return true;
}
+// TODO(viettrungluu): Deprecated and to be removed:
+bool DictionaryValue::RemoveWithoutPathExpansion(const std::wstring& key,
+ Value** out_value) {
+ return RemoveWithoutPathExpansion(WideToUTF8(key), out_value);
+}
+
DictionaryValue* DictionaryValue::DeepCopyWithoutEmptyChildren() {
Value* copy = CopyWithoutEmptyChildren(this);
return copy ? static_cast<DictionaryValue*>(copy) : new DictionaryValue;
diff --git a/base/values.h b/base/values.h
index 32d8a18..cc9d0fc 100644
--- a/base/values.h
+++ b/base/values.h
@@ -39,7 +39,7 @@ class DictionaryValue;
class ListValue;
typedef std::vector<Value*> ValueVector;
-typedef std::map<std::wstring, Value*> ValueMap;
+typedef std::map<std::string, Value*> ValueMap;
// The Value class is the base class for Values. A Value can be
// instantiated via the Create*Value() factory methods, or by directly
@@ -202,6 +202,7 @@ class BinaryValue: public Value {
DISALLOW_COPY_AND_ASSIGN(BinaryValue);
};
+// TODO(viettrungluu): Things marked DEPRECATED will be removed. crbug.com/23581
class DictionaryValue : public Value {
public:
DictionaryValue();
@@ -212,10 +213,9 @@ class DictionaryValue : public Value {
virtual bool Equals(const Value* other) const;
// Returns true if the current dictionary has a value for the given key.
- bool HasKeyASCII(const std::string& key) const;
- // Deprecated version of the above. TODO: add a string16 version for Unicode.
- // http://code.google.com/p/chromium/issues/detail?id=23581
- bool HasKey(const std::wstring& key) const;
+ bool HasKey(const std::string& key) const;
+ /*DEPRECATED*/bool HasKeyASCII(const std::string& key) const;
+ /*DEPRECATED*/bool HasKey(const std::wstring& key) const;
// Returns the number of Values in this dictionary.
size_t size() const { return dictionary_.size(); }
@@ -235,20 +235,31 @@ class DictionaryValue : public Value {
// to the path in that location.
// Note that the dictionary takes ownership of the value referenced by
// |in_value|, and therefore |in_value| must be non-NULL.
- void Set(const std::wstring& path, Value* in_value);
+ void Set(const std::string& path, Value* in_value);
+ /*DEPRECATED*/void Set(const std::wstring& path, Value* in_value);
// Convenience forms of Set(). These methods will replace any existing
// value at that path, even if it has a different type.
- void SetBoolean(const std::wstring& path, bool in_value);
- void SetInteger(const std::wstring& path, int in_value);
- void SetReal(const std::wstring& path, double in_value);
- void SetString(const std::wstring& path, const std::string& in_value);
- void SetString(const std::wstring& path, const std::wstring& in_value);
- void SetStringFromUTF16(const std::wstring& path, const string16& in_value);
+ void SetBoolean(const std::string& path, bool in_value);
+ void SetInteger(const std::string& path, int in_value);
+ void SetReal(const std::string& path, double in_value);
+ void SetString(const std::string& path, const std::string& in_value);
+ void SetStringFromUTF16(const std::string& path, const string16& in_value);
+ /*DEPRECATED*/void SetBoolean(const std::wstring& path, bool in_value);
+ /*DEPRECATED*/void SetInteger(const std::wstring& path, int in_value);
+ /*DEPRECATED*/void SetReal(const std::wstring& path, double in_value);
+ /*DEPRECATED*/void SetString(const std::wstring& path,
+ const std::string& in_value);
+ /*DEPRECATED*/void SetString(const std::wstring& path,
+ const std::wstring& in_value);
+ /*DEPRECATED*/void SetStringFromUTF16(const std::wstring& path,
+ const string16& in_value);
// Like Set(), but without special treatment of '.'. This allows e.g. URLs to
// be used as paths.
- void SetWithoutPathExpansion(const std::wstring& key, Value* in_value);
+ void SetWithoutPathExpansion(const std::string& key, Value* in_value);
+ /*DEPRECATED*/void SetWithoutPathExpansion(const std::wstring& key,
+ Value* in_value);
// Gets the Value associated with the given path starting from this object.
// A path has the form "<key>" or "<key>.<key>.[...]", where "." indexes
@@ -257,42 +268,70 @@ class DictionaryValue : public Value {
// through the |out_value| parameter, and the function will return true.
// Otherwise, it will return false and |out_value| will be untouched.
// Note that the dictionary always owns the value that's returned.
- bool Get(const std::wstring& path, Value** out_value) const;
+ bool Get(const std::string& path, Value** out_value) const;
+ /*DEPRECATED*/bool Get(const std::wstring& path, Value** out_value) const;
// These are convenience forms of Get(). The value will be retrieved
// and the return value will be true if the path is valid and the value at
// the end of the path can be returned in the form specified.
- 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::string& path, string16* out_value) const;
+ bool GetBoolean(const std::string& path, bool* out_value) const;
+ bool GetInteger(const std::string& path, int* out_value) const;
+ bool GetReal(const std::string& path, double* out_value) const;
+ bool GetString(const std::string& path, std::string* out_value) const;
+ bool GetStringAsUTF16(const std::string& path, string16* out_value) const;
bool GetStringASCII(const std::string& path, std::string* out_value) const;
- // TODO: deprecate wstring accessors.
- // http://code.google.com/p/chromium/issues/detail?id=23581
- bool GetString(const std::wstring& path, std::string* out_value) const;
- bool GetString(const std::wstring& path, std::wstring* out_value) const;
- bool GetStringAsUTF16(const std::wstring& path, string16* out_value) const;
- bool GetBinary(const std::wstring& path, BinaryValue** out_value) const;
- bool GetDictionary(const std::wstring& path,
+ bool GetBinary(const std::string& path, BinaryValue** out_value) const;
+ bool GetDictionary(const std::string& path,
DictionaryValue** out_value) const;
- bool GetList(const std::wstring& path, ListValue** out_value) const;
+ bool GetList(const std::string& path, ListValue** out_value) const;
+ /*DEPRECATED*/bool GetBoolean(const std::wstring& path,
+ bool* out_value) const;
+ /*DEPRECATED*/bool GetInteger(const std::wstring& path, int* out_value) const;
+ /*DEPRECATED*/bool GetReal(const std::wstring& path, double* out_value) const;
+ // Use |GetStringAsUTF16()| instead:
+ /*DEPRECATED*/bool GetString(const std::string& path,
+ string16* out_value) const;
+ /*DEPRECATED*/bool GetString(const std::wstring& path,
+ std::string* out_value) const;
+ /*DEPRECATED*/bool GetString(const std::wstring& path,
+ std::wstring* out_value) const;
+ /*DEPRECATED*/bool GetStringAsUTF16(const std::wstring& path,
+ string16* out_value) const;
+ /*DEPRECATED*/bool GetBinary(const std::wstring& path,
+ BinaryValue** out_value) const;
+ /*DEPRECATED*/bool GetDictionary(const std::wstring& path,
+ DictionaryValue** out_value) const;
+ /*DEPRECATED*/bool GetList(const std::wstring& path,
+ ListValue** out_value) const;
// Like Get(), but without special treatment of '.'. This allows e.g. URLs to
// be used as paths.
- bool GetWithoutPathExpansion(const std::wstring& key,
+ bool GetWithoutPathExpansion(const std::string& key,
Value** out_value) const;
- bool GetIntegerWithoutPathExpansion(const std::wstring& path,
+ bool GetIntegerWithoutPathExpansion(const std::string& key,
int* out_value) const;
- bool GetStringWithoutPathExpansion(const std::wstring& path,
+ bool GetStringWithoutPathExpansion(const std::string& key,
std::string* out_value) const;
- bool GetStringWithoutPathExpansion(const std::wstring& path,
- std::wstring* out_value) const;
- bool GetStringAsUTF16WithoutPathExpansion(const std::wstring& path,
+ bool GetStringAsUTF16WithoutPathExpansion(const std::string& key,
string16* out_value) const;
- bool GetDictionaryWithoutPathExpansion(const std::wstring& path,
+ bool GetDictionaryWithoutPathExpansion(const std::string& key,
DictionaryValue** out_value) const;
- bool GetListWithoutPathExpansion(const std::wstring& path,
+ bool GetListWithoutPathExpansion(const std::string& key,
ListValue** out_value) const;
+ /*DEPRECATED*/bool GetWithoutPathExpansion(const std::wstring& key,
+ Value** out_value) const;
+ /*DEPRECATED*/bool GetIntegerWithoutPathExpansion(const std::wstring& key,
+ int* out_value) const;
+ /*DEPRECATED*/bool GetStringWithoutPathExpansion(
+ const std::wstring& key, std::string* out_value) const;
+ /*DEPRECATED*/bool GetStringWithoutPathExpansion(
+ const std::wstring& key, std::wstring* out_value) const;
+ /*DEPRECATED*/bool GetStringAsUTF16WithoutPathExpansion(
+ const std::wstring& key, string16* out_value) const;
+ /*DEPRECATED*/bool GetDictionaryWithoutPathExpansion(
+ const std::wstring& key, DictionaryValue** out_value) const;
+ /*DEPRECATED*/bool GetListWithoutPathExpansion(const std::wstring& key,
+ ListValue** out_value) const;
// Removes the Value with the specified path from this dictionary (or one
// of its child dictionaries, if the path is more than just a local key).
@@ -300,11 +339,14 @@ class DictionaryValue : public Value {
// passed out via out_value. If |out_value| is NULL, the removed value will
// be deleted. This method returns true if |path| is a valid path; otherwise
// it will return false and the DictionaryValue object will be unchanged.
- bool Remove(const std::wstring& path, Value** out_value);
+ bool Remove(const std::string& path, Value** out_value);
+ /*DEPRECATED*/bool Remove(const std::wstring& path, Value** out_value);
// Like Remove(), but without special treatment of '.'. This allows e.g. URLs
// to be used as paths.
- bool RemoveWithoutPathExpansion(const std::wstring& key, Value** out_value);
+ bool RemoveWithoutPathExpansion(const std::string& key, Value** out_value);
+ /*DEPRECATED*/bool RemoveWithoutPathExpansion(const std::wstring& key,
+ Value** out_value);
// Makes a copy of |this| but doesn't include empty dictionaries and lists in
// the copy. This never returns NULL, even if |this| itself is empty.
@@ -323,14 +365,14 @@ class DictionaryValue : public Value {
// THE NORMAL XXX() APIs. This makes sure things will work correctly if any
// keys have '.'s in them.
class key_iterator
- : private std::iterator<std::input_iterator_tag, const std::wstring> {
+ : private std::iterator<std::input_iterator_tag, const std::string> {
public:
explicit key_iterator(ValueMap::const_iterator itr) { itr_ = itr; }
key_iterator operator++() {
++itr_;
return *this;
}
- const std::wstring& operator*() { return itr_->first; }
+ const std::string& operator*() { return itr_->first; }
bool operator!=(const key_iterator& other) { return itr_ != other.itr_; }
bool operator==(const key_iterator& other) { return itr_ == other.itr_; }