RSTools 3.1.0
Versatile C++20 utility library
Loading...
Searching...
No Matches
Char.hpp
Go to the documentation of this file.
1#pragma once
2
3namespace RST::String {
4
8 [[nodiscard]] constexpr bool isSpace(char c) noexcept { return c == ' ' || (c >= '\t' && c <= '\r'); }
9 [[nodiscard]] constexpr bool isDigit(char c) noexcept { return c >= '0' && c <= '9'; }
10 [[nodiscard]] constexpr bool isUpper(char c) noexcept { return c >= 'A' && c <= 'Z'; }
11 [[nodiscard]] constexpr bool isLower(char c) noexcept { return c >= 'a' && c <= 'z'; }
12 [[nodiscard]] constexpr bool isAlpha(char c) noexcept { return isUpper(c) || isLower(c); }
13 [[nodiscard]] constexpr bool isAlnum(char c) noexcept { return isAlpha(c) || isDigit(c); }
14 [[nodiscard]] constexpr bool isHexDigit(char c) noexcept { return isDigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'); }
15
16 [[nodiscard]] constexpr char toLower(char c) noexcept { return isUpper(c) ? static_cast<char>(c + ('a' - 'A')) : c; }
17 [[nodiscard]] constexpr char toUpper(char c) noexcept { return isLower(c) ? static_cast<char>(c - ('a' - 'A')) : c; }
19
20}
String helpers: case, trimming, splitting, joining, replacing, parsing and hashing.
Definition Char.hpp:3
constexpr bool isHexDigit(char c) noexcept
Definition Char.hpp:14
constexpr char toLower(char c) noexcept
Definition Char.hpp:16
constexpr bool isSpace(char c) noexcept
Definition Char.hpp:8
constexpr char toUpper(char c) noexcept
Definition Char.hpp:17
constexpr bool isLower(char c) noexcept
Definition Char.hpp:11
constexpr bool isAlpha(char c) noexcept
Definition Char.hpp:12
constexpr bool isAlnum(char c) noexcept
Definition Char.hpp:13
constexpr bool isUpper(char c) noexcept
Definition Char.hpp:10
constexpr bool isDigit(char c) noexcept
Definition Char.hpp:9
std::optional< T > parseNumber(std::string_view text, int base=10) noexcept
Parses text as a number, or returns std::nullopt if it is not entirely one.
Definition Convert.hpp:23