19 stream << std::string_view(stringView);
24 inline std::string& stringReplaceAll(std::string& str, std::string_view from, std::string_view to)
27 for (
size_t startPos = str.find(from, 0); startPos != std::string::npos; startPos = str.find(from, startPos + to.length())) {
28 str.replace(startPos, from.length(), to);
34 inline bool stringStartsWith(std::string_view str, std::string_view beginning) {
35 return str.find(beginning) == 0;
38 inline bool stringEndsWith(std::string_view str, std::string_view ending) {
39 size_t strLen = str.size();
40 size_t endLen = ending.size();
42 if (endLen <= strLen) {
43 return str.rfind(ending) == (strLen - endLen);
48 inline std::string stringToLower(std::string_view input)
52 output.reserve(input.size());
53 for (
const char c : input) {
54 output +=
static_cast<char>(std::tolower(c));
59 inline std::string stringToUpper(std::string_view input)
63 output.reserve(input.size());
64 for (
const char c : input) {
65 output +=
static_cast<char>(std::toupper(c));
77 struct hash<
Cogs::StringView>
Provides a weakly referenced view over the contents of a string.
Contains all Cogs related functionality.
constexpr size_t hash() noexcept
Simple getter function that returns the initial value for fnv1a hashing.
std::ostream & operator<<(std::ostream &stream, const Cogs::StringView &stringView)
Stream operator out provided to make it possible to insert Cogs::StringView into streams.
size_t operator()(const Cogs::StringView &v) const noexcept
Hash operator.