Zserio C++ runtime library
1.2.0
Built for Zserio 2.16.0
SizeConvertUtil.cpp
Go to the documentation of this file.
1
#include <cstddef>
2
#include <limits>
3
4
#include "
zserio/CppRuntimeException.h
"
5
#include "
zserio/RuntimeArch.h
"
6
#include "
zserio/SizeConvertUtil.h
"
7
8
namespace
zserio
9
{
10
11
uint32_t
convertSizeToUInt32
(
size_t
value)
12
{
13
#ifdef ZSERIO_RUNTIME_64BIT
14
if
(value >
static_cast<
size_t
>
(std::numeric_limits<uint32_t>::max()))
15
{
16
throw
CppRuntimeException
(
"SizeConvertUtil: size_t value '"
)
17
<< value <<
"' is out of bounds for conversion to uint32_t type!"
;
18
}
19
#endif
20
21
return
static_cast<
uint32_t
>
(value);
22
}
23
24
size_t
convertUInt64ToSize
(uint64_t value)
25
{
26
#ifndef ZSERIO_RUNTIME_64BIT
27
if
(value >
static_cast<
uint64_t
>
(std::numeric_limits<size_t>::max()))
28
{
29
throw
CppRuntimeException
(
"SizeConvertUtil: uint64_t value '"
)
30
<< value <<
"' is out of bounds for conversion to size_t type!"
;
31
}
32
#endif
33
34
return
static_cast<
size_t
>
(value);
35
}
36
37
}
// namespace zserio
CppRuntimeException.h
RuntimeArch.h
SizeConvertUtil.h
zserio::CppRuntimeException
Definition:
CppRuntimeException.h:21
zserio
Definition:
AllocatorHolder.h:7
zserio::convertSizeToUInt32
uint32_t convertSizeToUInt32(size_t value)
Definition:
SizeConvertUtil.cpp:11
zserio::convertUInt64ToSize
size_t convertUInt64ToSize(uint64_t value)
Definition:
SizeConvertUtil.cpp:24
zserio
SizeConvertUtil.cpp
Generated by
1.9.1