Zserio C++17 runtime library 1.3.0
Built for Zserio 2.20.0
Loading...
Searching...
No Matches
ParsingInfo.h
Go to the documentation of this file.
1#ifndef ZSERIO_PARSING_INFO_INC_H
2#define ZSERIO_PARSING_INFO_INC_H
3
4#include <limits>
5
7#include "zserio/Types.h"
8
9namespace zserio
10{
11
17{
18public:
23 m_bitPosition(INVALID_BIT_POSITION),
24 m_bitSize(INVALID_BIT_SIZE)
25 {}
26
33 {
34 m_bitPosition = endBitPosition;
35 }
36
47 {
48 const size_t bitPosition = getBitPosition();
50 {
51 throw CppRuntimeException("Invalid end bit position argument (")
52 << endBitPosition << " < " << bitPosition << ")!";
53 }
54
55 m_bitSize = endBitPosition - getBitPosition();
56 }
57
65 size_t getBitPosition() const
66 {
67 if (m_bitPosition == INVALID_BIT_POSITION)
68 {
69 throw CppRuntimeException("Invalid bit position, read data first!");
70 }
71
72 return m_bitPosition;
73 }
74
82 size_t getBitSize() const
83 {
84 if (m_bitSize == INVALID_BIT_SIZE)
85 {
86 throw CppRuntimeException("Invalid bit size, read data first!");
87 }
88
89 return m_bitSize;
90 }
91
92private:
93 static constexpr size_t INVALID_BIT_POSITION = std::numeric_limits<size_t>::max();
94 static constexpr size_t INVALID_BIT_SIZE = std::numeric_limits<size_t>::max();
95
96 size_t m_bitPosition;
97 size_t m_bitSize;
98};
99
100} // namespace zserio
101
102#endif // ZSERIO_PARSING_INFO_INC_H
void setEndBitPosition(size_t endBitPosition)
Definition ParsingInfo.h:46
void setBitPosition(size_t endBitPosition)
Definition ParsingInfo.h:32
size_t getBitSize() const
Definition ParsingInfo.h:82
size_t getBitPosition() const
Definition ParsingInfo.h:65