|
libcosmos
Linux C++ System Programming Library
|
#include <cctype>#include <cstring>#include <string>#include <string_view>#include <vector>#include <cosmos/dso_export.h>#include <cosmos/BitMask.hxx>#include <cosmos/SysString.hxx>Go to the source code of this file.
Classes | |
| struct | cosmos::CompareCString |
| Comparison type for std::map and similar containers with plain char* as keys. More... | |
Typedefs | |
| using | cosmos::StringVector = std::vector<std::string> |
| A vector of std::string. | |
| using | cosmos::StringViewVector = std::vector<std::string_view> |
| A vector of std::string_view. | |
| using | cosmos::CStringVector = std::vector<const char*> |
A vector of plain const char*. | |
| using | cosmos::SysStringVector = std::vector<SysString> |
| A vector of c-string wrappers. | |
| using | cosmos::SplitFlags = BitMask<SplitFlag> |
Enumerations | |
| enum class | cosmos::SplitFlag { STRIP_PARTS = 0x1 , KEEP_EMPTY = 0x2 } |
| Bitmask for algorithm settings of the split() function. More... | |
Functions | |
| std::string | cosmos::to_lower (const std::string_view s) |
Returns an all lower case version of s. | |
| std::string | cosmos::to_upper (const std::string_view s) |
Returns an all upper case version of s. | |
| std::wstring | cosmos::to_lower (const std::wstring_view s) |
Returns an all lower case version of s. | |
| std::wstring | cosmos::to_upper (const std::wstring_view s) |
Returns an all upper case version of s. | |
| void | cosmos::strip (std::string &s) |
| Strips leading and trailing whitespace from the given string in-place. | |
| std::string | cosmos::stripped (const std::string_view s) |
| Returns a version of the given string with stripped off leading and trailing whitespace. | |
| void | cosmos::strip (std::wstring &s) |
| Wide string variant of strip(std::string &s) | |
| std::wstring | cosmos::stripped (const std::wstring_view s) |
| Wide string variant of stripped(const std::string_view) | |
| bool | cosmos::is_prefix (const std::string_view s, const std::string_view prefix) |
Returns whether prefix is a prefix of s. | |
| bool | cosmos::is_suffix (const std::string_view s, const std::string_view suffix) |
Returns whether suffix is a suffix of s. | |
| std::string_view | cosmos::to_string_view (const char *s) |
Simple wrapper that creates a string_view from s and supports also nullptr. | |
| template<typename CH > | |
| bool | cosmos::printable (CH ch) |
| Simple wrapper around std::isprint that implicitly casts to unsigned char. | |
| template<typename CHAR > | |
| COSMOS_API std::vector< std::basic_string< CHAR > > | cosmos::split (const std::basic_string_view< CHAR > str, const std::basic_string_view< CHAR > sep, const SplitFlags flags=SplitFlags{}) |
| Split a string at separator boundaries. | |
| std::vector< std::string > | cosmos::split (const std::string_view str, const std::string_view sep, const SplitFlags flags=SplitFlags{}) |
This header contains helper functions and types for dealing with std::string objects and general string processing topics.
Definition in file string.hxx.
| using cosmos::CStringVector = std::vector<const char*> |
A vector of plain const char*.
Definition at line 22 of file string.hxx.
| using cosmos::SplitFlags = BitMask<SplitFlag> |
Definition at line 114 of file string.hxx.
| using cosmos::StringVector = std::vector<std::string> |
A vector of std::string.
Definition at line 18 of file string.hxx.
| using cosmos::StringViewVector = std::vector<std::string_view> |
A vector of std::string_view.
Definition at line 20 of file string.hxx.
| using cosmos::SysStringVector = std::vector<SysString> |
A vector of c-string wrappers.
Definition at line 24 of file string.hxx.
|
strong |
Bitmask for algorithm settings of the split() function.
| Enumerator | |
|---|---|
| STRIP_PARTS | Strip each extracted part using strip(). |
| KEEP_EMPTY | When multiple subsequent separators occur, keep empty parts in the result. |
Definition at line 107 of file string.hxx.
|
inline |
Returns whether prefix is a prefix of s.
Definition at line 71 of file string.hxx.
|
inline |
Returns whether suffix is a suffix of s.
Definition at line 77 of file string.hxx.
|
inline |
Simple wrapper around std::isprint that implicitly casts to unsigned char.
std::isprint is undefined if the passed value is not an unsigned 8 bit type or EOF. Thus cast different character types to unsigned char in this wrapper to avoid this trap.
Definition at line 101 of file string.hxx.
| COSMOS_API std::vector< std::basic_string< CHAR > > cosmos::split | ( | const std::basic_string_view< CHAR > | str, |
| const std::basic_string_view< CHAR > | sep, | ||
| const SplitFlags | flags = SplitFlags{} ) |
Split a string at separator boundaries.
The input string str will be split up at every occurrence of the sep substring. The resulting parts are returned as a vector. By default subsequent occurrences of sep are ignored. If SplitFlag::KEEP_EMPTY is set in flags then empty elements will be returned for these occurrences instead.
Definition at line 80 of file string.cxx.
|
inline |
Definition at line 131 of file string.hxx.
| void COSMOS_API cosmos::strip | ( | std::string & | s | ) |
Strips leading and trailing whitespace from the given string in-place.
Definition at line 63 of file string.cxx.
| void COSMOS_API cosmos::strip | ( | std::wstring & | s | ) |
Wide string variant of strip(std::string &s)
Definition at line 71 of file string.cxx.
|
inline |
Returns a version of the given string with stripped off leading and trailing whitespace.
Definition at line 54 of file string.hxx.
|
inline |
Wide string variant of stripped(const std::string_view)
Definition at line 64 of file string.hxx.
| std::string COSMOS_API cosmos::to_lower | ( | const std::string_view | s | ) |
Returns an all lower case version of s.
Definition at line 11 of file string.cxx.
| std::wstring COSMOS_API cosmos::to_lower | ( | const std::wstring_view | s | ) |
Returns an all lower case version of s.
Definition at line 37 of file string.cxx.
|
inline |
Simple wrapper that creates a string_view from s and supports also nullptr.
The std::string_view constructor does not allow a nullptr argument. This wrapper makes this limitation transparent by returning an empty string_view for nullptr C strings.
Definition at line 90 of file string.hxx.
| std::string COSMOS_API cosmos::to_upper | ( | const std::string_view | s | ) |
Returns an all upper case version of s.
Definition at line 24 of file string.cxx.
| std::wstring COSMOS_API cosmos::to_upper | ( | const std::wstring_view | s | ) |
Returns an all upper case version of s.
Definition at line 50 of file string.cxx.