| Index: base/values.cc
|
| ===================================================================
|
| --- base/values.cc (revision 10828)
|
| +++ base/values.cc (working copy)
|
| @@ -245,13 +245,13 @@
|
| 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 @@
|
| 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 @@
|
| 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 @@
|
| 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 @@
|
| 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 @@
|
| 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 @@
|
| 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 @@
|
| 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 @@
|
| 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 @@
|
| 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 @@
|
| 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 @@
|
| 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 @@
|
| 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 @@
|
|
|
| return true;
|
| }
|
| -
|
|
|