StormByte C++ Library 1.2.0
StormByte is a comprehensive, cross-platform C++ library aimed at easing system programming, configuration management, logging, and database handling tasks. This library provides a unified API that abstracts away the complexities and inconsistencies of different platforms (Windows, Linux).
Loading...
Searching...
No Matches
Namespaces | Enumerations | Functions
string.hxx File Reference
#include <StormByte/exception.hxx>
#include <StormByte/expected.hxx>
#include <StormByte/visibility.h>
#include <algorithm>
#include <cstddef>
#include <cmath>
#include <cctype>
#include <iomanip>
#include <locale>
#include <queue>
#include <sstream>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
Include dependency graph for string.hxx:

Go to the source code of this file.

Namespaces

namespace  StormByte
 Root namespace of the StormByte suite.
 
namespace  StormByte::String
 String helpers (case, split, UTF-8, human-readable numbers).
 

Enumerations

enum class  StormByte::String::Format : unsigned short { StormByte::String::Raw , StormByte::String::HumanReadableNumber , StormByte::String::HumanReadableBytes }
 How HumanReadable prints a number. More...
 

Functions

constexpr std::string StormByte::String::Indent (const int &level) noexcept
 level tab characters, or empty when level == 0.
 
constexpr bool StormByte::String::IsNumeric (std::string_view str) noexcept
 true when every character is a decimal digit (std::isdigit).
 
std::string StormByte::String::ToLower (std::string_view str) noexcept
 Lowercase copy of str.
 
std::string StormByte::String::ToUpper (std::string_view str) noexcept
 Uppercase copy of str.
 
std::queue< std::string > StormByte::String::Explode (std::string_view str, const char delimiter)
 Splits on delimiter into a queue (empty tokens kept).
 
std::vector< std::string > StormByte::String::Split (std::string_view str)
 Splits on ASCII whitespace into a vector.
 
template<typename T , typename = std::enable_if_t<std::is_arithmetic_v<T> && !std::is_same_v<T, wchar_t>>>
std::string StormByte::String::HumanReadable (const T &number, const Format &format, const std::string &locale="en_US.UTF-8") noexcept
 Formats an arithmetic value (not wchar_t).
 
std::string StormByte::String::UTF8Encode (std::wstring_view ws)
 Wide text to UTF-8.
 
std::wstring StormByte::String::UTF8Decode (std::string_view s)
 UTF-8 text to wide string.
 
std::string StormByte::String::SanitizeNewlines (std::string_view str) noexcept
 Normalizes \r\n to \n.
 
std::string StormByte::String::FromByteVector (const std::vector< std::byte > &byte_vector) noexcept
 Interprets bytes as char and builds a string.
 
std::vector< std::byte > StormByte::String::ToByteVector (std::string_view str) noexcept
 Copies text bytes into a vector<std::byte>.
 
std::string StormByte::String::RemoveWhitespace (std::string_view str) noexcept
 Strips every whitespace character.
 
bool StormByte::String::IsInteger (std::string_view str) noexcept
 true when str parses as an integer (optional leading +/-).