Skip to main content

utility-inlines.h File

C++ header file with inline implementations for the µTest++ utility functions. More...

Namespaces Index​

namespacemicro_os_plus

The primary namespace for the µOS++ framework. More...

namespacemicro_test_plus

Primary namespace for the µTest++ testing framework. More...

namespaceutility

Utility functions for the µTest++ testing framework. More...

Functions Index​

template <class T, class Delim_T>
auto split (T input, Delim_T delim) -> std::vector< T >

Splits a string into a vector of sub-strings. More...

Description​

C++ header file with inline implementations for the µTest++ utility functions.

This header provides the inline implementations for the utility function templates used within the µTest++ framework. It defines the logic for splitting strings into sub-strings using a specified delimiter, enabling convenient and type-safe string parsing in test expressions.

All definitions reside within the micro_os_plus::micro_test_plus::utility namespace.

This file is included by utility.h; the applications include micro-os-plus/micro-test-plus.h, not this file.

File Listing​

The file content with the documentation metadata removed is:

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
35
36#ifndef MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_UTILITY_INLINES_H_
37#define MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_UTILITY_INLINES_H_
38
39// ----------------------------------------------------------------------------
40
41#if defined(__cplusplus)
42
43// ----------------------------------------------------------------------------
44
45#if defined(__GNUC__)
46#pragma GCC diagnostic push
47
48#pragma GCC diagnostic ignored "-Waggregate-return"
49#if defined(__clang__)
50#pragma clang diagnostic ignored "-Wc++98-compat"
51#endif // defined(__clang__)
52#endif // defined(__GNUC__)
53
54// ============================================================================
55
57{
58 // --------------------------------------------------------------------------
59 namespace utility
60 {
84 template <class T, class Delim_T>
85 requires requires (T s, Delim_T d) {
86 T::npos;
87 s.find_first_of (d, std::size_t{});
88 s.substr (std::size_t{}, std::size_t{});
89 }
90 [[nodiscard]] auto
91 split (T input, Delim_T delim) -> std::vector<T>
92 {
93 std::vector<T> output{};
94 std::size_t first{};
95 while (first < std::size (input))
96 {
97 const auto second = input.find_first_of (delim, first);
98 if (first != second)
99 {
100 output.emplace_back (input.substr (first, second - first));
101 }
102 if (second == T::npos)
103 {
104 break;
105 }
106 first = second + 1;
107 }
108 return output;
109 }
110
111 // ------------------------------------------------------------------------
112 } // namespace utility
113
114 // --------------------------------------------------------------------------
115} // namespace micro_os_plus::micro_test_plus
116
117#if defined(__GNUC__)
118#pragma GCC diagnostic pop
119#endif // defined(__GNUC__)
120
121// ----------------------------------------------------------------------------
122
123#endif // defined(__cplusplus)
124
125// ----------------------------------------------------------------------------
126
127#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_UTILITY_INLINES_H_
128
129// ----------------------------------------------------------------------------

Generated via doxygen2docusaurus 2.2.8 by Doxygen 1.18.0.