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
6
#include "
zserio/CppRuntimeException.h
"
7
#include "
zserio/Types.h
"
8
9
namespace
zserio
10
{
11
16
class
ParsingInfo
17
{
18
public
:
22
ParsingInfo
() :
23
m_bitPosition(INVALID_BIT_POSITION),
24
m_bitSize(INVALID_BIT_SIZE)
25
{}
26
32
void
setBitPosition
(
size_t
endBitPosition
)
33
{
34
m_bitPosition =
endBitPosition
;
35
}
36
46
void
setEndBitPosition
(
size_t
endBitPosition
)
47
{
48
const
size_t
bitPosition
=
getBitPosition
();
49
if
(
endBitPosition
<
bitPosition
)
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
92
private
:
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
CppRuntimeException.h
Types.h
zserio::CppRuntimeException
Definition
CppRuntimeException.h:20
zserio::ParsingInfo
Definition
ParsingInfo.h:17
zserio::ParsingInfo::setEndBitPosition
void setEndBitPosition(size_t endBitPosition)
Definition
ParsingInfo.h:46
zserio::ParsingInfo::setBitPosition
void setBitPosition(size_t endBitPosition)
Definition
ParsingInfo.h:32
zserio::ParsingInfo::getBitSize
size_t getBitSize() const
Definition
ParsingInfo.h:82
zserio::ParsingInfo::getBitPosition
size_t getBitPosition() const
Definition
ParsingInfo.h:65
zserio::ParsingInfo::ParsingInfo
ParsingInfo()
Definition
ParsingInfo.h:22
zserio::View
Definition
Traits.h:15
zserio
Definition
AllocatorHolder.h:8
zserio
ParsingInfo.h
Generated by
1.9.8