Hermes
|
String class and set of string functions. More...
Classes | |
struct | regex |
Public Member Functions | |
template<typename T > | |
bool friend | operator== (const T &t, const Str &s) |
Character-wise comparison. More... | |
Str () | |
Default constructor. | |
Str (std::string s) | |
Constructor from std::string More... | |
Str (const char *s) | |
Constructor from const char* 's contents copy. More... | |
Str (const Str &other) | |
Copy constructor. More... | |
Str (Str &&other) noexcept | |
Move constructor. More... | |
const std::string & | str () const |
Get std::string object. More... | |
const char * | c_str () const |
Get const char* pointer. More... | |
size_t | size () const |
Get the number of characters on the string. More... | |
bool | empty () const |
Checks if string is empty. More... | |
Result< ConstStrView > | substr (size_t pos=0, i64 len=-1) |
Get a sub-string view from this object. More... | |
template<class... Args> | |
void | append (const Args &... args) |
Append arguments to this Str. More... | |
template<class... Args> | |
void | appendLine (const Args &... args) |
Append arguments to this Str followed by a breakline. More... | |
Str & | operator= (const Str &s)=default |
template<typename T > | |
Str & | operator= (const T &t) |
String of value assignment. More... | |
Str & | operator+= (const Str &other) |
Simple concatenation with other More... | |
template<typename T > | |
Str & | operator+= (const T &t) |
Simple concatenation with string of value. More... | |
template<typename T > | |
Str | operator+ (const T &t) const |
Generates a copy appended by t More... | |
Str | operator<< (const char *s) const |
Generates a copy appended by s More... | |
bool | operator== (const char *ss) const |
Performs const char* comparison. More... | |
template<typename T > | |
bool | operator== (const T &t) const |
Performs character comparison with string value of t More... | |
Static Public Member Functions | |
static bool | isPrefix (const std::string &p, const std::string &s) |
Checks if s has prefix p. More... | |
static std::string | abbreviate (const std::string &s, size_t width, const char fmt[4]="s.s") |
Abbreviates a string to fit in a string of width characters. More... | |
template<typename T > | |
static std::string | rjust (const T &value, size_t width, char fill_char=' ') |
Right justifies string value. More... | |
template<typename T > | |
static std::string | ljust (const T &value, size_t width, char fill_char=' ') |
Left justifies string value. More... | |
template<typename T > | |
static std::string | cjust (const T &value, size_t width, char fill_char=' ') |
Center justifies string value. More... | |
template<typename... Ts> | |
static std::string | format (const std::string &fmt, Ts &&... args) |
template<typename T > | |
static std::string | toHex (T i, bool leading_zeros=false, bool zero_x=false) |
Generates hexadecimal representation from number. More... | |
static std::string | strip (const std::string &s, const std::string &patterns=" \t\n") |
template<class... Args> | |
static std::string | concat (const Args &... args) |
Concatenates multiple elements_ into a single string. More... | |
static std::string | join (const std::vector< std::string > &v, const std::string &separator="") |
Concatenate strings together separated by a separator. More... | |
template<typename T > | |
static std::string | join (const std::vector< T > &v, const std::string &separator="") |
Concatenate elements together separates by a separator. More... | |
static std::vector< std::string > | split (const std::string &s, const std::string &delimiters=" ") |
Splits a string into tokens separated by delimiters. More... | |
static std::string | printBits (u32 n) |
Print bits in big-endian order. More... | |
template<typename T > | |
static std::string | binaryToHex (T input_n, bool uppercase=true, bool strip_leading_zeros=false) |
Get ascii representation of raw bit data of input_n More... | |
static std::string | addressOf (uintptr_t ptr, u32 digit_count=8) |
Generates hexadecimal representation of memory address. More... | |
static std::string | byteToBinary (byte b) |
Binary representation of byte. More... | |
static bool | isInteger (const std::string &s) |
Checks if string represents an integer. More... | |
static bool | isNumber (const std::string &s) |
Checks if string represents a number. More... | |
Friends | |
Str | operator<< (const char *s, const Str &str) |
Concatenate. More... | |
Str | operator+ (const std::string &s, const Str &str) |
Concatenate. More... | |
bool | operator== (const char *ss, const Str &s) |
const char* pointer comparison More... | |
String class and set of string functions.
hermes::Str::Str | ( | std::string | s | ) |
Constructor from std::string
s |
hermes::Str::Str | ( | const char * | s | ) |
Constructor from const char*
's contents copy.
s |
|
default |
Copy constructor.
other |
|
noexcept |
Move constructor.
other |
|
static |
Abbreviates a string to fit in a string of width characters.
s | input string |
width | final character count |
fmt | a three-character string describing the abbreviation type: ("..s", "s.s", ".s.", or "..s"). where 's' represents the input string contents and '.' the abbreviated portion of s. |
|
inlinestatic |
Generates hexadecimal representation of memory address.
ptr | |
digit_count |
|
inline |
Append arguments to this Str.
std::ostringstream
Args |
args |
|
inline |
Append arguments to this Str followed by a breakline.
std::ostringstream
Args |
args |
|
inlinestatic |
Get ascii representation of raw bit data of input_n
T |
input_n | |
uppercase | |
strip_leading_zeros |
|
inlinestatic |
Binary representation of byte.
b |
|
inline |
Get const char*
pointer.
|
inlinestatic |
Center justifies string value.
T | string-convertible type |
value | |
width | output size |
fill_char |
|
inlinestatic |
Concatenates multiple elements_ into a single string.
Args |
args |
|
inline |
Checks if string is empty.
|
inlinestatic |
Ts |
fmt | |
args |
|
static |
Checks if string represents an integer.
s |
|
static |
Checks if string represents a number.
s |
|
static |
Checks if s has prefix p.
p | prefix string |
s | string |
|
static |
Concatenate strings together separated by a separator.
v | array of strings |
separator | [in | ""] |
|
inlinestatic |
Concatenate elements together separates by a separator.
std::stringstream
T | element type |
v | |
separator |
|
inlinestatic |
Left justifies string value.
T | string-convertible type |
value | |
width | output size |
fill_char |
|
inline |
Generates a copy appended by t
std::stringstream
T |
t |
Simple concatenation with other
other |
|
inline |
Simple concatenation with string of value.
std::stringstream
T |
t |
|
inline |
Generates a copy appended by s
s |
|
inline |
String of value assignment.
std::stringstream
T |
t |
|
inline |
Performs const char* comparison.
ss |
|
inline |
Performs character comparison with string value of t
std::stringstream
|
inline |
Character-wise comparison.
T |
t | |
s |
|
inlinestatic |
Print bits in big-endian order.
n |
|
inlinestatic |
Right justifies string value.
T | string-convertible type |
value | |
width | output size |
fill_char |
|
inline |
Get the number of characters on the string.
|
static |
Splits a string into tokens separated by delimiters.
s | [in] input string |
delimiters | [in | default = " "] delimiters |
|
inline |
Get std::string
object.
|
static |
s | |
patterns |
Result< ConstStrView > hermes::Str::substr | ( | size_t | pos = 0 , |
i64 | len = -1 |
||
) |
Get a sub-string view from this object.
pos | position of the first character of the sub-string in str. |
len | number of characters of the sub-string. If len = -1, then the size is str.size() - pos. |
|
inlinestatic |
Generates hexadecimal representation from number.
i
T |
i | number |
leading_zeros | puts leading zeros up to the size of T |
zero_x | puts the "0x" suffix |
Concatenate.
s | |
str |
|
friend |
const char*
pointer comparison
ss | |
s |