micro-test-plus 4.1.0
µTest++ Testing Framework
Loading...
Searching...
No Matches
reflection.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the µOS++ project (https://micro-os-plus.github.io/).
3 * Copyright (c) 2021-2026 Liviu Ionescu. All rights reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose is hereby granted, under the terms of the MIT license.
7 *
8 * If a copy of the license was not distributed with this file, it can be
9 * obtained from https://opensource.org/licenses/mit.
10 *
11 * Major parts of the code are inspired from v1.1.8 of the Boost UT project,
12 * released under the terms of the Boost Version 1.0 Software License,
13 * which can be obtained from https://www.boost.org/LICENSE_1_0.txt.
14 */
15
16// ----------------------------------------------------------------------------
17
33
34// ----------------------------------------------------------------------------
35
36#include <cstring>
37
38#if defined(MICRO_OS_PLUS_INCLUDE_CONFIG_H)
39#include <micro-os-plus/config.h>
40#endif // MICRO_OS_PLUS_INCLUDE_CONFIG_H
41
43
44// ----------------------------------------------------------------------------
45
46#if defined(__GNUC__)
47#if defined(__clang__)
48#pragma clang diagnostic ignored "-Wc++98-compat"
49#endif
50#endif
51
52// ============================================================================
53
55{
56 // --------------------------------------------------------------------------
57 // Public API.
58
59 // --------------------------------------------------------------------------
60 // Too small to deserve a separate source file.
61 namespace reflection
62 {
63
73 const char*
74 short_name (const char* name) noexcept
75 {
76#if defined(__GNUC__)
77#pragma GCC diagnostic push
78#if defined(__clang__)
79#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
80#endif
81#endif
82 const char* p = strrchr (name, '/');
83 if (p != nullptr)
84 return p + 1;
85 else
86 return name;
87#if defined(__GNUC__)
88#pragma GCC diagnostic pop
89#endif
90 }
91
92 } // namespace reflection
93
94 // ==========================================================================
95} // namespace micro_os_plus::micro_test_plus
96
97// ----------------------------------------------------------------------------
Reflection utilities for the µTest++ testing framework.
const char * short_name(const char *name) noexcept
Extract a short type or function name from a fully qualified name.
Primary namespace for the µTest++ testing framework.
C++ header file with declarations for the µTest++ reflection utilities.