blob: 9ece9b9be55b6b82b52be2ded864672b81ea7fbb [file] [log] [blame]
hashimoto@chromium.org8fb5a2b2012-03-17 08:08:42 +09001// 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_
hashimoto@chromium.org8fb5a2b2012-03-17 08:08:42 +09007
tfarina@chromium.org7928ea22012-11-05 10:56:14 +09008#include "dbus/dbus_export.h"
9
hashimoto@chromium.org8fb5a2b2012-03-17 08:08:42 +090010namespace base {
11class Value;
12}
13
14namespace dbus {
15
16class MessageReader;
hashimoto@chromium.orgea599822012-03-25 05:37:18 +090017class MessageWriter;
hashimoto@chromium.org8fb5a2b2012-03-17 08:08:42 +090018
19// Pops a value from |reader| as a base::Value.
20// Returns NULL if an error occurs.
21// Note: Integer values larger than int32 (including uint32) are converted to
22// double. Non-string diciontary keys are converted to strings.
tfarina@chromium.org7928ea22012-11-05 10:56:14 +090023CHROME_DBUS_EXPORT base::Value* PopDataAsValue(MessageReader* reader);
hashimoto@chromium.org8fb5a2b2012-03-17 08:08:42 +090024
armansito@chromium.org39d51b92014-05-22 20:52:55 +090025// Appends a basic type value to |writer|. Basic types are BOOLEAN, INTEGER,
26// DOUBLE, and STRING. Use this function for values that are known to be basic
27// types and to handle basic type members of collections that should not
28// have type "a{sv}" or "av". Otherwise, use AppendValueData.
tfarina@chromium.org7928ea22012-11-05 10:56:14 +090029CHROME_DBUS_EXPORT void AppendBasicTypeValueData(MessageWriter* writer,
30 const base::Value& value);
hashimoto@chromium.orgea599822012-03-25 05:37:18 +090031
armansito@chromium.org39d51b92014-05-22 20:52:55 +090032// Appends a basic type value to |writer| as a variant. Basic types are BOOLEAN,
33// INTEGER, DOUBLE, and STRING. Use this function for values that are known to
34// be basic types and to handle basic type members of collections that should
35// not have type "a{sv}" or "av". Otherwise, use AppendValueDataAsVariant.
tfarina@chromium.org7928ea22012-11-05 10:56:14 +090036CHROME_DBUS_EXPORT void AppendBasicTypeValueDataAsVariant(
37 MessageWriter* writer,
38 const base::Value& value);
hashimoto@chromium.orgea599822012-03-25 05:37:18 +090039
armansito@chromium.org39d51b92014-05-22 20:52:55 +090040// Appends a value to |writer|. Value can be a basic type, as well as a
41// collection type, such as dictionary or list. Collections will be recursively
42// written as variant containers, i.e. dictionaries will be written with type
43// a{sv} and lists with type av. Any sub-dictionaries or sub-lists will also
44// have these types.
45CHROME_DBUS_EXPORT void AppendValueData(MessageWriter* writer,
46 const base::Value& value);
47
48// Appends a value to |writer| as a variant. Value can be a basic type, as well
49// as a collection type, such as dictionary or list. Collections will be
50// recursively written as variant containers, i.e. dictionaries will be written
51// with type a{sv} and lists with type av. Any sub-dictionaries or sub-lists
52// will also have these types.
53CHROME_DBUS_EXPORT void AppendValueDataAsVariant(MessageWriter* writer,
54 const base::Value& value);
55
hashimoto@chromium.org8fb5a2b2012-03-17 08:08:42 +090056} // namespace dbus
57
58#endif // DBUS_VALUES_UTIL_H_