Astarte device API for C++ 0.8.1
Astarte device SDK for C++
Loading...
Searching...
No Matches
object.hpp
Go to the documentation of this file.
1// (C) Copyright 2025, SECO Mind Srl
2//
3// SPDX-License-Identifier: Apache-2.0
4
5#ifndef ASTARTE_DEVICE_SDK_OBJECT_H
6#define ASTARTE_DEVICE_SDK_OBJECT_H
7
12
13#include <initializer_list>
14#include <string>
15#include <unordered_map>
16
18
19namespace AstarteDeviceSdk {
20
23 public:
25 using MapType = std::unordered_map<std::string, AstarteData>;
27 using iterator = MapType::iterator;
29 using const_iterator = MapType::const_iterator;
31 using size_type = MapType::size_type;
33 using value_type = MapType::value_type;
34
41 AstarteDatastreamObject(std::initializer_list<value_type> init);
48 auto at(const std::string& key) -> AstarteData&;
55 auto at(const std::string& key) const -> const AstarteData&;
61 auto begin() -> iterator;
67 auto begin() const -> const_iterator;
73 auto end() -> iterator;
79 auto end() const -> const_iterator;
85 auto size() const -> size_type;
91 auto empty() const -> bool;
98 void insert(const std::string& key, const AstarteData& data);
105 auto erase(const std::string& key) -> size_type;
110 void clear();
117 auto find(const std::string& key) -> iterator;
124 auto find(const std::string& key) const -> const_iterator;
129 auto get_raw_data() const -> const MapType&;
135 [[nodiscard]] auto operator==(const AstarteDatastreamObject& other) const -> bool;
141 [[nodiscard]] auto operator!=(const AstarteDatastreamObject& other) const -> bool;
142
143 private:
144 MapType data_;
145};
146
147} // namespace AstarteDeviceSdk
148
149#endif // ASTARTE_DEVICE_SDK_OBJECT_H
Astarte data class, representing the basic Astarte types.
Definition data.hpp:40
MapType::value_type value_type
Helper type for value type of the map of paths and Astarte datas.
Definition object.hpp:33
MapType::size_type size_type
Helper type for size type of the map of paths and Astarte datas.
Definition object.hpp:31
std::unordered_map< std::string, AstarteData > MapType
Helper type for the map of paths and Astarte datas.
Definition object.hpp:25
auto begin() -> iterator
Returns an iterator to the beginning of the specified bucket.
MapType::iterator iterator
Helper type for the iterator over the map of paths and Astarte datas.
Definition object.hpp:27
AstarteDatastreamObject()
Constructor for the class. To instantiate an empty object.
AstarteDatastreamObject(std::initializer_list< value_type > init)
Constructor for the class. To instantiate a non-empty object.
auto empty() const -> bool
Checks whether the container is empty.
MapType::const_iterator const_iterator
Helper type for the const iterator over the map of paths and Astarte datas.
Definition object.hpp:29
auto erase(const std::string &key) -> size_type
Erases elements.
auto at(const std::string &key) const -> const AstarteData &
Access specified element with bounds checking.
void clear()
Clears the contents.
void insert(const std::string &key, const AstarteData &data)
Insert elements.
auto size() const -> size_type
Returns the number of elements.
auto get_raw_data() const -> const MapType &
Return the raw data contained in this class instance.
auto begin() const -> const_iterator
Returns an iterator to the beginning of the specified bucket.
auto at(const std::string &key) -> AstarteData &
Access specified element with bounds checking.
auto find(const std::string &key) -> iterator
Finds element with specific key.
auto end() -> iterator
Returns an iterator to the end of the specified bucket.
Astarte data class and its related methods.
Umbrella namespace for the Astarte device SDK.
Definition data.hpp:23