xentara-utils v2.0.4
The Xentara Utility Library
|
A class that decodes CBOR data types that includes: unsigned integers, negative integers, byte strings, text strings encoded as UTF-8, simple values and float-point number. More...
#include <xentara/utils/cbor/Decoder.hpp>
Public Member Functions | |
Decoder (std::reference_wrapper< io::InputStream< std::byte > > stream) | |
A Decoder constructor that sets an input stream. | |
template<tools::UnsignedIntegral Type> | |
auto | operator>> (Type &value) -> Decoder & |
Decodes an unsigned integeral value. | |
template<tools::SignedIntegral Type> | |
auto | operator>> (Type &value) -> Decoder & |
Decodes signed/unsigned integeral value. | |
template<typename Allocator > | |
auto | operator>> (core::RawVector< std::byte, Allocator > &data) -> Decoder & |
Decodes byte string of opaque bytes. | |
template<typename CharTraits , typename Allocator > | |
auto | operator>> (std::basic_string< char, CharTraits, Allocator > &string) -> Decoder & |
Decodes text string of Unicode characters that is encoded as UTF-8 - Major Type 3. | |
auto | operator>> (float &value) -> Decoder & |
Decodes float value. | |
auto | operator>> (double &value) -> Decoder & |
Decodes double value. | |
auto | operator>> (bool &value) -> Decoder & |
Decodes bool value. | |
auto | operator>> (NullTag tag) -> Decoder & |
Decodes a CBOR null value (simple value 22) | |
auto | operator>> (UndefinedTag tag) -> Decoder & |
Decodes a CBOR undefined value (simple value 23) | |
auto | operator>> (Tag &value) -> Decoder & |
Decodes a CBOR data item tag. | |
auto | operator>> (SimpleValue &value) -> Decoder & |
Decodes an arbitrary CBOR simple value. | |
auto | operator>> (Array &array) -> Decoder & |
Decodes the header of a CBOR array. | |
auto | operator>> (Map &map) -> Decoder & |
Decodes the header of a CBOR map. | |
template<typename Value > requires (!std::same_as<Value, NullTag> && !std::same_as<Value, BreakTag> && !std::same_as<Value, DataType> && !std::same_as<Value, ExtendedDataType>) | |
auto | operator>> (std::optional< Value > &optional) -> Decoder & |
Decodes an optional value. | |
auto | operator>> (BreakTag tag) -> Decoder & |
Decodes a CBOR break value (simple value 31) | |
auto | operator>> (DataType &value) -> Decoder & |
Checks what the data type of the next value will be. | |
auto | operator>> (ExtendedDataType &value) -> Decoder & |
Checks what the data type and bit size of the next value will be. | |
auto | operator>> (AlternativeValue &value) -> Decoder & |
Decodes a CBOR alternative value. | |
auto | skip () -> void |
Skips the next value. | |
A class that decodes CBOR data types that includes: unsigned integers, negative integers, byte strings, text strings encoded as UTF-8, simple values and float-point number.
xentara::utils::cbor::Decoder::Decoder | ( | std::reference_wrapper< io::InputStream< std::byte > > | stream | ) |
A Decoder constructor that sets an input stream.
stream | Input stream |
auto xentara::utils::cbor::Decoder::operator>> | ( | AlternativeValue & | value | ) | -> Decoder & |
Decodes a CBOR alternative value.
value | A value to decode |
Decodes the header of a CBOR array.
This function only decodes the header of the array, consisting of the major type and the length. The array elements and (for indefinite length arrays) the stop code must be decoded separately.
array | The array header to decode |
auto xentara::utils::cbor::Decoder::operator>> | ( | bool & | value | ) | -> Decoder & |
Decodes bool value.
value | A value to decode |
Decodes a CBOR break value (simple value 31)
tag | Always pass kBreak as this parameter |
auto xentara::utils::cbor::Decoder::operator>> | ( | core::RawVector< std::byte, Allocator > & | data | ) | -> Decoder & |
Decodes byte string of opaque bytes.
data | Address of the data |
Checks what the data type of the next value will be.
This function does not consume any data in the stream, it only looks ahead to what the next value will be without actually reading it. The actual value concerned can be extracted as usual after determining the data type.
auto xentara::utils::cbor::Decoder::operator>> | ( | double & | value | ) | -> Decoder & |
Decodes double value.
value | A value to decode |
auto xentara::utils::cbor::Decoder::operator>> | ( | ExtendedDataType & | value | ) | -> Decoder & |
Checks what the data type and bit size of the next value will be.
This function does not consume any data in the stream, it only looks ahead to what the next value will be without actually reading it. The actual value concerned can be extracted as usual after determining the data type.
auto xentara::utils::cbor::Decoder::operator>> | ( | float & | value | ) | -> Decoder & |
Decodes float value.
value | A value to decode |
Decodes the header of a CBOR map.
This function only decodes the header of the map, consisting of the major type and the length. The keys and values, and (for indefinite length maps) the stop code, must be decoded separately.
map | The map header to decode |
Decodes a CBOR null value (simple value 22)
tag | Always pass kNull as this parameter |
auto xentara::utils::cbor::Decoder::operator>> | ( | SimpleValue & | value | ) | -> Decoder & |
Decodes an arbitrary CBOR simple value.
value | A value to decode |
auto xentara::utils::cbor::Decoder::operator>> | ( | std::basic_string< char, CharTraits, Allocator > & | string | ) | -> Decoder & |
Decodes text string of Unicode characters that is encoded as UTF-8 - Major Type 3.
string | Address of the data |
auto xentara::utils::cbor::Decoder::operator>> | ( | std::optional< Value > & | optional | ) | -> Decoder & |
Decodes an optional value.
This function first checks the data type of the next value. If the next value is a CBOR null value (simple value 22), it is decoded and optional is set to std::nullopt. If the next value is any other type, then the value is read and moved into optional using std::move().
optional | A optional value to decode |
Decodes a CBOR data item tag.
value | A value to decode |
auto xentara::utils::cbor::Decoder::operator>> | ( | Type & | value | ) | -> Decoder & |
Decodes an unsigned integeral value.
value | A value to decode |
auto xentara::utils::cbor::Decoder::operator>> | ( | Type & | value | ) | -> Decoder & |
Decodes signed/unsigned integeral value.
value | A value to decode |
auto xentara::utils::cbor::Decoder::operator>> | ( | UndefinedTag | tag | ) | -> Decoder & |
Decodes a CBOR undefined value (simple value 23)
tag | Always pass kUndefined as this parameter |
auto xentara::utils::cbor::Decoder::skip | ( | ) | -> void |
Skips the next value.
This function skips the next value. For the types like Tags, Arrays, and Maps, it skips over all their nested data as well.