Lines Matching refs:Value
19 // Returns whether |value| is exactly representable by double or not.
21 bool IsExactlyRepresentableByDouble(T value) {
22 return value == static_cast<T>(static_cast<double>(value));
28 std::unique_ptr<base::Value> element_value = PopDataAsValue(reader);
52 std::unique_ptr<base::Value> key(PopDataAsValue(&entry_reader));
55 // Use JSONWriter to convert an arbitrary value to a string.
58 // Get the value and set the key-value pair.
59 std::unique_ptr<base::Value> value = PopDataAsValue(&entry_reader);
60 if (!value)
62 dictionary_value->SetWithoutPathExpansion(key_string, std::move(value));
67 // Gets the D-Bus type signature for the value.
68 std::string GetTypeSignature(const base::Value& value) {
69 switch (value.type()) {
70 case base::Value::Type::BOOLEAN:
72 case base::Value::Type::INTEGER:
74 case base::Value::Type::DOUBLE:
76 case base::Value::Type::STRING:
78 case base::Value::Type::BINARY:
80 case base::Value::Type::DICTIONARY:
82 case base::Value::Type::LIST:
85 DLOG(ERROR) << "Unexpected type " << value.type();
92 std::unique_ptr<base::Value> PopDataAsValue(MessageReader* reader) {
93 std::unique_ptr<base::Value> result;
99 uint8_t value = 0;
100 if (reader->PopByte(&value))
101 result = std::make_unique<base::Value>(value);
105 bool value = false;
106 if (reader->PopBool(&value))
107 result = std::make_unique<base::Value>(value);
111 int16_t value = 0;
112 if (reader->PopInt16(&value))
113 result = std::make_unique<base::Value>(value);
117 uint16_t value = 0;
118 if (reader->PopUint16(&value))
119 result = std::make_unique<base::Value>(value);
123 int32_t value = 0;
124 if (reader->PopInt32(&value))
125 result = std::make_unique<base::Value>(value);
129 uint32_t value = 0;
130 if (reader->PopUint32(&value)) {
131 result = std::make_unique<base::Value>(static_cast<double>(value));
136 int64_t value = 0;
137 if (reader->PopInt64(&value)) {
138 DLOG_IF(WARNING, !IsExactlyRepresentableByDouble(value)) <<
139 value << " is not exactly representable by double";
140 result = std::make_unique<base::Value>(static_cast<double>(value));
145 uint64_t value = 0;
146 if (reader->PopUint64(&value)) {
147 DLOG_IF(WARNING, !IsExactlyRepresentableByDouble(value)) <<
148 value << " is not exactly representable by double";
149 result = std::make_unique<base::Value>(static_cast<double>(value));
154 double value = 0;
155 if (reader->PopDouble(&value))
156 result = std::make_unique<base::Value>(value);
160 std::string value;
161 if (reader->PopString(&value))
162 result = std::make_unique<base::Value>(value);
166 ObjectPath value;
167 if (reader->PopObjectPath(&value))
168 result = std::make_unique<base::Value>(value.value());
217 void AppendBasicTypeValueData(MessageWriter* writer, const base::Value& value) {
218 switch (value.type()) {
219 case base::Value::Type::BOOLEAN: {
221 bool success = value.GetAsBoolean(&bool_value);
226 case base::Value::Type::INTEGER: {
228 bool success = value.GetAsInteger(&int_value);
233 case base::Value::Type::DOUBLE: {
235 bool success = value.GetAsDouble(&double_value);
240 case base::Value::Type::STRING: {
242 bool success = value.GetAsString(&string_value);
248 DLOG(ERROR) << "Unexpected type " << value.type();
254 const base::Value& value) {
256 writer->OpenVariant(GetTypeSignature(value), &sub_writer);
257 AppendBasicTypeValueData(&sub_writer, value);
261 void AppendValueData(MessageWriter* writer, const base::Value& value) {
262 switch (value.type()) {
263 case base::Value::Type::DICTIONARY: {
265 value.GetAsDictionary(&dictionary);
273 AppendValueDataAsVariant(&dict_entry_writer, iter.value());
279 case base::Value::Type::LIST: {
281 value.GetAsList(&list);
284 for (const auto& value : *list) {
285 AppendValueDataAsVariant(&array_writer, value);
290 case base::Value::Type::BOOLEAN:
291 case base::Value::Type::INTEGER:
292 case base::Value::Type::DOUBLE:
293 case base::Value::Type::STRING:
294 AppendBasicTypeValueData(writer, value);
297 DLOG(ERROR) << "Unexpected type: " << value.type();
301 void AppendValueDataAsVariant(MessageWriter* writer, const base::Value& value) {
303 writer->OpenVariant(GetTypeSignature(value), &variant_writer);
304 AppendValueData(&variant_writer, value);