• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #ifndef DBUS_VALUES_UTIL_H_
6 #define DBUS_VALUES_UTIL_H_
7 
8 #include <stdint.h>
9 
10 #include <memory>
11 
12 #include "dbus/dbus_export.h"
13 
14 namespace base {
15 class Value;
16 }
17 
18 namespace dbus {
19 
20 class MessageReader;
21 class MessageWriter;
22 
23 // Pops a value from |reader| as a base::Value.
24 // Returns NULL if an error occurs.
25 // Note: Integer values larger than int32_t (including uint32_t) are converted
26 // to double.  Non-string dictionary keys are converted to strings.
27 CHROME_DBUS_EXPORT std::unique_ptr<base::Value> PopDataAsValue(
28     MessageReader* reader);
29 
30 // Appends a basic type value to |writer|. Basic types are BOOLEAN, INTEGER,
31 // DOUBLE, and STRING. Use this function for values that are known to be basic
32 // types and to handle basic type members of collections that should not
33 // have type "a{sv}" or "av". Otherwise, use AppendValueData.
34 CHROME_DBUS_EXPORT void AppendBasicTypeValueData(MessageWriter* writer,
35                                                  const base::Value& value);
36 
37 // Appends a basic type value to |writer| as a variant. Basic types are BOOLEAN,
38 // INTEGER, DOUBLE, and STRING. Use this function for values that are known to
39 // be basic types and to handle basic type members of collections that should
40 // not have type "a{sv}" or "av". Otherwise, use AppendValueDataAsVariant.
41 CHROME_DBUS_EXPORT void AppendBasicTypeValueDataAsVariant(
42     MessageWriter* writer,
43     const base::Value& value);
44 
45 // Appends a value to |writer|. Value can be a basic type, as well as a
46 // collection type, such as dictionary or list. Collections will be recursively
47 // written as variant containers, i.e. dictionaries will be written with type
48 // a{sv} and lists with type av. Any sub-dictionaries or sub-lists will also
49 // have these types.
50 CHROME_DBUS_EXPORT void AppendValueData(MessageWriter* writer,
51                                         const base::Value& value);
52 
53 // Appends a value to |writer| as a variant. Value can be a basic type, as well
54 // as a collection type, such as dictionary or list. Collections will be
55 // recursively written as variant containers, i.e. dictionaries will be written
56 // with type a{sv} and lists with type av. Any sub-dictionaries or sub-lists
57 // will also have these types.
58 CHROME_DBUS_EXPORT void AppendValueDataAsVariant(MessageWriter* writer,
59                                                  const base::Value& value);
60 
61 }  // namespace dbus
62 
63 #endif  // DBUS_VALUES_UTIL_H_
64