Astarte device API for C++ 0.8.1
Astarte device SDK for C++
Loading...
Searching...
No Matches
individual.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_INDIVIDUAL_H
6#define ASTARTE_DEVICE_SDK_INDIVIDUAL_H
7
15
16#include <ostream>
17
20
21namespace astarte::device {
22
30 public:
36 explicit DatastreamIndividual(Data data);
37
43 [[nodiscard]] auto get_value() const -> const Data&;
44
51 [[nodiscard]] auto operator==(const DatastreamIndividual& other) const -> bool;
52
59 [[nodiscard]] auto operator!=(const DatastreamIndividual& other) const -> bool;
60
61 private:
62 Data data_;
63};
64
65} // namespace astarte::device
66
68template <>
76 template <typename ParseContext>
77 constexpr auto parse(ParseContext& ctx) const {
78 return ctx.begin();
79 }
80
88 template <typename FormatContext>
89 auto format(const astarte::device::DatastreamIndividual& data, FormatContext& ctx) const {
90 return astarte_fmt::format_to(ctx.out(), "{}", data.get_value());
91 }
92};
93
101inline auto operator<<(std::ostream& out, const astarte::device::DatastreamIndividual& data)
102 -> std::ostream& {
103 out << astarte_fmt::format("{}", data);
104 return out;
105}
106
107#endif // ASTARTE_DEVICE_SDK_INDIVIDUAL_H
Represents a single Astarte data value.
Definition data.hpp:61
Represents the Astarte individual datastream data.
Definition individual.hpp:29
DatastreamIndividual(Data data)
Constructor for the DatastreamIndividual class.
auto get_value() const -> const Data &
Gets the value contained within the object.
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
Data formatting utilities for Astarte types.
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
constexpr auto parse(ParseContext &ctx) const
Parses the format string.
Definition individual.hpp:77
auto format(const astarte::device::DatastreamIndividual &data, FormatContext &ctx) const
Formats the DatastreamIndividual object.
Definition individual.hpp:89
Base formatter struct declaration for Doxygen.
Definition formatter.hpp:48