Chromium Code Reviews| Index: device/bluetooth/bluez/bluetooth_service_attribute_value_bluez.h |
| diff --git a/device/bluetooth/bluez/bluetooth_service_attribute_value_bluez.h b/device/bluetooth/bluez/bluetooth_service_attribute_value_bluez.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..402475fc950b99365f57db8797063f191bf53c21 |
| --- /dev/null |
| +++ b/device/bluetooth/bluez/bluetooth_service_attribute_value_bluez.h |
| @@ -0,0 +1,55 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_SERVICE_ATTRIBUTE_VALUE_BLUEZ_H_ |
| +#define DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_SERVICE_ATTRIBUTE_VALUE_BLUEZ_H_ |
| + |
| +#include <cstddef> |
| +#include <memory> |
| +#include <vector> |
| + |
| +#include "base/values.h" |
| +#include "device/bluetooth/bluetooth_export.h" |
| + |
| +namespace bluez { |
| + |
| +// This class contains a Bluetooth service attribute. A service attribute is |
| +// defined by the following fields, |
| +// type: This is the type of the attribute. Along with being any of the |
| +// fixed types, an attribute can also be of type sequence, which means |
| +// that it contains an array of other attributes. |
| +// size: This is the size of the attribute. This can be variable for each type. |
| +// For example, a UUID can have the sizes, 2, 4 or 16 bytes. |
| +// value: This is the raw value of the attribute. For example, for a UUID, it |
| +// will be the string representation of the UUID. For a sequence, it |
| +// will be an array of other attributes. |
| +class DEVICE_BLUETOOTH_EXPORT BluetoothServiceAttributeValueBlueZ { |
| + public: |
| + enum Type { NULLTYPE, UINT, INT, UUID, STRING, BOOL, SEQUENCE, URL }; |
| + |
| + using Sequence = std::vector<BluetoothServiceAttributeValueBlueZ>; |
| + |
| + BluetoothServiceAttributeValueBlueZ(Type type, |
| + size_t size, |
| + std::unique_ptr<base::Value> value); |
| + BluetoothServiceAttributeValueBlueZ(std::unique_ptr<Sequence> sequence); |
| + BluetoothServiceAttributeValueBlueZ( |
| + const BluetoothServiceAttributeValueBlueZ& attribute); |
| + ~BluetoothServiceAttributeValueBlueZ(); |
| + |
| + Type type() const { return type_; } |
| + size_t size() const { return size_; } |
| + const Sequence& sequence() const { return *sequence_.get(); } |
| + 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
|
| + |
| + private: |
| + Type type_; |
| + size_t size_; |
| + std::unique_ptr<base::Value> value_; |
| + std::unique_ptr<Sequence> sequence_; |
| +}; |
| + |
| +} // namespace bluez |
| + |
| +#endif // DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_SERVICE_ATTRIBUTE_VALUE_BLUEZ_H_ |