encoding.h File Reference

Contains classes and methods for defining and using encoders/decoders for various types. More...

#include "layer.h"
#include "containers.h"
Include dependency graph for encoding.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<typename Type , GARLIC_VIEW Layer>
static std::enable_if_t< internal::use_explicit_decoder< Type, Layer >, Type > garlic::decode (Layer &&layer)
 Decodes a layer. More...
 
template<typename Type , GARLIC_VIEW Layer, typename Callable >
static std::enable_if_t< internal::use_safe_decode_layer_method< Type, Layer > > garlic::safe_decode (Layer &&layer, Callable &&cb)
 Safely attempt to decode a value and if successful, call the callback method. More...
 
template<GARLIC_REF Layer, typename Type >
static std::enable_if_t< internal::use_encode_layer_method< Type, Layer > > garlic::encode (Layer &&layer, const Type &value)
 Encode a value in a garlic::RefLayer. More...
 

Detailed Description

Contains classes and methods for defining and using encoders/decoders for various types.

Function Documentation

◆ decode()

template<typename Type , GARLIC_VIEW Layer>
static std::enable_if_t<internal::use_explicit_decoder<Type, Layer>, Type> garlic::decode ( Layer &&  layer)
inlinestatic

Decodes a layer.

Template Parameters
Layerany readable layer that conforms to the garlic::ViewLayer concept.
Typethe output type.
Parameters
layerthe layer to read from.

◆ encode()

template<GARLIC_REF Layer, typename Type >
static std::enable_if_t<internal::use_encode_layer_method<Type, Layer> > garlic::encode ( Layer &&  layer,
const Type &  value 
)
inlinestatic

Encode a value in a garlic::RefLayer.

If an encoder is defined for the Type, it will be used to encode that value into the layer.

Template Parameters
Layerany writable layer that conforms to the garlic::RefLayer concept.
Parameters
layerthe layer to write to.
valuethe value to encode to the layer.

◆ safe_decode()

template<typename Type , GARLIC_VIEW Layer, typename Callable >
static std::enable_if_t<internal::use_safe_decode_layer_method<Type, Layer> > garlic::safe_decode ( Layer &&  layer,
Callable &&  cb 
)
inlinestatic

Safely attempt to decode a value and if successful, call the callback method.

Template Parameters
Layerany readable layer that conforms to the garlic::ViewLayer concept.
Callableany lambda or callable type.
Parameters
layerthe layer to read from.
cbthe callback function to call with a successfully decoded value.