| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/values.h" | 5 #include "base/values.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <ostream> | 8 #include <ostream> |
| 9 | 9 |
| 10 #include "base/float_util.h" | 10 #include "base/float_util.h" |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 } | 457 } |
| 458 | 458 |
| 459 void DictionaryValue::SetStringWithoutPathExpansion( | 459 void DictionaryValue::SetStringWithoutPathExpansion( |
| 460 const std::string& path, const string16& in_value) { | 460 const std::string& path, const string16& in_value) { |
| 461 SetWithoutPathExpansion(path, CreateStringValue(in_value)); | 461 SetWithoutPathExpansion(path, CreateStringValue(in_value)); |
| 462 } | 462 } |
| 463 | 463 |
| 464 bool DictionaryValue::Get( | 464 bool DictionaryValue::Get( |
| 465 const std::string& path, const Value** out_value) const { | 465 const std::string& path, const Value** out_value) const { |
| 466 DCHECK(IsStringUTF8(path)); | 466 DCHECK(IsStringUTF8(path)); |
| 467 // LOG(WARNING) << "\n1\n"; |
| 467 std::string current_path(path); | 468 std::string current_path(path); |
| 468 const DictionaryValue* current_dictionary = this; | 469 const DictionaryValue* current_dictionary = this; |
| 470 // LOG(WARNING) << "\n2\n"; |
| 469 for (size_t delimiter_position = current_path.find('.'); | 471 for (size_t delimiter_position = current_path.find('.'); |
| 470 delimiter_position != std::string::npos; | 472 delimiter_position != std::string::npos; |
| 471 delimiter_position = current_path.find('.')) { | 473 delimiter_position = current_path.find('.')) { |
| 472 const DictionaryValue* child_dictionary = NULL; | 474 const DictionaryValue* child_dictionary = NULL; |
| 473 if (!current_dictionary->GetDictionary( | 475 if (!current_dictionary->GetDictionary( |
| 474 current_path.substr(0, delimiter_position), &child_dictionary)) | 476 current_path.substr(0, delimiter_position), &child_dictionary)) |
| 475 return false; | 477 return false; |
| 476 | 478 |
| 477 current_dictionary = child_dictionary; | 479 current_dictionary = child_dictionary; |
| 478 current_path.erase(0, delimiter_position + 1); | 480 current_path.erase(0, delimiter_position + 1); |
| 479 } | 481 } |
| 482 // LOG(WARNING) << "\n3\n"; |
| 480 | 483 |
| 481 return current_dictionary->GetWithoutPathExpansion(current_path, out_value); | 484 return current_dictionary->GetWithoutPathExpansion(current_path, out_value); |
| 482 } | 485 } |
| 483 | 486 |
| 484 bool DictionaryValue::Get(const std::string& path, Value** out_value) { | 487 bool DictionaryValue::Get(const std::string& path, Value** out_value) { |
| 485 return static_cast<const DictionaryValue&>(*this).Get( | 488 return static_cast<const DictionaryValue&>(*this).Get( |
| 486 path, | 489 path, |
| 487 const_cast<const Value**>(out_value)); | 490 const_cast<const Value**>(out_value)); |
| 488 } | 491 } |
| 489 | 492 |
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1107 | 1110 |
| 1108 std::ostream& operator<<(std::ostream& out, const Value& value) { | 1111 std::ostream& operator<<(std::ostream& out, const Value& value) { |
| 1109 std::string json; | 1112 std::string json; |
| 1110 JSONWriter::WriteWithOptions(&value, | 1113 JSONWriter::WriteWithOptions(&value, |
| 1111 JSONWriter::OPTIONS_PRETTY_PRINT, | 1114 JSONWriter::OPTIONS_PRETTY_PRINT, |
| 1112 &json); | 1115 &json); |
| 1113 return out << json; | 1116 return out << json; |
| 1114 } | 1117 } |
| 1115 | 1118 |
| 1116 } // namespace base | 1119 } // namespace base |
| OLD | NEW |