Zserio C++17 runtime library 1.3.0
Built for Zserio 2.20.0
Loading...
Searching...
No Matches
CppRuntimeException.cpp
Go to the documentation of this file.
1#include <algorithm>
2#include <cstring>
3
5
6namespace zserio
7{
8
10 m_buffer()
11{
13}
14
16
18{
19 return m_buffer.data();
20}
21
23{
24 const size_t available = m_buffer.size() - 1 - m_len;
26 appendImpl(std::string_view(message, numCharsToAppend));
28
30{
31 const size_t available = m_buffer.size() - 1 - m_len;
32 const size_t numCharsToAppend = std::min(messageLen, available);
33 appendImpl(std::string_view(message, numCharsToAppend));
34}
35
36void CppRuntimeException::appendImpl(std::string_view message)
37{
38 if (message.size() > 0)
39 {
40 (void)std::copy(message.begin(), message.end(), m_buffer.begin() + m_len);
41 m_len += message.size();
42 }
43 m_buffer.at(m_len) = '\0';
44}
45
47{
48 exception.append(message);
49 return exception;
50}
51
53{
54 return exception << (value ? "true" : "false");
55}
56
58{
59 std::array<char, 24> integerPartBuffer = {};
60 std::array<char, 24> floatingPartBuffer = {};
61 const char* integerPartString = nullptr;
62 const char* floatingPartString = nullptr;
65 if (floatingPartString != nullptr)
66 {
68 }
69
70 return result;
71}
72
74{
76}
77
78CppRuntimeException& operator<<(CppRuntimeException& exception, std::string_view value)
79{
80 exception.append(value.data(), value.size());
81 return exception;
82}
83
84} // namespace zserio
const char * what() const noexcept override
CppRuntimeException(const char *message="")
void append(const char *message)
CppRuntimeException & operator<<(CppRuntimeException &exception, const BasicBitBuffer< ALLOC > &bitBuffer)
Definition BitBuffer.h:554
void convertFloatToString(std::array< char, 24 > &integerPartBuffer, std::array< char, 24 > &floatingPartBuffer, float value, const char *&integerPartString, const char *&floatingPartString)