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/values.h" | 7 #include "base/values.h" |
8 | 8 |
9 namespace json_schema_compiler { | 9 namespace json_schema_compiler { |
10 namespace util { | 10 namespace util { |
11 | 11 |
12 bool GetItemFromList(const base::ListValue& from, int index, int* out) { | 12 bool GetItemFromList(const base::ListValue& from, |
| 13 int index, |
| 14 ITEMS_ARE_NOT_BINARY /* binary_tag */, |
| 15 int* out) { |
13 return from.GetInteger(index, out); | 16 return from.GetInteger(index, out); |
14 } | 17 } |
15 | 18 |
16 bool GetItemFromList(const base::ListValue& from, int index, bool* out) { | 19 bool GetItemFromList(const base::ListValue& from, |
| 20 int index, |
| 21 ITEMS_ARE_NOT_BINARY /* binary_tag */, |
| 22 bool* out) { |
17 return from.GetBoolean(index, out); | 23 return from.GetBoolean(index, out); |
18 } | 24 } |
19 | 25 |
20 bool GetItemFromList(const base::ListValue& from, int index, double* out) { | 26 bool GetItemFromList(const base::ListValue& from, |
| 27 int index, |
| 28 ITEMS_ARE_NOT_BINARY /* binary_tag */, |
| 29 double* out) { |
21 return from.GetDouble(index, out); | 30 return from.GetDouble(index, out); |
22 } | 31 } |
23 | 32 |
24 bool GetItemFromList(const base::ListValue& from, int index, std::string* out) { | 33 bool GetItemFromList(const base::ListValue& from, |
| 34 int index, |
| 35 ITEMS_ARE_NOT_BINARY /* binary_tag */, |
| 36 std::string* out) { |
25 return from.GetString(index, out); | 37 return from.GetString(index, out); |
26 } | 38 } |
27 | 39 |
28 bool GetItemFromList(const base::ListValue& from, | 40 bool GetItemFromList(const base::ListValue& from, |
29 int index, | 41 int index, |
| 42 ITEMS_ARE_BINARY /* binary_tag */, |
| 43 std::string* out) { |
| 44 const base::BinaryValue* value = NULL; |
| 45 if (!from.GetBinary(index, &value)) |
| 46 return false; |
| 47 out->assign(value->GetBuffer(), value->GetSize()); |
| 48 return true; |
| 49 } |
| 50 |
| 51 bool GetItemFromList(const base::ListValue& from, |
| 52 int index, |
| 53 ITEMS_ARE_NOT_BINARY /* binary_tag */, |
30 linked_ptr<base::Value>* out) { | 54 linked_ptr<base::Value>* out) { |
31 const base::Value* value = NULL; | 55 const base::Value* value = NULL; |
32 if (!from.Get(index, &value)) | 56 if (!from.Get(index, &value)) |
33 return false; | 57 return false; |
34 *out = make_linked_ptr(value->DeepCopy()); | 58 *out = make_linked_ptr(value->DeepCopy()); |
35 return true; | 59 return true; |
36 } | 60 } |
37 | 61 |
38 bool GetItemFromList(const base::ListValue& from, int index, | 62 bool GetItemFromList(const base::ListValue& from, |
39 linked_ptr<base::DictionaryValue>* out) { | 63 int index, |
| 64 ITEMS_ARE_NOT_BINARY /* binary_tag */, |
| 65 linked_ptr<base::DictionaryValue>* out) { |
40 const base::DictionaryValue* dict = NULL; | 66 const base::DictionaryValue* dict = NULL; |
41 if (!from.GetDictionary(index, &dict)) | 67 if (!from.GetDictionary(index, &dict)) |
42 return false; | 68 return false; |
43 *out = make_linked_ptr(dict->DeepCopy()); | 69 *out = make_linked_ptr(dict->DeepCopy()); |
44 return true; | 70 return true; |
45 } | 71 } |
46 | 72 |
47 void AddItemToList(const int from, base::ListValue* out) { | 73 void AddItemToList(const int from, base::ListValue* out) { |
48 out->Append(new base::FundamentalValue(from)); | 74 out->Append(new base::FundamentalValue(from)); |
49 } | 75 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 return "dictionary"; | 114 return "dictionary"; |
89 case base::Value::TYPE_LIST: | 115 case base::Value::TYPE_LIST: |
90 return "list"; | 116 return "list"; |
91 } | 117 } |
92 NOTREACHED(); | 118 NOTREACHED(); |
93 return ""; | 119 return ""; |
94 } | 120 } |
95 | 121 |
96 } // namespace api_util | 122 } // namespace api_util |
97 } // namespace extensions | 123 } // namespace extensions |
OLD | NEW |