This rtools class primarily provides a collection of static methods that facilitate a variety of general-purpose computer programming needs. Separate classes may also be added in the future for more sophisticated needs.
More...
|
static std::vector< std::string > * | atomize (const char *str, size_t len=0) |
| Split string into an std::vector that's perfectly-sized to store all the elements separated by whitespace, but not whitespace that's enclosed within quotation marks (literal quotation marks - " - will not be intrepreted, and will be treated as literal/non-functional non-whitespace characters). More...
|
|
static std::vector< std::string > * | atomize (std::string str, size_t len=0) |
| Split string into an std::vector that's perfectly-sized to store all the elements separated by whitespace, but not whitespace that's enclosed within quotation marks (literal quotation marks - " - will not be intrepreted, and will be treated as literal/non-functional non-whitespace characters). More...
|
|
static std::string | insert_commas (const char *value, size_t len=0, bool skip_dot=true, const int digits=3, const char *comma=",", const char *space=" ", const char dot='.') noexcept |
| Insert commas into the last numeric sequence of digits in the supplied string and insert spaces before that (commas and spaces are configurable). If a decimal point is found, then comma insertions will occur before that (this is also configurable). More...
|
|
static std::string | to_hex (const int i) noexcept |
| Convert a 32-bit integer to hexadecimal. More...
|
|
static std::string | to_lower (std::string &str, bool in_place_conversion=false) noexcept |
| Convert ASCII characters in an std::string to lower case. UTF-8 characters are not converted. More...
|
|
static std::string | to_upper (std::string &str, bool in_place_conversion=false) noexcept |
| Convert ASCII characters in an std::string to upper case. UTF-8 characters are not converted. More...
|
|
This rtools class primarily provides a collection of static methods that facilitate a variety of general-purpose computer programming needs. Separate classes may also be added in the future for more sophisticated needs.
- History
- 2023-May-17 rtools v1.00 by Randolf Richardson.
◆ atomize() [1/2]
static std::vector<std::string>* randolf::rtools::atomize |
( |
const char * |
str, |
|
|
size_t |
len = 0 |
|
) |
| |
|
inlinestatic |
Split string into an std::vector
that's perfectly-sized to store all the elements separated by whitespace, but not whitespace that's enclosed within quotation marks (literal quotation marks - "
- will not be intrepreted, and will be treated as literal/non-functional non-whitespace characters).
Any leading and/or trailing whitespace characters will be ignored.
Multiple whitespace delimiters will be treated as a single delimiter.
Whitespace characters:
- 0: NULL
- 9: Tab
- 10: Linefeed
- 13: Carriage Return
- 32: Space
- Returns
- Pointer to an array of "atoms" stored in an
std::vector
object
- Parameters
-
str | Source string (to be split into atoms) |
len | Length of string (in bytes), or 0 if str is an ASCIIZ string (NULL-terminated) |
◆ atomize() [2/2]
static std::vector<std::string>* randolf::rtools::atomize |
( |
std::string |
str, |
|
|
size_t |
len = 0 |
|
) |
| |
|
inlinestatic |
Split string into an std::vector
that's perfectly-sized to store all the elements separated by whitespace, but not whitespace that's enclosed within quotation marks (literal quotation marks - "
- will not be intrepreted, and will be treated as literal/non-functional non-whitespace characters).
Any leading and/or trailing whitespace characters will be ignored.
Multiple whitespace delimiters will be treated as a single delimiter.
Whitespace characters:
- 0: NULL
- 9: Tab
- 10: Linefeed
- 13: Carriage Return
- 32: Space
- Returns
- Pointer to an array of "atoms" stored in an
std::vector
object
- Parameters
-
str | Source string (to be split into atoms) |
len | Length of string (in bytes), or 0 if str is an ASCIIZ string (NULL-terminated) |
◆ insert_commas()
static std::string randolf::rtools::insert_commas |
( |
const char * |
value, |
|
|
size_t |
len = 0 , |
|
|
bool |
skip_dot = true , |
|
|
const int |
digits = 3 , |
|
|
const char * |
comma = "," , |
|
|
const char * |
space = " " , |
|
|
const char |
dot = '.' |
|
) |
| |
|
inlinestaticnoexcept |
Insert commas into the last numeric sequence of digits in the supplied string and insert spaces before that (commas and spaces are configurable). If a decimal point is found, then comma insertions will occur before that (this is also configurable).
- Returns
- Numeric value as a char* array converted to a properly-delimited string as an std::string
- Parameters
-
value | Pointer to ASCII representation of numeric value |
len | Length of value (in bytes), or 0 to auto-detect length if value string is an ASCIIZ string |
skip_dot | Don't insert any commas after the last period (or whatever string is set as the dot character) |
digits | Number of digits between commas |
comma | Pointer to ASCIIZ comma character string (nullptr = disabled) |
space | Pointer to ASCIIZ space character string (nullptr = disabled) used instead of commas for non-digit fill-ins where commas would normally be inserted |
dot | Period character used when skip_dot is enabled |
◆ to_hex()
static std::string randolf::rtools::to_hex |
( |
const int |
i | ) |
|
|
inlinestaticnoexcept |
Convert a 32-bit integer to hexadecimal.
This method is needed because std::to_string() doesn't include an option to specify the radix.
- Returns
- Up to 8 hexadecimal characters
- Parameters
-
i | Integer to convert to hexadecimal |
◆ to_lower()
static std::string randolf::rtools::to_lower |
( |
std::string & |
str, |
|
|
bool |
in_place_conversion = false |
|
) |
| |
|
inlinestaticnoexcept |
Convert ASCII characters in an std::string to lower case. UTF-8 characters are not converted.
- Returns
- Copy of std::string, in lower-case form
- See also
- to_upper
- Parameters
-
str | Source string |
in_place_conversion | Perform in-place conversion (default is FALSE / non-destructive) |
◆ to_upper()
static std::string randolf::rtools::to_upper |
( |
std::string & |
str, |
|
|
bool |
in_place_conversion = false |
|
) |
| |
|
inlinestaticnoexcept |
Convert ASCII characters in an std::string to upper case. UTF-8 characters are not converted.
- Returns
- Copy of std::string, in upper-case form
- See also
- to_lower
- Parameters
-
str | Source string |
in_place_conversion | Perform in-place conversion (default is FALSE / non-destructive) |
The documentation for this class was generated from the following file: