5#ifndef ASTARTE_DEVICE_SDK_OBJECT_H
6#define ASTARTE_DEVICE_SDK_OBJECT_H
16#include <initializer_list>
19#include <unordered_map>
36 using MapType = std::unordered_map<std::string, Data>;
64 auto at(
const std::string& key) ->
Data&;
74 auto at(
const std::string& key)
const ->
const Data&;
215 template <
typename ParseContext>
216 constexpr auto parse(ParseContext& ctx)
const {
227 template <
typename FormatContext>
229 auto out = ctx.out();
230 out = astarte_fmt::format_to(out,
"{{");
235 out = astarte_fmt::format_to(out,
", ");
237 out = astarte_fmt::format_to(out, R
"("{}": {})", pair.first, pair.second);
241 out = astarte_fmt::format_to(out,
"}}");
255 out << astarte_fmt::format(
"{}", data);
Represents a single Astarte data value.
Definition data.hpp:61
Astarte object class, representing the Astarte object datastream data.
Definition object.hpp:33
MapType::iterator iterator
Helper type for the iterator over the map of paths and Astarte datas.
Definition object.hpp:38
auto begin() -> iterator
Returns an iterator to the beginning of the map.
MapType::size_type size_type
Helper type for size type of the map of paths and Astarte datas.
Definition object.hpp:42
std::unordered_map< std::string, Data > MapType
Helper type for the map of paths and Astarte datas.
Definition object.hpp:36
auto end() -> iterator
Returns an iterator to the end of the map.
auto erase(const std::string &key) -> size_type
Erases elements from the map.
void clear()
Clears the contents of the map.
MapType::const_iterator const_iterator
Helper type for the const iterator over the map of paths and Astarte datas.
Definition object.hpp:40
DatastreamObject(std::initializer_list< value_type > init)
Constructs a DatastreamObject with initial content.
void insert(const std::string &key, const Data &data)
Inserts elements into the map.
auto find(const std::string &key) -> iterator
Finds an element with a specific key.
auto empty() const -> bool
Checks if the map is empty.
auto at(const std::string &key) -> Data &
Accesses the specified element with bounds checking.
DatastreamObject()
Constructs an empty DatastreamObject.
auto begin() const -> const_iterator
Returns an iterator to the beginning of the map.
auto get_raw_data() const -> const MapType &
Returns the raw data contained in this class instance.
auto size() const -> size_type
Returns the number of elements in the map.
auto at(const std::string &key) const -> const Data &
Accesses the specified element with bounds checking.
MapType::value_type value_type
Helper type for value type of the map of paths and Astarte datas.
Definition object.hpp:44
Astarte data class and its related methods.
auto operator<<(std::ostream &out, const astarte::device::Data &data) -> std::ostream &
Stream insertion operator for Data.
Definition data.hpp:243
Umbrella namespace for the Astarte device library.
Definition data.hpp:29
Namespace alias for the formatting library (std or fmt).
Definition formatter.hpp:45
Global namespace for all Astarte related functionality.
Definition data.hpp:29