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