diff options
author | armansito@chromium.org <armansito@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-22 11:52:55 +0000 |
---|---|---|
committer | armansito@chromium.org <armansito@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-22 11:52:55 +0000 |
commit | a68242f419e2ef9a5167dc59c2caf64c28aee530 (patch) | |
tree | a47aae5ddcdd0bc91205f1c19fa991a5d9db45fd /dbus/values_util.h | |
parent | 9c497f14121c6ee2aed0ea9edfbf73e7faa455be (diff) | |
download | chromium_src-a68242f419e2ef9a5167dc59c2caf64c28aee530.zip chromium_src-a68242f419e2ef9a5167dc59c2caf64c28aee530.tar.gz chromium_src-a68242f419e2ef9a5167dc59c2caf64c28aee530.tar.bz2 |
dbus/values_util.h: Add functions to append collection type values to message.
Added functions AppendValueData and AppendValueDataAsVariant to values_util.h.
These functions are useful for writing both basic types and variant lists and
dictionaries to a message writer. Lists and dictionaries are written with type
"av" and "a{sv}", respectively.
BUG=359413
TEST=dbus_unittests,chromeos_unittests
Review URL: https://codereview.chromium.org/221393004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272167 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'dbus/values_util.h')
-rw-r--r-- | dbus/values_util.h | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/dbus/values_util.h b/dbus/values_util.h index e34c7a0..9ece9b9 100644 --- a/dbus/values_util.h +++ b/dbus/values_util.h @@ -22,15 +22,37 @@ class MessageWriter; // double. Non-string diciontary keys are converted to strings. CHROME_DBUS_EXPORT base::Value* PopDataAsValue(MessageReader* reader); -// Appends a basic type value to |writer|. +// Appends a basic type value to |writer|. Basic types are BOOLEAN, INTEGER, +// DOUBLE, and STRING. Use this function for values that are known to be basic +// types and to handle basic type members of collections that should not +// have type "a{sv}" or "av". Otherwise, use AppendValueData. CHROME_DBUS_EXPORT void AppendBasicTypeValueData(MessageWriter* writer, const base::Value& value); -// Appends a basic type value to |writer| as a variant. +// Appends a basic type value to |writer| as a variant. Basic types are BOOLEAN, +// INTEGER, DOUBLE, and STRING. Use this function for values that are known to +// be basic types and to handle basic type members of collections that should +// not have type "a{sv}" or "av". Otherwise, use AppendValueDataAsVariant. CHROME_DBUS_EXPORT void AppendBasicTypeValueDataAsVariant( MessageWriter* writer, const base::Value& value); +// Appends a value to |writer|. Value can be a basic type, as well as a +// collection type, such as dictionary or list. Collections will be recursively +// written as variant containers, i.e. dictionaries will be written with type +// a{sv} and lists with type av. Any sub-dictionaries or sub-lists will also +// have these types. +CHROME_DBUS_EXPORT void AppendValueData(MessageWriter* writer, + const base::Value& value); + +// Appends a value to |writer| as a variant. Value can be a basic type, as well +// as a collection type, such as dictionary or list. Collections will be +// recursively written as variant containers, i.e. dictionaries will be written +// with type a{sv} and lists with type av. Any sub-dictionaries or sub-lists +// will also have these types. +CHROME_DBUS_EXPORT void AppendValueDataAsVariant(MessageWriter* writer, + const base::Value& value); + } // namespace dbus #endif // DBUS_VALUES_UTIL_H_ |