summaryrefslogtreecommitdiffstats
path: root/base/values.cc
diff options
context:
space:
mode:
authordsh@google.com <dsh@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-03 21:49:53 +0000
committerdsh@google.com <dsh@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-03 21:49:53 +0000
commit3a79b3cc8393d54d72c8c7e14615fe64d86fd039 (patch)
tree2730ef27672c8f9c9e1b6ef3f443434ac98bfd4f /base/values.cc
parent1c9e90e17741f9c34f4cbe7f3e68a8300ed24e08 (diff)
downloadchromium_src-3a79b3cc8393d54d72c8c7e14615fe64d86fd039.zip
chromium_src-3a79b3cc8393d54d72c8c7e14615fe64d86fd039.tar.gz
chromium_src-3a79b3cc8393d54d72c8c7e14615fe64d86fd039.tar.bz2
Port DictionaryValue to use string16 instead of wstring.
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=10818 Review URL: http://codereview.chromium.org/31014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10833 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/values.cc')
-rw-r--r--base/values.cc70
1 files changed, 36 insertions, 34 deletions
diff --git a/base/values.cc b/base/values.cc
index cf98c0b..29a5896 100644
--- a/base/values.cc
+++ b/base/values.cc
@@ -245,13 +245,13 @@ void DictionaryValue::Clear() {
dictionary_.clear();
}
-bool DictionaryValue::HasKey(const std::wstring& key) const {
+bool DictionaryValue::HasKey(const string16& key) const {
ValueMap::const_iterator current_entry = dictionary_.find(key);
DCHECK((current_entry == dictionary_.end()) || current_entry->second);
return current_entry != dictionary_.end();
}
-void DictionaryValue::SetInCurrentNode(const std::wstring& key,
+void DictionaryValue::SetInCurrentNode(const string16& key,
Value* in_value) {
// If there's an existing value here, we need to delete it, because
// we own all our children.
@@ -263,12 +263,12 @@ void DictionaryValue::SetInCurrentNode(const std::wstring& key,
dictionary_[key] = in_value;
}
-bool DictionaryValue::Set(const std::wstring& path, Value* in_value) {
+bool DictionaryValue::Set(const string16& path, Value* in_value) {
DCHECK(in_value);
- std::wstring key = path;
+ string16 key = path;
- size_t delimiter_position = path.find_first_of(L".", 0);
+ size_t delimiter_position = path.find_first_of('.', 0);
// If there isn't a dictionary delimiter in the path, we're done.
if (delimiter_position == std::wstring::npos) {
SetInCurrentNode(key, in_value);
@@ -286,37 +286,37 @@ bool DictionaryValue::Set(const std::wstring& path, Value* in_value) {
entry = static_cast<DictionaryValue*>(dictionary_[key]);
}
- std::wstring remaining_path = path.substr(delimiter_position + 1);
+ string16 remaining_path = path.substr(delimiter_position + 1);
return entry->Set(remaining_path, in_value);
}
-bool DictionaryValue::SetBoolean(const std::wstring& path, bool in_value) {
+bool DictionaryValue::SetBoolean(const string16& path, bool in_value) {
return Set(path, CreateBooleanValue(in_value));
}
-bool DictionaryValue::SetInteger(const std::wstring& path, int in_value) {
+bool DictionaryValue::SetInteger(const string16& path, int in_value) {
return Set(path, CreateIntegerValue(in_value));
}
-bool DictionaryValue::SetReal(const std::wstring& path, double in_value) {
+bool DictionaryValue::SetReal(const string16& path, double in_value) {
return Set(path, CreateRealValue(in_value));
}
-bool DictionaryValue::SetString(const std::wstring& path,
+bool DictionaryValue::SetString(const string16& path,
const std::string& in_value) {
return Set(path, CreateStringValue(in_value));
}
-bool DictionaryValue::SetString(const std::wstring& path,
- const std::wstring& in_value) {
- return Set(path, CreateStringValue(in_value));
+bool DictionaryValue::SetString(const string16& path,
+ const string16& in_value) {
+ return Set(path, CreateStringValue(UTF16ToWideHack(in_value)));
}
-bool DictionaryValue::Get(const std::wstring& path, Value** out_value) const {
- std::wstring key = path;
+bool DictionaryValue::Get(const string16& path, Value** out_value) const {
+ string16 key = path;
- size_t delimiter_position = path.find_first_of(L".", 0);
- if (delimiter_position != std::wstring::npos) {
+ size_t delimiter_position = path.find_first_of('.', 0);
+ if (delimiter_position != string16::npos) {
key = path.substr(0, delimiter_position);
}
@@ -325,7 +325,7 @@ bool DictionaryValue::Get(const std::wstring& path, Value** out_value) const {
return false;
Value* entry = entry_iterator->second;
- if (delimiter_position == std::wstring::npos) {
+ if (delimiter_position == string16::npos) {
if (out_value)
*out_value = entry;
return true;
@@ -339,7 +339,7 @@ bool DictionaryValue::Get(const std::wstring& path, Value** out_value) const {
return false;
}
-bool DictionaryValue::GetBoolean(const std::wstring& path,
+bool DictionaryValue::GetBoolean(const string16& path,
bool* bool_value) const {
Value* value;
if (!Get(path, &value))
@@ -348,7 +348,7 @@ bool DictionaryValue::GetBoolean(const std::wstring& path,
return value->GetAsBoolean(bool_value);
}
-bool DictionaryValue::GetInteger(const std::wstring& path,
+bool DictionaryValue::GetInteger(const string16& path,
int* out_value) const {
Value* value;
if (!Get(path, &value))
@@ -357,7 +357,7 @@ bool DictionaryValue::GetInteger(const std::wstring& path,
return value->GetAsInteger(out_value);
}
-bool DictionaryValue::GetReal(const std::wstring& path,
+bool DictionaryValue::GetReal(const string16& path,
double* out_value) const {
Value* value;
if (!Get(path, &value))
@@ -366,7 +366,7 @@ bool DictionaryValue::GetReal(const std::wstring& path,
return value->GetAsReal(out_value);
}
-bool DictionaryValue::GetString(const std::wstring& path,
+bool DictionaryValue::GetString(const string16& path,
std::string* out_value) const {
Value* value;
if (!Get(path, &value))
@@ -375,16 +375,19 @@ 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::GetString(const string16& path,
+ string16* out_value) const {
Value* value;
if (!Get(path, &value))
return false;
- return value->GetAsString(out_value);
+ std::wstring wout_value;
+ bool success = value->GetAsString(&wout_value);
+ out_value->assign(WideToUTF16Hack(wout_value));
+ return success;
}
-bool DictionaryValue::GetBinary(const std::wstring& path,
+bool DictionaryValue::GetBinary(const string16& path,
BinaryValue** out_value) const {
Value* value;
bool result = Get(path, &value);
@@ -397,7 +400,7 @@ bool DictionaryValue::GetBinary(const std::wstring& path,
return true;
}
-bool DictionaryValue::GetDictionary(const std::wstring& path,
+bool DictionaryValue::GetDictionary(const string16& path,
DictionaryValue** out_value) const {
Value* value;
bool result = Get(path, &value);
@@ -410,7 +413,7 @@ bool DictionaryValue::GetDictionary(const std::wstring& path,
return true;
}
-bool DictionaryValue::GetList(const std::wstring& path,
+bool DictionaryValue::GetList(const string16& path,
ListValue** out_value) const {
Value* value;
bool result = Get(path, &value);
@@ -423,11 +426,11 @@ bool DictionaryValue::GetList(const std::wstring& path,
return true;
}
-bool DictionaryValue::Remove(const std::wstring& path, Value** out_value) {
- std::wstring key = path;
+bool DictionaryValue::Remove(const string16& path, Value** out_value) {
+ string16 key = path;
- size_t delimiter_position = path.find_first_of(L".", 0);
- if (delimiter_position != std::wstring::npos) {
+ size_t delimiter_position = path.find_first_of('.', 0);
+ if (delimiter_position != string16::npos) {
key = path.substr(0, delimiter_position);
}
@@ -436,7 +439,7 @@ bool DictionaryValue::Remove(const std::wstring& path, Value** out_value) {
return false;
Value* entry = entry_iterator->second;
- if (delimiter_position == std::wstring::npos) {
+ if (delimiter_position == string16::npos) {
if (out_value)
*out_value = entry;
else
@@ -651,4 +654,3 @@ bool ListValue::Equals(const Value* other) const {
return true;
}
-