| Index: dbus/property.cc
|
| diff --git a/dbus/property.cc b/dbus/property.cc
|
| index 9475a0728a6cca7e4de360caa10333593a4bda44..0e912f34daa20ec377b04ed7f302b61d6f58b242 100644
|
| --- a/dbus/property.cc
|
| +++ b/dbus/property.cc
|
| @@ -478,6 +478,103 @@ void Property<std::vector<uint8> >::AppendSetValueToWriter(
|
| writer->CloseContainer(&variant_writer);
|
| }
|
|
|
| +//
|
| +// Property<std::map<std::string, std::string>> specialization.
|
| +//
|
| +
|
| +template <>
|
| +bool Property<std::map<std::string, std::string>>::PopValueFromReader(
|
| + MessageReader* reader) {
|
| + MessageReader variant_reader(NULL);
|
| + MessageReader array_reader(NULL);
|
| + if (!reader->PopVariant(&variant_reader) ||
|
| + !variant_reader.PopArray(&array_reader))
|
| + return false;
|
| + value_.clear();
|
| + while (array_reader.HasMoreData()) {
|
| + dbus::MessageReader dict_entry_reader(NULL);
|
| + if (!array_reader.PopDictEntry(&dict_entry_reader))
|
| + return false;
|
| + std::string key;
|
| + std::string value;
|
| + if (!dict_entry_reader.PopString(&key) ||
|
| + !dict_entry_reader.PopString(&value))
|
| + return false;
|
| + value_[key] = value;
|
| + }
|
| + return true;
|
| +}
|
| +
|
| +template <>
|
| +void Property<std::map<std::string, std::string>>::AppendSetValueToWriter(
|
| + MessageWriter* writer) {
|
| + MessageWriter variant_writer(NULL);
|
| + MessageWriter dict_writer(NULL);
|
| + writer->OpenVariant("a{ss}", &variant_writer);
|
| + variant_writer.OpenArray("{ss}", &dict_writer);
|
| + for (const auto& pair : set_value_) {
|
| + dbus::MessageWriter entry_writer(NULL);
|
| + dict_writer.OpenDictEntry(&entry_writer);
|
| + entry_writer.AppendString(pair.first);
|
| + entry_writer.AppendString(pair.second);
|
| + dict_writer.CloseContainer(&entry_writer);
|
| + }
|
| + variant_writer.CloseContainer(&dict_writer);
|
| + writer->CloseContainer(&variant_writer);
|
| +}
|
| +
|
| +//
|
| +// Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>
|
| +// specialization.
|
| +//
|
| +
|
| +template <>
|
| +bool Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>::
|
| + PopValueFromReader(MessageReader* reader) {
|
| + MessageReader variant_reader(NULL);
|
| + MessageReader array_reader(NULL);
|
| + if (!reader->PopVariant(&variant_reader) ||
|
| + !variant_reader.PopArray(&array_reader))
|
| + return false;
|
| +
|
| + value_.clear();
|
| + while (array_reader.HasMoreData()) {
|
| + dbus::MessageReader struct_reader(NULL);
|
| + if (!array_reader.PopStruct(&struct_reader))
|
| + return false;
|
| +
|
| + std::pair<std::vector<uint8_t>, uint16_t> entry;
|
| + const uint8* bytes = NULL;
|
| + size_t length = 0;
|
| + if (!struct_reader.PopArrayOfBytes(&bytes, &length))
|
| + return false;
|
| + entry.first.assign(bytes, bytes + length);
|
| + if (!struct_reader.PopUint16(&entry.second))
|
| + return false;
|
| + value_.push_back(entry);
|
| + }
|
| + return true;
|
| +}
|
| +
|
| +template <>
|
| +void Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>::
|
| + AppendSetValueToWriter(MessageWriter* writer) {
|
| + MessageWriter variant_writer(NULL);
|
| + MessageWriter array_writer(NULL);
|
| + writer->OpenVariant("a(ayq)", &variant_writer);
|
| + variant_writer.OpenArray("(ayq)", &array_writer);
|
| + for (const auto& pair : set_value_) {
|
| + dbus::MessageWriter struct_writer(nullptr);
|
| + array_writer.OpenStruct(&struct_writer);
|
| + struct_writer.AppendArrayOfBytes(std::get<0>(pair).data(),
|
| + std::get<0>(pair).size());
|
| + struct_writer.AppendUint16(std::get<1>(pair));
|
| + array_writer.CloseContainer(&struct_writer);
|
| + }
|
| + variant_writer.CloseContainer(&array_writer);
|
| + writer->CloseContainer(&variant_writer);
|
| +}
|
| +
|
| template class Property<uint8>;
|
| template class Property<bool>;
|
| template class Property<int16>;
|
| @@ -492,5 +589,7 @@ template class Property<ObjectPath>;
|
| template class Property<std::vector<std::string> >;
|
| template class Property<std::vector<ObjectPath> >;
|
| template class Property<std::vector<uint8> >;
|
| +template class Property<std::map<std::string, std::string>>;
|
| +template class Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>;
|
|
|
| } // namespace dbus
|
|
|