Fix emulator build error
[platform/framework/web/chromium-efl.git] / base / json / json_value_converter.cc
1 // Copyright 2014 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/json/json_value_converter.h"
6
7 #include "base/strings/utf_string_conversions.h"
8
9 namespace base {
10 namespace internal {
11
12 bool BasicValueConverter<int>::Convert(
13     const base::Value& value, int* field) const {
14   if (!value.is_int())
15     return false;
16   if (field)
17     *field = value.GetInt();
18   return true;
19 }
20
21 bool BasicValueConverter<std::string>::Convert(
22     const base::Value& value, std::string* field) const {
23   if (!value.is_string())
24     return false;
25   if (field)
26     *field = value.GetString();
27   return true;
28 }
29
30 bool BasicValueConverter<std::u16string>::Convert(const base::Value& value,
31                                                   std::u16string* field) const {
32   if (!value.is_string())
33     return false;
34   if (field)
35     *field = base::UTF8ToUTF16(value.GetString());
36   return true;
37 }
38
39 bool BasicValueConverter<double>::Convert(
40     const base::Value& value, double* field) const {
41   if (!value.is_double() && !value.is_int())
42     return false;
43   if (field)
44     *field = value.GetDouble();
45   return true;
46 }
47
48 bool BasicValueConverter<bool>::Convert(
49     const base::Value& value, bool* field) const {
50   if (!value.is_bool())
51     return false;
52   if (field)
53     *field = value.GetBool();
54   return true;
55 }
56
57 }  // namespace internal
58 }  // namespace base
59