Zserio C++ runtime library  1.1.0
Built for Zserio 2.15.0
BitSizeOfCalculator.h
Go to the documentation of this file.
1 #ifndef ZSERIO_BITSIZEOF_CALCULATOR_H_INC
2 #define ZSERIO_BITSIZEOF_CALCULATOR_H_INC
3 
4 #include <cstddef>
5 #include <string>
6 
7 #include "zserio/BitBuffer.h"
10 #include "zserio/Span.h"
11 #include "zserio/StringView.h"
12 #include "zserio/Types.h"
13 
14 namespace zserio
15 {
16 
24 size_t bitSizeOfVarInt16(int16_t value);
25 
33 size_t bitSizeOfVarInt32(int32_t value);
34 
42 size_t bitSizeOfVarInt64(int64_t value);
43 
51 size_t bitSizeOfVarUInt16(uint16_t value);
52 
60 size_t bitSizeOfVarUInt32(uint32_t value);
61 
69 size_t bitSizeOfVarUInt64(uint64_t value);
70 
78 size_t bitSizeOfVarInt(int64_t value);
79 
87 size_t bitSizeOfVarUInt(uint64_t value);
88 
96 size_t bitSizeOfVarSize(uint32_t value);
97 
105 size_t bitSizeOfBytes(Span<const uint8_t> bytesValue);
106 
114 size_t bitSizeOfString(StringView stringValue);
115 
123 template <typename ALLOC>
125 {
126  const size_t bitBufferSize = bitBuffer.getBitSize();
127 
128  // bit buffer consists of varsize for bit size followed by the bits
129  return bitSizeOfVarSize(convertSizeToUInt32(bitBufferSize)) + bitBufferSize;
130 }
131 
132 } // namespace zserio
133 
134 #endif // ifndef ZSERIO_BITSIZEOF_CALCULATOR_H_INC
size_t getBitSize() const
Definition: BitBuffer.h:403
size_t bitSizeOfString(StringView stringValue)
size_t bitSizeOfVarInt32(int32_t value)
size_t bitSizeOfVarUInt32(uint32_t value)
BasicStringView< char, std::char_traits< char > > StringView
Definition: StringView.h:968
size_t bitSizeOfVarInt64(int64_t value)
size_t bitSizeOfVarSize(uint32_t value)
size_t bitSizeOfVarUInt64(uint64_t value)
uint32_t convertSizeToUInt32(size_t value)
size_t bitSizeOfVarInt16(int16_t value)
size_t bitSizeOfBitBuffer(const BasicBitBuffer< ALLOC > &bitBuffer)
size_t bitSizeOfVarUInt(uint64_t value)
size_t bitSizeOfVarInt(int64_t value)
size_t bitSizeOfBytes(Span< const uint8_t > bytesValue)
size_t bitSizeOfVarUInt16(uint16_t value)