MMTF-C++
The C++ language MMTF libraries
Loading...
Searching...
No Matches
mmtf::BinaryDecoder Class Reference

Helper class to decode msgpack binary into a vector. More...

#include <binary_decoder.hpp>

Public Member Functions

 BinaryDecoder (const msgpack::object &obj, const std::string &key="UNNAMED_BINARY")
 Initialize object given a msgpack object. Reads out binary header to prepare for call of decode.
 
 BinaryDecoder (const std::string &str, const std::string &key="UNNAMED_BINARY")
 Initialize object given a msgpack binary string. Reads out binary header to prepare for call of decode.
 
template<typename T>
void decode (T &target) const
 Decode binary msgpack object into the given target.
 
template<>
void decode (std::vector< float > &output) const
 
template<>
void decode (std::vector< int8_t > &output) const
 
template<>
void decode (std::vector< int16_t > &output) const
 
template<>
void decode (std::vector< int32_t > &output) const
 
template<>
void decode (std::vector< std::string > &output) const
 
template<>
void decode (std::vector< char > &output) const
 

Detailed Description

Helper class to decode msgpack binary into a vector.

Constructor & Destructor Documentation

◆ BinaryDecoder() [1/2]

mmtf::BinaryDecoder::BinaryDecoder ( const msgpack::object & obj,
const std::string & key = "UNNAMED_BINARY" )
inline

Initialize object given a msgpack object. Reads out binary header to prepare for call of decode.

Parameters
[in]objObject to decode.
[in]keyKey used to report errors.
Warning
This uses a pointer to the data of obj. obj must stay alive while this instance exists or it will result in undefined behavior.
Exceptions
mmtf::DecodeErrorif obj is not a binary or is too short.

◆ BinaryDecoder() [2/2]

mmtf::BinaryDecoder::BinaryDecoder ( const std::string & str,
const std::string & key = "UNNAMED_BINARY" )
inline

Initialize object given a msgpack binary string. Reads out binary header to prepare for call of decode.

Parameters
[in]strObject to decode.
[in]keyKey used to report errors.
Warning
This uses a pointer to the data of str. str must stay alive while this instance exists or it will result in undefined behavior.
Exceptions
mmtf::DecodeErrorif obj is not a binary or is too short.

Member Function Documentation

◆ decode() [1/7]

template<>
void mmtf::BinaryDecoder::decode ( std::vector< char > & output) const
inline

◆ decode() [2/7]

template<>
void mmtf::BinaryDecoder::decode ( std::vector< float > & output) const
inline

◆ decode() [3/7]

template<>
void mmtf::BinaryDecoder::decode ( std::vector< int16_t > & output) const
inline

◆ decode() [4/7]

template<>
void mmtf::BinaryDecoder::decode ( std::vector< int32_t > & output) const
inline

◆ decode() [5/7]

template<>
void mmtf::BinaryDecoder::decode ( std::vector< int8_t > & output) const
inline

◆ decode() [6/7]

template<>
void mmtf::BinaryDecoder::decode ( std::vector< std::string > & output) const
inline

◆ decode() [7/7]

template<typename T>
void mmtf::BinaryDecoder::decode ( T & target) const

Decode binary msgpack object into the given target.

Parameters
[out]targetStore decoded vector into this field.
Template Parameters
TCan be one of:
  • std::vector<float> (strategies: 1, 9, 10, 11, 12, 13)
  • std::vector<int8_t> (strategies: 2, 16)
  • std::vector<int16_t> (strategies: 3)
  • std::vector<int32_t> (strategies: 4, 7, 8, 14, 15)
  • std::vector<std::string> (strategies: 5)
  • std::vector<char> (strategies: 6)
Exceptions
mmtf::DecodeErrorif we fail to decode.

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