Skip to main content

utility.h File

C++ header file with declarations for the µTest++ utility helpers. More...

Included Headers​

#include <cstddef> #include <string_view> #include <vector> #include "inlines/utility-inlines.h"

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​

const char *extract_file_name (const char *path) noexcept

Extracts the file name component from a full path. More...

boolis_match (std::string_view input, std::string_view pattern)

Checks whether a string matches a pattern with * and ? wildcards. More...

std::vector< std::string_view >split (std::string_view input, std::string_view delimiters)

Splits a string view into a vector of string views. More...

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 declarations for the µTest++ utility helpers.

This header provides declarations for the utility helper functions used within the µTest++ framework. It defines interfaces for string operations including file-name extraction, pattern matching, and string splitting.

This file is included by micro-os-plus/micro-test-plus.h, which is the header that the applications include.

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
30
31#ifndef MICRO_OS_PLUS_MICRO_TEST_PLUS_UTILITY_H_
32#define MICRO_OS_PLUS_MICRO_TEST_PLUS_UTILITY_H_
33
34// ----------------------------------------------------------------------------
35
36#if defined(__cplusplus)
37
38// ----------------------------------------------------------------------------
39
40#if __has_include("micro-os-plus/project-config.h")
41#include "micro-os-plus/project-config.h"
42#endif // __has_include("micro-os-plus/project-config.h")
43
44#if __has_include("micro-os-plus/micro-test-plus-defines.h")
45#include "micro-os-plus/micro-test-plus-defines.h"
46#endif // __has_include("micro-os-plus/micro-test-plus-defines.h")
47
48#include <cstddef>
49#include <string_view>
50#include <vector>
51
52// ----------------------------------------------------------------------------
53
54#if defined(__GNUC__)
55#pragma GCC diagnostic push
56
57#if defined(__clang__)
58#pragma clang diagnostic ignored "-Wc++98-compat"
59#endif // defined(__clang__)
60#endif // defined(__GNUC__)
61
62// ============================================================================
63
65{
66 // --------------------------------------------------------------------------
67
81 namespace utility
82 {
92 [[nodiscard]] const char*
93 extract_file_name (const char* path) noexcept;
94
105 [[nodiscard]] bool
106 is_match (std::string_view input, std::string_view pattern);
107
128 template <class T, class Delim_T>
129 requires requires (T s, Delim_T d) {
130 T::npos;
131 s.find_first_of (d, std::size_t{});
132 s.substr (std::size_t{}, std::size_t{});
133 }
134 [[nodiscard]] auto
135 split (T input, Delim_T delim) -> std::vector<T>;
136
153 [[nodiscard]] std::vector<std::string_view>
154 split (std::string_view input, std::string_view delimiters);
155
156 // ------------------------------------------------------------------------
157 } // namespace utility
158
159 // --------------------------------------------------------------------------
160} // namespace micro_os_plus::micro_test_plus
161
162// ----------------------------------------------------------------------------
163
164#if defined(__GNUC__)
165#pragma GCC diagnostic pop
166#endif // defined(__GNUC__)
167
168// ----------------------------------------------------------------------------
169
170#endif // defined(__cplusplus)
171
172// ============================================================================
173// Templates, inlines & constexpr implementations.
174
176
177// ----------------------------------------------------------------------------
178
179#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_UTILITY_H_
180
181// ----------------------------------------------------------------------------

Generated via doxygen2docusaurus 2.2.8 by Doxygen 1.18.0.