values_util.h 2.5 KB

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