CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::CBOR::Decoder Class Referencefinal

The Decoder class is a CBOR (Concise Binary Object Representation) decoder that provides an abstraction for deserializing CBOR data from an input stream. More...

#include <CeresEngine/Foundation/CBOR.hpp>

Public Member Functions

 Decoder (InputStream inputStream)
 Creates a new CBOR decoder from an InputStream.
 
 Decoder (IInputStream &inputStream)
 Creates a new CBOR decoder from an IInputStream.
 
Value read ()
 Decodes the next object from the CBOR stream.
 
template<typename Callback >
void map (const Value &value, Callback &&callback)
 Decodes the contents of a map from the CBOR value stream.
 
Generator< Pair< Value, Value > > map (const Map &value)
 Decodes the contents of a map from the CBOR value stream.
 
template<typename Callback >
void array (const Value &value, Callback &&callback)
 Decodes the contents of an array from the CBOR value stream.
 
Generator< Valuearray (const Array &value)
 Decodes the contents of an array from the CBOR value stream.
 
template<typename Callback >
void tag (const Value &value, Callback &&callback)
 Decodes the contents of a tag from the CBOR value stream.
 

Private Attributes

BufferedInputStream mStream
 The stream to read from.
 

Detailed Description

The Decoder class is a CBOR (Concise Binary Object Representation) decoder that provides an abstraction for deserializing CBOR data from an input stream.

It's designed to decode CBOR values from an instance of an InputStream. It provides an efficient and convenient way to read and decode CBOR data streams, without having to parse the entire data stream into memory.

Constructor & Destructor Documentation

◆ Decoder() [1/2]

CeresEngine::CBOR::Decoder::Decoder ( InputStream  inputStream)
inlineexplicit

Creates a new CBOR decoder from an InputStream.

◆ Decoder() [2/2]

CeresEngine::CBOR::Decoder::Decoder ( IInputStream inputStream)
inlineexplicit

Creates a new CBOR decoder from an IInputStream.

Member Function Documentation

◆ array() [1/2]

Generator< Value > CeresEngine::CBOR::Decoder::array ( const Array value)

Decodes the contents of an array from the CBOR value stream.

Parameters
valueA CBOR value that represents the array to be read.
Returns
A generator that returns every key-value of the array.
Note
It's important to consume the whole sequence of generator, otherwise the decoder will be in a bad state.

◆ array() [2/2]

template<typename Callback >
void CeresEngine::CBOR::Decoder::array ( const Value value,
Callback &&  callback 
)
inline

Decodes the contents of an array from the CBOR value stream.

Parameters
valueA CBOR value that represents the array to be read.
callbackA callback to be invoked for every value in the array.

◆ map() [1/2]

Generator< Pair< Value, Value > > CeresEngine::CBOR::Decoder::map ( const Map value)

Decodes the contents of a map from the CBOR value stream.

Parameters
valueA CBOR value that represents the map to be read.
Returns
A generator that returns every key-value of the map.
Note
It's important to consume the whole sequence of generator, otherwise the decoder will be in a bad state.

◆ map() [2/2]

template<typename Callback >
void CeresEngine::CBOR::Decoder::map ( const Value value,
Callback &&  callback 
)
inline

Decodes the contents of a map from the CBOR value stream.

Parameters
valueA CBOR value that represents the map to be read.
callbackA callback to be invoked for every key-value of the map.

◆ read()

Value CeresEngine::CBOR::Decoder::read ( )

Decodes the next object from the CBOR stream.

Returns
The decoded CBOR object value.

◆ tag()

template<typename Callback >
void CeresEngine::CBOR::Decoder::tag ( const Value value,
Callback &&  callback 
)
inline

Decodes the contents of a tag from the CBOR value stream.

Parameters
valueA CBOR value that represents the tag to be read.
callbackA callback to be invoked with the tag value.

Member Data Documentation

◆ mStream

BufferedInputStream CeresEngine::CBOR::Decoder::mStream
private

The stream to read from.

This is a buffered InputStream and it's very important that this is referenced by value (not through the InputStream wrapper), as it allows to reduce the number of virtual calls and significantly increase the performance.


The documentation for this class was generated from the following file: