Skip to content

Commit 5e2917f

Browse files
committed
Updated copyright year to include 2026.
1 parent 3ecbb4c commit 5e2917f

208 files changed

Lines changed: 52589 additions & 61177 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

include/comms/Assert.h

Lines changed: 71 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2014 - 2025 (C). Alex Robenko. All rights reserved.
2+
// Copyright 2014 - 2026 (C). Alex Robenko. All rights reserved.
33
//
44
// This Source Code Form is subject to the terms of the Mozilla Public
55
// License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -15,75 +15,60 @@
1515
#include <type_traits>
1616
#include <utility>
1717

18-
namespace comms
19-
{
18+
namespace comms {
2019

2120
/// @brief Base class for any custom assertion behaviour.
2221
/// @details In order to implement custom assertion failure behaviour it
2322
/// is necessary to inherit from this class and override
2423
/// fail() virtual member function.
2524
/// @headerfile comms/Assert.h
26-
class Assert
27-
{
25+
class Assert {
2826
public:
29-
/// @brief Destructor
30-
virtual ~Assert() noexcept {}
31-
32-
/// @brief Pure virtual function to be called when assertion fails.
33-
/// @param[in] expr Assertion condition/expression
34-
/// @param[in] file File name
35-
/// @param[in] line Line number of the assert statement.
36-
/// @param[in] function Function name.
37-
virtual void fail(
38-
const char* expr,
39-
const char* file,
40-
unsigned int line,
41-
const char* function) = 0;
27+
/// @brief Destructor
28+
virtual ~Assert() noexcept {}
29+
30+
/// @brief Pure virtual function to be called when assertion fails.
31+
/// @param[in] expr Assertion condition/expression
32+
/// @param[in] file File name
33+
/// @param[in] line Line number of the assert statement.
34+
/// @param[in] function Function name.
35+
virtual void fail(const char *expr, const char *file, unsigned int line,
36+
const char *function) = 0;
4237

4338
private:
4439
};
4540

4641
/// @cond DOCUMENT_ASSERT_MANAGER
47-
class AssertManager
48-
{
42+
class AssertManager {
4943
public:
44+
static AssertManager &instance() {
45+
static AssertManager mgr;
46+
return mgr;
47+
}
5048

51-
static AssertManager& instance()
52-
{
53-
static AssertManager mgr;
54-
return mgr;
55-
}
56-
57-
AssertManager(const AssertManager&) = delete;
49+
AssertManager(const AssertManager &) = delete;
5850

59-
AssertManager& operator=(const AssertManager&) = delete;
51+
AssertManager &operator=(const AssertManager &) = delete;
6052

61-
Assert* reset(Assert* newAssert = nullptr)
62-
{
63-
auto prevAssert = m_assert;
64-
m_assert = newAssert;
65-
return prevAssert;
66-
}
53+
Assert *reset(Assert *newAssert = nullptr) {
54+
auto prevAssert = m_assert;
55+
m_assert = newAssert;
56+
return prevAssert;
57+
}
6758

68-
Assert* getAssert()
69-
{
70-
return m_assert;
71-
}
59+
Assert *getAssert() { return m_assert; }
7260

73-
bool hasAssertRegistered() const
74-
{
75-
return (m_assert != nullptr);
76-
}
61+
bool hasAssertRegistered() const { return (m_assert != nullptr); }
7762

78-
static void infiniteLoop()
79-
{
80-
while (true) {};
81-
}
63+
static void infiniteLoop() {
64+
while (true) {
65+
};
66+
}
8267

8368
private:
84-
AssertManager() : m_assert(nullptr) {}
69+
AssertManager() : m_assert(nullptr) {}
8570

86-
Assert* m_assert;
71+
Assert *m_assert;
8772
};
8873

8974
/// @endcond
@@ -95,45 +80,36 @@ class AssertManager
9580
/// behaviour of the assertion failure.
9681
/// @pre TAssert class must be derived from comms::Assert.
9782
/// @headerfile comms/Assert.h
98-
template < typename TAssert>
99-
class EnableAssert
100-
{
101-
static_assert(std::is_base_of<Assert, TAssert>::value,
102-
"TAssert class must be derived class of Assert");
83+
template <typename TAssert> class EnableAssert {
84+
static_assert(std::is_base_of<Assert, TAssert>::value,
85+
"TAssert class must be derived class of Assert");
86+
10387
public:
104-
/// Type of assert object.
105-
using AssertType = TAssert;
106-
107-
/// @brief Constructor
108-
/// @details Registers new assertion failure behaviour. It forwards
109-
/// all the provided parameters to the constructor of embedded
110-
/// assertion object of type TAssert.
111-
/// @param args Arguments to pass to the assertion class constructor.
112-
template<typename... TParams>
113-
EnableAssert(TParams&&... args)
114-
: m_assert(std::forward<TParams>(args)...),
115-
m_prevAssert(AssertManager::instance().reset(&m_assert))
116-
{
117-
}
118-
119-
/// @brief Destructor
120-
/// @details Restores the assertion behaviour that was recorded during
121-
/// the instantiation of this object.
122-
~EnableAssert() noexcept
123-
{
124-
AssertManager::instance().reset(m_prevAssert);
125-
}
126-
127-
/// @brief Provides reference to internal Assert object
128-
/// @return Reference to object of type TAssert.
129-
AssertType& getAssert()
130-
{
131-
return m_assert;
132-
}
88+
/// Type of assert object.
89+
using AssertType = TAssert;
90+
91+
/// @brief Constructor
92+
/// @details Registers new assertion failure behaviour. It forwards
93+
/// all the provided parameters to the constructor of embedded
94+
/// assertion object of type TAssert.
95+
/// @param args Arguments to pass to the assertion class constructor.
96+
template <typename... TParams>
97+
EnableAssert(TParams &&...args)
98+
: m_assert(std::forward<TParams>(args)...),
99+
m_prevAssert(AssertManager::instance().reset(&m_assert)) {}
100+
101+
/// @brief Destructor
102+
/// @details Restores the assertion behaviour that was recorded during
103+
/// the instantiation of this object.
104+
~EnableAssert() noexcept { AssertManager::instance().reset(m_prevAssert); }
105+
106+
/// @brief Provides reference to internal Assert object
107+
/// @return Reference to object of type TAssert.
108+
AssertType &getAssert() { return m_assert; }
133109

134110
private:
135-
AssertType m_assert;
136-
Assert* m_prevAssert;
111+
AssertType m_assert;
112+
Assert *m_prevAssert;
137113
};
138114

139115
#ifndef COMMS_ASSERT
@@ -154,24 +130,24 @@ class EnableAssert
154130
#ifndef COMMS_NOSTDLIB
155131
#define COMMS_ASSERT_FAIL_FUNC(expr) assert(expr)
156132
#else // #ifndef COMMS_NOSTDLIB
157-
#define COMMS_ASSERT_FAIL_FUNC(expr) comms::AssertManager::instance().infiniteLoop()
133+
#define COMMS_ASSERT_FAIL_FUNC(expr) \
134+
comms::AssertManager::instance().infiniteLoop()
158135
#endif // #ifndef COMMS_NOSTDLIB
159136

160137
/// @endcond
161138

162139
/// @brief Generic assert macro
163140
/// @details Will use custom assertion failure behaviour if such is defined,
164141
/// otherwise it will use standard "assert()" macro.
165-
/// In case COMMS_NOSTDLIB is defined and no custom assertion failure was
166-
/// enabled, infinite loop will be executed.
142+
/// In case COMMS_NOSTDLIB is defined and no custom assertion failure
143+
/// was enabled, infinite loop will be executed.
167144
/// @param expr Boolean expression
168-
#define COMMS_ASSERT(expr) \
169-
((expr) \
170-
? static_cast<void>(0) \
171-
: (comms::AssertManager::instance().hasAssertRegistered() \
172-
? comms::AssertManager::instance().getAssert()->fail( \
173-
#expr, __FILE__, __LINE__, COMMS_ASSERT_FUNCTION_STR) \
174-
: COMMS_ASSERT_FAIL_FUNC(expr)))
145+
#define COMMS_ASSERT(expr) \
146+
((expr) ? static_cast<void>(0) \
147+
: (comms::AssertManager::instance().hasAssertRegistered() \
148+
? comms::AssertManager::instance().getAssert()->fail( \
149+
#expr, __FILE__, __LINE__, COMMS_ASSERT_FUNCTION_STR) \
150+
: COMMS_ASSERT_FAIL_FUNC(expr)))
175151

176152
#else // #ifndef NDEBUG
177153

@@ -186,4 +162,4 @@ class EnableAssert
186162
#define GASSERT(expr) COMMS_ASSERT(expr)
187163
#endif // #ifndef GASSERT
188164

189-
} // namespace comms
165+
} // namespace comms

include/comms/CompileControl.h

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2015 - 2025 (C). Alex Robenko. All rights reserved.
2+
// Copyright 2015 - 2026 (C). Alex Robenko. All rights reserved.
33
//
44
// This Source Code Form is subject to the terms of the Mozilla Public
55
// License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -13,15 +13,15 @@
1313
#ifdef __GNUC__
1414

1515
#define GCC_DIAG_STR(s) #s
16-
#define GCC_DIAG_JOINSTR(x,y) GCC_DIAG_STR(x ## y)
17-
#define GCC_DIAG_DO_PRAGMA(x) _Pragma (#x)
16+
#define GCC_DIAG_JOINSTR(x, y) GCC_DIAG_STR(x##y)
17+
#define GCC_DIAG_DO_PRAGMA(x) _Pragma(#x)
1818
#define GCC_DIAG_PRAGMA(x) GCC_DIAG_DO_PRAGMA(GCC diagnostic x)
19-
#define CC_DISABLE_WARNINGS() \
20-
GCC_DIAG_PRAGMA(push) \
21-
GCC_DIAG_PRAGMA(ignored "-Wpedantic") \
22-
GCC_DIAG_PRAGMA(ignored "-Wctor-dtor-privacy")\
23-
GCC_DIAG_PRAGMA(ignored "-Wold-style-cast") \
24-
GCC_DIAG_PRAGMA(ignored "-Wconversion")
19+
#define CC_DISABLE_WARNINGS() \
20+
GCC_DIAG_PRAGMA(push) \
21+
GCC_DIAG_PRAGMA(ignored "-Wpedantic") \
22+
GCC_DIAG_PRAGMA(ignored "-Wctor-dtor-privacy") \
23+
GCC_DIAG_PRAGMA(ignored "-Wold-style-cast") \
24+
GCC_DIAG_PRAGMA(ignored "-Wconversion")
2525

2626
#define CC_ENABLE_WARNINGS() GCC_DIAG_PRAGMA(pop)
2727

@@ -40,7 +40,7 @@
4040
#endif
4141

4242
#define COMMS_IS_MSVC false
43-
#define COMMS_IS_GCC false
43+
#define COMMS_IS_GCC false
4444
#define COMMS_IS_CLANG false
4545
#define COMMS_IS_USING_GNUC false
4646

@@ -65,7 +65,8 @@
6565
#define COMMS_IS_CLANG true
6666
#endif // #if defined(__clang__)
6767

68-
#define COMMS_IS_GCC_47_OR_BELOW (COMMS_IS_GCC && (__GNUC__ == 4) && (__GNUC_MINOR__ < 8))
68+
#define COMMS_IS_GCC_47_OR_BELOW \
69+
(COMMS_IS_GCC && (__GNUC__ == 4) && (__GNUC_MINOR__ < 8))
6970
#define COMMS_IS_GCC_9 (COMMS_IS_GCC && (__GNUC__ == 9))
7071
#define COMMS_IS_GCC_9_OR_BELOW (COMMS_IS_GCC_9 && (__GNUC__ <= 9))
7172
#define COMMS_IS_GCC_9_OR_ABOVE (COMMS_IS_GCC_9 && (__GNUC__ >= 9))
@@ -87,10 +88,13 @@
8788
#define COMMS_IS_CLANG_16_OR_ABOVE (COMMS_IS_CLANG && (__clang_major__ >= 16))
8889
#define COMMS_IS_CLANG_18_OR_BELOW (COMMS_IS_CLANG && (__clang_major__ <= 18))
8990
#define COMMS_IS_CLANG_19_OR_BELOW (COMMS_IS_CLANG && (__clang_major__ <= 19))
90-
#define COMMS_IS_MSVC_2025 (COMMS_IS_MSVC && (_MSC_VER >= 1940) && (_MSC_VER < 1949))
91+
#define COMMS_IS_MSVC_2025 \
92+
(COMMS_IS_MSVC && (_MSC_VER >= 1940) && (_MSC_VER < 1949))
9193
#define COMMS_IS_MSVC_2025_OR_BELOW (COMMS_IS_MSVC && (_MSC_VER < 1950))
92-
#define COMMS_IS_MSVC_2022 (COMMS_IS_MSVC && (_MSC_VER >= 1930) && (_MSC_VER < 1939))
93-
#define COMMS_IS_MSVC_2019 (COMMS_IS_MSVC && (_MSC_VER >= 1920) && (_MSC_VER < 1930))
94+
#define COMMS_IS_MSVC_2022 \
95+
(COMMS_IS_MSVC && (_MSC_VER >= 1930) && (_MSC_VER < 1939))
96+
#define COMMS_IS_MSVC_2019 \
97+
(COMMS_IS_MSVC && (_MSC_VER >= 1920) && (_MSC_VER < 1930))
9498
#define COMMS_IS_MSVC_2019_OR_BELOW (COMMS_IS_MSVC && (_MSC_VER < 1930))
9599
#define COMMS_IS_MSVC_2017_OR_BELOW (COMMS_IS_MSVC && (_MSC_VER < 1920))
96100
#define COMMS_IS_MSVC_2015_OR_BELOW (COMMS_IS_MSVC && (_MSC_VER < 1910))
@@ -145,29 +149,23 @@
145149

146150
#endif // #if COMMS_IS_CLANG
147151

148-
#define COMMS_HAS_CPP20_VERSION_HEADER \
149-
COMMS_IS_CPP20 && \
150-
(\
151-
(COMMS_IS_USING_GNUC && (__GNUC__ >= 9)) || \
152-
(COMMS_IS_CLANG && COMMS_CLANG_HAS_VERSION_HEADER) || \
153-
(COMMS_IS_MSVC && (_MSC_VER >= 1922)) \
154-
)
152+
#define COMMS_HAS_CPP20_VERSION_HEADER \
153+
COMMS_IS_CPP20 && ((COMMS_IS_USING_GNUC && (__GNUC__ >= 9)) || \
154+
(COMMS_IS_CLANG && COMMS_CLANG_HAS_VERSION_HEADER) || \
155+
(COMMS_IS_MSVC && (_MSC_VER >= 1922)))
155156

156157
#if COMMS_HAS_CPP20_VERSION_HEADER
157158
#include <version>
158159
#endif
159160

160-
#define COMMS_HAS_CPP17_STRING_VIEW false
161+
#define COMMS_HAS_CPP17_STRING_VIEW false
161162

162163
#ifndef COMMS_NO_CPP17_STRING_VIEW
163164
#undef COMMS_HAS_CPP17_STRING_VIEW
164-
#define COMMS_HAS_CPP17_STRING_VIEW \
165-
COMMS_IS_CPP17 && \
166-
(\
167-
(COMMS_IS_USING_GNUC && (__GNUC__ >= 7)) || \
168-
(COMMS_IS_CLANG && COMMS_CLANG_HAS_STRING_VIEW) || \
169-
(COMMS_IS_MSVC && (_MSC_VER >= 1910)) \
170-
)
165+
#define COMMS_HAS_CPP17_STRING_VIEW \
166+
COMMS_IS_CPP17 && ((COMMS_IS_USING_GNUC && (__GNUC__ >= 7)) || \
167+
(COMMS_IS_CLANG && COMMS_CLANG_HAS_STRING_VIEW) || \
168+
(COMMS_IS_MSVC && (_MSC_VER >= 1910)))
171169

172170
#endif // #ifndef COMMS_NO_CPP17_STRING_VIEW
173171

@@ -182,8 +180,8 @@
182180
#define COMMS_MSVC_WARNING_PRAGMA(s_) __pragma(s_)
183181
#define COMMS_MSVC_WARNING_PUSH __pragma(warning(push))
184182
#define COMMS_MSVC_WARNING_POP __pragma(warning(pop))
185-
#define COMMS_MSVC_WARNING_DISABLE(w_) __pragma(warning(disable:w_))
186-
#define COMMS_MSVC_WARNING_SUPPRESS(w_) __pragma(warning(suppress:w_))
183+
#define COMMS_MSVC_WARNING_DISABLE(w_) __pragma(warning(disable : w_))
184+
#define COMMS_MSVC_WARNING_SUPPRESS(w_) __pragma(warning(suppress : w_))
187185

188186
#else // #if COMMS_IS_MSVC
189187

@@ -194,4 +192,3 @@
194192
#define COMMS_MSVC_WARNING_SUPPRESS(w_)
195193

196194
#endif // #if COMMS_IS_MSVC
197-

include/comms/EmptyHandler.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2014 - 2025 (C). Alex Robenko. All rights reserved.
2+
// Copyright 2014 - 2026 (C). Alex Robenko. All rights reserved.
33
//
44
// This Source Code Form is subject to the terms of the Mozilla Public
55
// License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -10,18 +10,14 @@
1010

1111
#pragma once
1212

13-
namespace comms
14-
{
13+
namespace comms {
1514

1615
/// @brief Empty message handler, does nothing.
1716
/// @details May be used in @ref comms::option::app::Handler option to force
1817
/// existence of "comms::Message::dispatch()" member function.
19-
class EmptyHandler
20-
{
18+
class EmptyHandler {
2119
public:
22-
template <typename TMessage>
23-
void handle(TMessage&) {}
20+
template <typename TMessage> void handle(TMessage &) {}
2421
};
2522

26-
} // namespace comms
27-
23+
} // namespace comms

0 commit comments

Comments
 (0)