Astarte data class, representing the basic Astarte types.
More...
#include <data.hpp>
|
| template<AstarteDataAllowedType T> |
| | AstarteData (T value) |
| | Constructor for the AstarteData class.
|
| |
| template<AstarteDataAllowedType T> |
| auto | into () const -> std::conditional_t< std::is_same_v< T, std::string_view >, std::string_view, const T & > |
| | Convert the Astarte data class to the appropriate data type.
|
| |
| template<AstarteDataAllowedType T> |
| auto | try_into () const -> std::optional< T > |
| | Convert the Astarte data class to the given type if it's the correct variant.
|
| |
| auto | get_type () const -> AstarteType |
| | Get the type of the data contained in this class instance.
|
| |
| auto | get_raw_data () const -> const std::variant< int32_t, int64_t, double, bool, std::string, std::vector< uint8_t >, std::chrono::system_clock::time_point, std::vector< int32_t >, std::vector< int64_t >, std::vector< double >, std::vector< bool >, std::vector< std::string >, std::vector< std::vector< uint8_t > >, std::vector< std::chrono::system_clock::time_point > > & |
| | Return the raw data contained in this class instance.
|
| |
| auto | operator== (const AstarteData &other) const -> bool |
| | Overloader for the comparison operator ==.
|
| |
| auto | operator!= (const AstarteData &other) const -> bool |
| | Overloader for the comparison operator !=.
|
| |
Astarte data class, representing the basic Astarte types.
◆ AstarteData()
template<AstarteDataAllowedType T>
| AstarteDeviceSdk::AstarteData::AstarteData |
( |
T | value | ) |
|
|
inlineexplicit |
Constructor for the AstarteData class.
- Note
- About string views. By design an AstarteData object is intended to encapsulate data without relying on the lifetime of its inputs. As such passing a string_view to the constructor will result in the creation of a new internal std::string object that will contain a copy of the input string.
- Parameters
-
| value | The content of the Astarte data instance. |
◆ get_raw_data()
| auto AstarteDeviceSdk::AstarteData::get_raw_data |
( |
| ) |
const -> const std::variant< int32_t, int64_t, double, bool, std::string, std::vector< uint8_t >, std::chrono::system_clock::time_point, std::vector< int32_t >, std::vector< int64_t >, std::vector< double >, std::vector< bool >, std::vector< std::string >, std::vector< std::vector< uint8_t > >, std::vector< std::chrono::system_clock::time_point > > & |
|
nodiscard |
Return the raw data contained in this class instance.
- Returns
- The raw data contained in this class instance. This is a variant containing one of the possible data types.
◆ get_type()
| auto AstarteDeviceSdk::AstarteData::get_type |
( |
| ) |
const -> AstarteType |
|
nodiscard |
Get the type of the data contained in this class instance.
- Returns
- The type of the content of this class instance.
◆ into()
template<AstarteDataAllowedType T>
| auto AstarteDeviceSdk::AstarteData::into |
( |
| ) |
const -> std::conditional_t<std::is_same_v<T, std::string_view>, std::string_view, const T&> |
|
inlinenodiscard |
Convert the Astarte data class to the appropriate data type.
- Returns
- The value contained in the class instance.
◆ operator!=()
| auto AstarteDeviceSdk::AstarteData::operator!= |
( |
const AstarteData & | other | ) |
const -> bool |
|
nodiscard |
Overloader for the comparison operator !=.
- Parameters
-
| other | The object to compare to. |
- Returns
- True when different, false otherwise.
◆ operator==()
| auto AstarteDeviceSdk::AstarteData::operator== |
( |
const AstarteData & | other | ) |
const -> bool |
|
nodiscard |
Overloader for the comparison operator ==.
- Parameters
-
| other | The object to compare to. |
- Returns
- True when equal, false otherwise.
◆ try_into()
template<AstarteDataAllowedType T>
| auto AstarteDeviceSdk::AstarteData::try_into |
( |
| ) |
const -> std::optional<T> |
|
inlinenodiscard |
Convert the Astarte data class to the given type if it's the correct variant.
- Returns
- The value contained in the class instance or nullopt.
The documentation for this class was generated from the following file:
- /home/runner/work/astarte-device-sdk-cpp/astarte-device-sdk-cpp/astarte-device-sdk-cpp/include/astarte_device_sdk/data.hpp