File Coverage

/usr/local/lib/perl5/site_perl/5.26.1/x86_64-linux/XS/libcatch.x/i/catch2/internal/catch_string_manip.hpp
Criterion Covered Total %
statement 0 3 0.0
branch n/a
condition n/a
subroutine n/a
pod n/a
total 0 3 0.0


line stmt bran cond sub pod time code
1              
2             // Copyright Catch2 Authors
3             // Distributed under the Boost Software License, Version 1.0.
4             // (See accompanying file LICENSE_1_0.txt or copy at
5             // https://www.boost.org/LICENSE_1_0.txt)
6              
7             // SPDX-License-Identifier: BSL-1.0
8             #ifndef CATCH_STRING_MANIP_HPP_INCLUDED
9             #define CATCH_STRING_MANIP_HPP_INCLUDED
10              
11             #include
12              
13             #include
14             #include
15             #include
16              
17             namespace Catch {
18              
19             bool startsWith( std::string const& s, std::string const& prefix );
20             bool startsWith( StringRef s, char prefix );
21             bool endsWith( std::string const& s, std::string const& suffix );
22             bool endsWith( std::string const& s, char suffix );
23             bool contains( std::string const& s, std::string const& infix );
24             void toLowerInPlace( std::string& s );
25             std::string toLower( std::string const& s );
26             char toLower( char c );
27             //! Returns a new string without whitespace at the start/end
28             std::string trim( std::string const& str );
29             //! Returns a substring of the original ref without whitespace. Beware lifetimes!
30             StringRef trim(StringRef ref);
31              
32             // !!! Be aware, returns refs into original string - make sure original string outlives them
33             std::vector splitStringRef( StringRef str, char delimiter );
34             bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis );
35              
36             /**
37             * Helper for streaming a "count [maybe-plural-of-label]" human-friendly string
38             *
39             * Usage example:
40             * ```cpp
41             * std::cout << "Found " << pluralise(count, "error") << '\n';
42             * ```
43             *
44             * **Important:** The provided string must outlive the instance
45             */
46             struct pluralise {
47 0           pluralise(std::size_t count, StringRef label):
48             m_count(count),
49 0           m_label(label)
50 0           {}
51              
52             friend std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser );
53              
54             std::size_t m_count;
55             StringRef m_label;
56             };
57             }
58              
59             #endif // CATCH_STRING_MANIP_HPP_INCLUDED