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

Side by Side Diff: third_party/libaddressinput/chromium/json.cc

Issue 2232743003: third_party/libaddressinput: Use stl utilities from the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months 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 unified diff | Download patch
« no previous file with comments | « third_party/libaddressinput/chromium/chrome_metadata_source.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "third_party/libaddressinput/src/cpp/src/util/json.h" 5 #include "third_party/libaddressinput/src/cpp/src/util/json.h"
6 6
7 #include <map> 7 #include <map>
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 } // namespace 42 } // namespace
43 43
44 // Implementation of JSON parser for libaddressinput using JSON parser in 44 // Implementation of JSON parser for libaddressinput using JSON parser in
45 // Chrome. 45 // Chrome.
46 class Json::JsonImpl { 46 class Json::JsonImpl {
47 public: 47 public:
48 explicit JsonImpl(const std::string& json) 48 explicit JsonImpl(const std::string& json)
49 : owned_(Parse(json, &parser_error_)), 49 : owned_(Parse(json, &parser_error_)),
50 dict_(*owned_) {} 50 dict_(*owned_) {}
51 51
52 ~JsonImpl() { STLDeleteElements(&sub_dicts_); } 52 ~JsonImpl() { base::STLDeleteElements(&sub_dicts_); }
53 53
54 bool parser_error() const { return parser_error_; } 54 bool parser_error() const { return parser_error_; }
55 55
56 const std::vector<const Json*>& GetSubDictionaries() { 56 const std::vector<const Json*>& GetSubDictionaries() {
57 if (sub_dicts_.empty()) { 57 if (sub_dicts_.empty()) {
58 for (base::DictionaryValue::Iterator it(dict_); !it.IsAtEnd(); 58 for (base::DictionaryValue::Iterator it(dict_); !it.IsAtEnd();
59 it.Advance()) { 59 it.Advance()) {
60 if (it.value().IsType(base::Value::TYPE_DICTIONARY)) { 60 if (it.value().IsType(base::Value::TYPE_DICTIONARY)) {
61 const base::DictionaryValue* sub_dict = NULL; 61 const base::DictionaryValue* sub_dict = NULL;
62 it.value().GetAsDictionary(&sub_dict); 62 it.value().GetAsDictionary(&sub_dict);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 bool Json::GetStringValueForKey(const std::string& key, 102 bool Json::GetStringValueForKey(const std::string& key,
103 std::string* value) const { 103 std::string* value) const {
104 return impl_->GetStringValueForKey(key, value); 104 return impl_->GetStringValueForKey(key, value);
105 } 105 }
106 106
107 Json::Json(JsonImpl* impl) : impl_(impl) {} 107 Json::Json(JsonImpl* impl) : impl_(impl) {}
108 108
109 } // namespace addressinput 109 } // namespace addressinput
110 } // namespace i18n 110 } // namespace i18n
OLDNEW
« no previous file with comments | « third_party/libaddressinput/chromium/chrome_metadata_source.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698