Woman, Life, Freedom


DoIP Library
Diagnostics over Internet Protocol (DoIP) C++ library
DoipLib::Convert Namespace Reference

Helper functions namespace for conversion from/to byte vector. More...

Functions

template<typename T >
void ToByteVector (T unsignedInteger, std::vector< uint8_t > &vector)
 Convert the given unsigned integer to a byte vector. More...
 
template<typename T >
ToUnsignedInteger (const std::vector< uint8_t > &vector, std::size_t &offset)
 Convert the given byte vector to an unsigned integer. More...
 
template<typename T >
ToEnum (const std::vector< uint8_t > &vector, std::size_t &offset)
 Convert the given byte vector to an enum. More...
 
template<std::size_t N>
std::array< uint8_t, N > ToByteArray (const std::vector< uint8_t > &vector, std::size_t &offset)
 Convert the given byte vector to a byte array. More...
 
template<std::size_t N>
std::string ToString (const std::vector< uint8_t > &vector, std::size_t &offset)
 Convert the given byte vector to a string. More...
 

Detailed Description

Helper functions namespace for conversion from/to byte vector.

Function Documentation

◆ ToByteArray()

template<std::size_t N>
std::array< uint8_t, N > DoipLib::Convert::ToByteArray ( const std::vector< uint8_t > &  vector,
std::size_t &  offset 
)

Convert the given byte vector to a byte array.

Template Parameters
NByte array size
Parameters
vectorByte vector to be converted
[in,out]offsetOffset within the byte vector
Returns
Byte array as the byte vector conversion result

◆ ToByteVector()

template<typename T >
void DoipLib::Convert::ToByteVector ( unsignedInteger,
std::vector< uint8_t > &  vector 
)

Convert the given unsigned integer to a byte vector.

Template Parameters
TUnsigned integer type
Parameters
[in]unsignedIntegerUnsigned integer to be converted
[out]vectorByte vector as the unsigned integer conversion result

◆ ToEnum()

template<typename T >
T DoipLib::Convert::ToEnum ( const std::vector< uint8_t > &  vector,
std::size_t &  offset 
)

Convert the given byte vector to an enum.

Template Parameters
TEnum with underlying unsigned integer type
Parameters
vectorByte vector to be converted
[in,out]offsetOffset within the byte vector
Returns
Enum as the byte vector conversion result
Warning
If the underlying enum type is not an unsigned integer, the behaviour is undefined.

◆ ToString()

template<std::size_t N>
std::string DoipLib::Convert::ToString ( const std::vector< uint8_t > &  vector,
std::size_t &  offset 
)

Convert the given byte vector to a string.

Template Parameters
NString size
Parameters
vectorByte vector to be converted
[in,out]offsetOffset within the byte vector
Returns
String as the byte vector conversion result

◆ ToUnsignedInteger()

template<typename T >
T DoipLib::Convert::ToUnsignedInteger ( const std::vector< uint8_t > &  vector,
std::size_t &  offset 
)

Convert the given byte vector to an unsigned integer.

Template Parameters
TUnsigned integer type
Parameters
vectorByte vector to be converted
[in,out]offsetOffset within the byte vector
Returns
Unsigned integer as the byte vector conversion result