1#ifndef BYTE_BUFFER_HPP_7NOEQO4F
2#define BYTE_BUFFER_HPP_7NOEQO4F
11typedef std::vector<uint8_t> ByteBuffer;
14
15
16
17
18template<
typename MASK>
19MASK* buffer_cast(ByteBuffer& buffer)
21 static_assert(std::is_standard_layout<MASK>::value,
"MASK has to be standard layout type");
22 static_assert(std::is_trivially_copyable<MASK>::value,
"MASK has to be trivially copyable");
23 static_assert(std::is_object<MASK>::value,
"MASK has to be an object");
26 if (
sizeof(MASK) <= buffer.size()) {
27 mask =
reinterpret_cast<MASK*>(&buffer[0]);
32template<
typename MASK>
33const MASK* buffer_cast(
const ByteBuffer& buffer)
36 return buffer_cast<MASK>(
const_cast<ByteBuffer&>(buffer));
40
41
42
43
45ByteBuffer buffer_copy(
const T& object)
47 static_assert(std::is_standard_layout<T>::value,
"T has to be standard layout type");
48 auto ptr =
reinterpret_cast<
const uint8_t*>(&object);
49 return ByteBuffer(ptr, ptr +
sizeof(T));
ByteBuffer encode() const
bool decode(const ByteBuffer &buffer)
ByteBuffer encode() const
bool decode(const ByteBuffer &buffer)
void swap(asn1c_wrapper_common &other) noexcept
int compare(const asn1c_wrapper_common &other) const
bool validate(std::string &error) const
int print(FILE *stream) const
ByteBuffer encode() const
bool decode(const ByteBuffer &buffer)