Files
Catch2/src/catch2/internal/catch_string_manip.hpp

39 lines
1.4 KiB
C++
Raw Normal View History

#ifndef CATCH_STRING_MANIP_HPP_INCLUDED
#define CATCH_STRING_MANIP_HPP_INCLUDED
2020-05-10 10:09:01 +02:00
#include <catch2/internal/catch_stringref.hpp>
#include <string>
#include <iosfwd>
2019-04-25 14:19:00 +01:00
#include <vector>
namespace Catch {
bool startsWith( std::string const& s, std::string const& prefix );
bool startsWith( std::string const& s, char prefix );
bool endsWith( std::string const& s, std::string const& suffix );
bool endsWith( std::string const& s, char suffix );
bool contains( std::string const& s, std::string const& infix );
void toLowerInPlace( std::string& s );
std::string toLower( std::string const& s );
2019-09-07 11:31:00 +02:00
//! Returns a new string without whitespace at the start/end
std::string trim( std::string const& str );
2019-09-07 11:31:00 +02:00
//! Returns a substring of the original ref without whitespace. Beware lifetimes!
StringRef trim(StringRef ref);
// !!! Be aware, returns refs into original string - make sure original string outlives them
std::vector<StringRef> splitStringRef( StringRef str, char delimiter );
bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis );
struct pluralise {
pluralise( std::size_t count, std::string const& label );
friend std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser );
std::size_t m_count;
std::string m_label;
};
}
#endif // CATCH_STRING_MANIP_HPP_INCLUDED