String utilities.
More...
|
GF_CORE_API std::string | gf::niceNum (float num, float precision) |
| Create a string representation of a floating point number. More...
|
|
GF_CORE_API std::string | gf::formatString (const char *fmt,...) |
| Format a string like printf. More...
|
|
GF_CORE_API std::string | gf::formatString (const char *fmt, va_list ap) |
| Format a string like vprintf. More...
|
|
GF_CORE_API std::string | gf::escapeString (std::string_view str) |
| Escape a string. More...
|
|
GF_CORE_API std::vector< std::string_view > | gf::splitInParagraphs (std::string_view str) |
| Split a string in multiples paragraphs. More...
|
|
GF_CORE_API std::vector< std::string_view > | gf::splitInWords (std::string_view str) |
| Split a string in multiples words. More...
|
|
String utilities.
◆ escapeString()
GF_CORE_API std::string gf::escapeString |
( |
std::string_view |
str | ) |
|
Escape a string.
This function replaces characters with their escaped equivalent. For example, a '\n' character is replaced with "\\\\n". This function can be used to display strings.
- Parameters
-
- Returns
- An escaped string
◆ formatString() [1/2]
GF_CORE_API std::string gf::formatString |
( |
const char * |
fmt, |
|
|
va_list |
ap |
|
) |
| |
Format a string like vprintf.
- Parameters
-
◆ formatString() [2/2]
GF_CORE_API std::string gf::formatString |
( |
const char * |
fmt, |
|
|
|
... |
|
) |
| |
Format a string like printf.
- Parameters
-
◆ niceNum()
GF_CORE_API std::string gf::niceNum |
( |
float |
num, |
|
|
float |
precision |
|
) |
| |
Create a string representation of a floating point number.
It is based on Python niceNum.
- Parameters
-
num | The number to display |
precision | The precision to use for display |
- Returns
- A string representing the number
◆ splitInParagraphs()
GF_CORE_API std::vector< std::string_view > gf::splitInParagraphs |
( |
std::string_view |
str | ) |
|
Split a string in multiples paragraphs.
The paragraphs are separated by '\n'.
- Parameters
-
- Returns
- A vector of strings containing the paragraphs
◆ splitInWords()
GF_CORE_API std::vector< std::string_view > gf::splitInWords |
( |
std::string_view |
str | ) |
|
Split a string in multiples words.
The words are separated by ' ' (space) or '\t' (tabulation).
- Parameters
-
- Returns
- A vector of strings containing the words