Home | History | Annotate | Download | only in dbus

Lines Matching refs:Value

17 // Returns whether |value| is exactly representable by double or not.
19 bool IsExactlyRepresentableByDouble(T value) {
20 return value == static_cast<T>(static_cast<double>(value));
26 base::Value* element_value = PopDataAsValue(reader);
50 scoped_ptr<base::Value> key(PopDataAsValue(&entry_reader));
53 // Use JSONWriter to convert an arbitrary value to a string.
56 // Get the value and set the key-value pair.
57 base::Value* value = PopDataAsValue(&entry_reader);
58 if (!value)
60 dictionary_value->SetWithoutPathExpansion(key_string, value);
65 // Gets the D-Bus type signature for the value.
66 std::string GetTypeSignature(const base::Value& value) {
67 switch (value.GetType()) {
68 case base::Value::TYPE_BOOLEAN:
70 case base::Value::TYPE_INTEGER:
72 case base::Value::TYPE_DOUBLE:
74 case base::Value::TYPE_STRING:
76 case base::Value::TYPE_BINARY:
78 case base::Value::TYPE_DICTIONARY:
80 case base::Value::TYPE_LIST:
83 DLOG(ERROR) << "Unexpected type " << value.GetType();
90 base::Value* PopDataAsValue(MessageReader* reader) {
91 base::Value* result = NULL;
97 uint8_t value = 0;
98 if (reader->PopByte(&value))
99 result = new base::FundamentalValue(value);
103 bool value = false;
104 if (reader->PopBool(&value))
105 result = new base::FundamentalValue(value);
109 int16_t value = 0;
110 if (reader->PopInt16(&value))
111 result = new base::FundamentalValue(value);
115 uint16_t value = 0;
116 if (reader->PopUint16(&value))
117 result = new base::FundamentalValue(value);
121 int32_t value = 0;
122 if (reader->PopInt32(&value))
123 result = new base::FundamentalValue(value);
127 uint32_t value = 0;
128 if (reader->PopUint32(&value))
129 result = new base::FundamentalValue(static_cast<double>(value));
133 int64_t value = 0;
134 if (reader->PopInt64(&value)) {
135 DLOG_IF(WARNING, !IsExactlyRepresentableByDouble(value)) <<
136 value << " is not exactly representable by double";
137 result = new base::FundamentalValue(static_cast<double>(value));
142 uint64_t value = 0;
143 if (reader->PopUint64(&value)) {
144 DLOG_IF(WARNING, !IsExactlyRepresentableByDouble(value)) <<
145 value << " is not exactly representable by double";
146 result = new base::FundamentalValue(static_cast<double>(value));
151 double value = 0;
152 if (reader->PopDouble(&value))
153 result = new base::FundamentalValue(value);
157 std::string value;
158 if (reader->PopString(&value))
159 result = new base::StringValue(value);
163 ObjectPath value;
164 if (reader->PopObjectPath(&value))
165 result = new base::StringValue(value.value());
214 void AppendBasicTypeValueData(MessageWriter* writer, const base::Value& value) {
215 switch (value.GetType()) {
216 case base::Value::TYPE_BOOLEAN: {
218 bool success = value.GetAsBoolean(&bool_value);
223 case base::Value::TYPE_INTEGER: {
225 bool success = value.GetAsInteger(&int_value);
230 case base::Value::TYPE_DOUBLE: {
232 bool success = value.GetAsDouble(&double_value);
237 case base::Value::TYPE_STRING: {
239 bool success = value.GetAsString(&string_value);
245 DLOG(ERROR) << "Unexpected type " << value.GetType();
251 const base::Value& value) {
253 writer->OpenVariant(GetTypeSignature(value), &sub_writer);
254 AppendBasicTypeValueData(&sub_writer, value);
258 void AppendValueData(MessageWriter* writer, const base::Value& value) {
259 switch (value.GetType()) {
260 case base::Value::TYPE_DICTIONARY: {
262 value.GetAsDictionary(&dictionary);
270 AppendValueDataAsVariant(&dict_entry_writer, iter.value());
276 case base::Value::TYPE_LIST: {
278 value.GetAsList(&list);
283 const base::Value* value = *iter;
284 AppendValueDataAsVariant(&array_writer, *value);
289 case base::Value::TYPE_BOOLEAN:
290 case base::Value::TYPE_INTEGER:
291 case base::Value::TYPE_DOUBLE:
292 case base::Value::TYPE_STRING:
293 AppendBasicTypeValueData(writer, value);
296 DLOG(ERROR) << "Unexpected type: " << value.GetType();
300 void AppendValueDataAsVariant(MessageWriter* writer, const base::Value& value) {
302 writer->OpenVariant(GetTypeSignature(value), &variant_writer);
303 AppendValueData(&variant_writer, value);