| 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 "tools/json_schema_compiler/util.h" | 5 #include "tools/json_schema_compiler/util.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | |
| 8 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/values.h" | 8 #include "base/values.h" |
| 10 | 9 |
| 11 namespace json_schema_compiler { | 10 namespace json_schema_compiler { |
| 12 namespace util { | 11 namespace util { |
| 13 | 12 |
| 14 bool PopulateItem(const base::Value& from, int* out) { | 13 bool PopulateItem(const base::Value& from, int* out) { |
| 15 return from.GetAsInteger(out); | 14 return from.GetAsInteger(out); |
| 16 } | 15 } |
| 17 | 16 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 147 |
| 149 void AddItemToList(const double from, base::ListValue* out) { | 148 void AddItemToList(const double from, base::ListValue* out) { |
| 150 out->Append(new base::FundamentalValue(from)); | 149 out->Append(new base::FundamentalValue(from)); |
| 151 } | 150 } |
| 152 | 151 |
| 153 void AddItemToList(const std::string& from, base::ListValue* out) { | 152 void AddItemToList(const std::string& from, base::ListValue* out) { |
| 154 out->Append(new base::StringValue(from)); | 153 out->Append(new base::StringValue(from)); |
| 155 } | 154 } |
| 156 | 155 |
| 157 void AddItemToList(const std::vector<char>& from, base::ListValue* out) { | 156 void AddItemToList(const std::vector<char>& from, base::ListValue* out) { |
| 158 out->Append(base::BinaryValue::CreateWithCopiedBuffer(vector_as_array(&from), | 157 out->Append( |
| 159 from.size())); | 158 base::BinaryValue::CreateWithCopiedBuffer(from.data(), from.size())); |
| 160 } | 159 } |
| 161 | 160 |
| 162 void AddItemToList(const linked_ptr<base::Value>& from, base::ListValue* out) { | 161 void AddItemToList(const linked_ptr<base::Value>& from, base::ListValue* out) { |
| 163 out->Append(from->DeepCopy()); | 162 out->Append(from->DeepCopy()); |
| 164 } | 163 } |
| 165 | 164 |
| 166 void AddItemToList(const linked_ptr<base::DictionaryValue>& from, | 165 void AddItemToList(const linked_ptr<base::DictionaryValue>& from, |
| 167 base::ListValue* out) { | 166 base::ListValue* out) { |
| 168 out->Append(static_cast<base::Value*>(from->DeepCopy())); | 167 out->Append(static_cast<base::Value*>(from->DeepCopy())); |
| 169 } | 168 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 186 return "dictionary"; | 185 return "dictionary"; |
| 187 case base::Value::TYPE_LIST: | 186 case base::Value::TYPE_LIST: |
| 188 return "list"; | 187 return "list"; |
| 189 } | 188 } |
| 190 NOTREACHED(); | 189 NOTREACHED(); |
| 191 return ""; | 190 return ""; |
| 192 } | 191 } |
| 193 | 192 |
| 194 } // namespace util | 193 } // namespace util |
| 195 } // namespace json_schema_compiler | 194 } // namespace json_schema_compiler |
| OLD | NEW |