xentara-utils v1.2.1
Xentara utilities library
Loading...
Searching...
No Matches
xentara::utils::cbor::Decoder Class Reference

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 <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.
 
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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Decoder()

xentara::utils::cbor::Decoder::Decoder ( std::reference_wrapper< io::InputStream< std::byte > >  stream)

A Decoder constructor that sets an input stream.

Parameters
streamInput stream

Member Function Documentation

◆ operator>>() [1/16]

auto xentara::utils::cbor::Decoder::operator>> ( Array array) -> Decoder &

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.

Parameters
arrayThe array header to decode
Returns
A reference to this object

◆ operator>>() [2/16]

auto xentara::utils::cbor::Decoder::operator>> ( bool &  value) -> Decoder &

Decodes bool value.

Parameters
valueA value to decode
Returns
A reference to this object

◆ operator>>() [3/16]

auto xentara::utils::cbor::Decoder::operator>> ( BreakTag  tag) -> Decoder &

Decodes a CBOR break value (simple value 31)

Parameters
tagAlways pass kBreak as this parameter
Returns
A reference to this object
See also
section 3.2.1) RFC 8949.

◆ operator>>() [4/16]

template<typename Allocator >
auto xentara::utils::cbor::Decoder::operator>> ( core::RawVector< std::byte, Allocator > &  data) -> Decoder &

Decodes byte string of opaque bytes.

Parameters
dataAddress of the data
Returns
A reference to this object

◆ operator>>() [5/16]

auto xentara::utils::cbor::Decoder::operator>> ( DataType value) -> Decoder &

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.

Returns
The data type of the next value in the stream

◆ operator>>() [6/16]

auto xentara::utils::cbor::Decoder::operator>> ( double &  value) -> Decoder &

Decodes double value.

Parameters
valueA value to decode
Returns
A reference to this object

◆ operator>>() [7/16]

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.

Returns
The data type of the next value in the stream

◆ operator>>() [8/16]

auto xentara::utils::cbor::Decoder::operator>> ( float &  value) -> Decoder &

Decodes float value.

Parameters
valueA value to decode
Returns
A reference to this object

◆ operator>>() [9/16]

auto xentara::utils::cbor::Decoder::operator>> ( Map map) -> Decoder &

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.

Parameters
mapThe map header to decode
Returns
A reference to this object

◆ operator>>() [10/16]

auto xentara::utils::cbor::Decoder::operator>> ( NullTag  tag) -> Decoder &

Decodes a CBOR null value (simple value 22)

Parameters
tagAlways pass kNull as this parameter
Returns
A reference to this object

◆ operator>>() [11/16]

auto xentara::utils::cbor::Decoder::operator>> ( SimpleValue value) -> Decoder &

Decodes an arbitrary CBOR simple value.

Parameters
valueA value to decode
Returns
A reference to this object

◆ operator>>() [12/16]

template<typename CharTraits , typename Allocator >
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.

Parameters
stringAddress of the data
Returns
A reference to this object

◆ operator>>() [13/16]

auto xentara::utils::cbor::Decoder::operator>> ( Tag value) -> Decoder &

Decodes a CBOR data item tag.

Parameters
valueA value to decode
Returns
A reference to this object
See also
section 3.4) of RFC 8949.

◆ operator>>() [14/16]

template<tools::UnsignedIntegral Type>
auto xentara::utils::cbor::Decoder::operator>> ( Type &  value) -> Decoder &

Decodes an unsigned integeral value.

Parameters
valueA value to decode
Returns
A reference to this object

◆ operator>>() [15/16]

template<tools::SignedIntegral Type>
auto xentara::utils::cbor::Decoder::operator>> ( Type &  value) -> Decoder &

Decodes signed/unsigned integeral value.

Parameters
valueA value to decode
Returns
A reference to this object

◆ operator>>() [16/16]

auto xentara::utils::cbor::Decoder::operator>> ( UndefinedTag  tag) -> Decoder &

Decodes a CBOR undefined value (simple value 23)

Parameters
tagAlways pass kUndefined as this parameter
Returns
A reference to this object
See also
section 5.7) of RFC 8949.