| 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/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 | 10 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 62 |
| 63 bool PopulateItem(const base::Value& from, | 63 bool PopulateItem(const base::Value& from, |
| 64 std::string* out, | 64 std::string* out, |
| 65 base::string16* error) { | 65 base::string16* error) { |
| 66 if (!from.GetAsString(out)) | 66 if (!from.GetAsString(out)) |
| 67 return ReportError(from, base::Value::Type::STRING, error); | 67 return ReportError(from, base::Value::Type::STRING, error); |
| 68 return true; | 68 return true; |
| 69 } | 69 } |
| 70 | 70 |
| 71 bool PopulateItem(const base::Value& from, std::vector<char>* out) { | 71 bool PopulateItem(const base::Value& from, std::vector<char>* out) { |
| 72 const base::Value* binary = nullptr; | 72 if (!from.is_blob()) |
| 73 if (!from.GetAsBinary(&binary)) | |
| 74 return false; | 73 return false; |
| 75 *out = binary->GetBlob(); | 74 *out = from.GetBlob(); |
| 76 return true; | 75 return true; |
| 77 } | 76 } |
| 78 | 77 |
| 79 bool PopulateItem(const base::Value& from, | 78 bool PopulateItem(const base::Value& from, |
| 80 std::vector<char>* out, | 79 std::vector<char>* out, |
| 81 base::string16* error) { | 80 base::string16* error) { |
| 82 const base::Value* binary = nullptr; | 81 if (!from.is_blob()) |
| 83 if (!from.GetAsBinary(&binary)) | |
| 84 return ReportError(from, base::Value::Type::BINARY, error); | 82 return ReportError(from, base::Value::Type::BINARY, error); |
| 85 *out = binary->GetBlob(); | 83 *out = from.GetBlob(); |
| 86 return true; | 84 return true; |
| 87 } | 85 } |
| 88 | 86 |
| 89 bool PopulateItem(const base::Value& from, std::unique_ptr<base::Value>* out) { | 87 bool PopulateItem(const base::Value& from, std::unique_ptr<base::Value>* out) { |
| 90 *out = from.CreateDeepCopy(); | 88 *out = from.CreateDeepCopy(); |
| 91 return true; | 89 return true; |
| 92 } | 90 } |
| 93 | 91 |
| 94 bool PopulateItem(const base::Value& from, | 92 bool PopulateItem(const base::Value& from, |
| 95 std::unique_ptr<base::Value>* out, | 93 std::unique_ptr<base::Value>* out, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 out->Append(from->CreateDeepCopy()); | 140 out->Append(from->CreateDeepCopy()); |
| 143 } | 141 } |
| 144 | 142 |
| 145 void AddItemToList(const std::unique_ptr<base::DictionaryValue>& from, | 143 void AddItemToList(const std::unique_ptr<base::DictionaryValue>& from, |
| 146 base::ListValue* out) { | 144 base::ListValue* out) { |
| 147 out->Append(from->CreateDeepCopy()); | 145 out->Append(from->CreateDeepCopy()); |
| 148 } | 146 } |
| 149 | 147 |
| 150 } // namespace util | 148 } // namespace util |
| 151 } // namespace json_schema_compiler | 149 } // namespace json_schema_compiler |
| OLD | NEW |