Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 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 | |
| 5 #ifndef DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_SERVICE_ATTRIBUTE_VALUE_BLUEZ_H_ | |
| 6 #define DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_SERVICE_ATTRIBUTE_VALUE_BLUEZ_H_ | |
| 7 | |
| 8 #include <cstddef> | |
| 9 #include <memory> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/values.h" | |
| 13 #include "device/bluetooth/bluetooth_export.h" | |
| 14 | |
| 15 namespace bluez { | |
| 16 | |
| 17 // This class contains a Bluetooth service attribute. A service attribute is | |
| 18 // defined by the following fields, | |
| 19 // type: This is the type of the attribute. Along with being any of the | |
| 20 // fixed types, an attribute can also be of type sequence, which means | |
| 21 // that it contains an array of other attributes. | |
| 22 // size: This is the size of the attribute. This can be variable for each type. | |
| 23 // For example, a UUID can have the sizes, 2, 4 or 16 bytes. | |
| 24 // value: This is the raw value of the attribute. For example, for a UUID, it | |
| 25 // will be the string representation of the UUID. For a sequence, it | |
| 26 // will be an array of other attributes. | |
| 27 class DEVICE_BLUETOOTH_EXPORT BluetoothServiceAttributeValueBlueZ { | |
| 28 public: | |
| 29 enum Type { NULLTYPE, UINT, INT, UUID, STRING, BOOL, SEQUENCE, URL }; | |
| 30 | |
| 31 using Sequence = std::vector<BluetoothServiceAttributeValueBlueZ>; | |
| 32 | |
| 33 BluetoothServiceAttributeValueBlueZ(Type type, | |
| 34 size_t size, | |
| 35 std::unique_ptr<base::Value> value); | |
| 36 BluetoothServiceAttributeValueBlueZ(std::unique_ptr<Sequence> sequence); | |
| 37 BluetoothServiceAttributeValueBlueZ( | |
| 38 const BluetoothServiceAttributeValueBlueZ& attribute); | |
| 39 ~BluetoothServiceAttributeValueBlueZ(); | |
| 40 | |
| 41 Type type() const { return type_; } | |
| 42 size_t size() const { return size_; } | |
| 43 const Sequence& sequence() const { return *sequence_.get(); } | |
| 44 const base::Value& value() const { return *value_.get(); } | |
|
Miao
2016/06/23 10:49:05
I am working on the type conversion currently, and
rkc
2016/06/23 19:55:43
Integer types should be stored as UInt32, UUID and
| |
| 45 | |
| 46 private: | |
| 47 Type type_; | |
| 48 size_t size_; | |
| 49 std::unique_ptr<base::Value> value_; | |
| 50 std::unique_ptr<Sequence> sequence_; | |
| 51 }; | |
| 52 | |
| 53 } // namespace bluez | |
| 54 | |
| 55 #endif // DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_SERVICE_ATTRIBUTE_VALUE_BLUEZ_H_ | |
| OLD | NEW |