Files
Breeze/source/BreezeCore/include/breeze/Text.hpp
T
2026-10-24 09:53:48 -03:00

36 lines
1.3 KiB
C++

#pragma once
#include <string>
#include <string_view>
#include <vector>
/// Small string helpers; nothing here knows about breeze.
namespace breeze::text
{
std::string trim(std::string_view s);
std::vector<std::string> split(std::string_view s, char delimiter);
std::vector<std::string> splitLines(std::string_view s);
std::string join(const std::vector<std::string>& parts, std::string_view separator);
std::string lower(std::string_view s);
bool startsWith(std::string_view s, std::string_view prefix);
bool endsWith(std::string_view s, std::string_view suffix);
std::string replaceAll(std::string s, std::string_view from, std::string_view to);
/// "CoreFarewell" -> "core_farewell", "HTTPServer" -> "http_server", "my-app" -> "my_app".
std::string snakeCase(std::string_view s);
/// Lower-case letters and digits only: "Clang-CL" -> "clangcl". For comparing names loosely.
std::string normalized(std::string_view s);
/// A module or project name: a letter, then letters, digits, '_' (and '-' when allowDash).
bool isName(std::string_view s, bool allowDash = false);
/// A CMake target id as this project writes them: letters, digits, '_', '.', '+', '-' and "::".
bool isTargetId(std::string_view s);
/// "x" for a version-less message, with a '<none>' stand-in for an empty value.
std::string orNone(std::string_view s);
}