Functions | |
void | ReplaceAllInString (std::string *string, std::string const &string_to_replace, std::string const &string_to_replace_with) |
Find and replace all instances of string_to_replace inside string , using string_to_replace_with . | |
std::string | StringPrintf (char const *format,...) |
Performs printf into an STL string and returns it. | |
void | StringPrintf (std::string *string, char const *format,...) |
Performs printf into the provided STL string. | |
char * | StringDuplicate (char const *string_to_duplicate) |
Returns a newly allocated copy of the given string. | |
char | Lowercase (char c) |
If c is an uppercase letter, returns it in lowercase, otherwise returns c. | |
char | Uppercase (char c) |
If c is a lowercase letter, returns it in uppercase, otherwise returns c. | |
void | MakeLowercase (std::string *str) |
Converts all alphabetic characters in the string to lowercase. | |
void | MakeUppercase (std::string *str) |
Converts all alphabetic characters in the string to uppercase. | |
char | ShiftedAscii (char c) |
Returns the ASCII code of the given character as it would be interpreted with the SHIFT key held down. | |
bool | CharacterLiteralCharNeedsEscaping (char c) |
Returns true iff the given character needs to be escaped to be properly represented in a C-style character literal. | |
bool | StringLiteralCharNeedsEscaping (char c) |
Returns true iff the given character needs to be escaped to be properly represented in a C-style string literal. | |
char | EscapeCode (char c) |
Returns the escape character code for escaped characters. | |
char | EscapedChar (char c) |
Returns the escaped character for the given escape code. | |
std::string | CharacterLiteral (char c) |
Returns the single-quote-surrounded C-style character literal for the given character in the form of a std::string. | |
std::string | StringLiteral (std::string const &text) |
Returns the double-quote-surrounded C-style string literal for the given text in the form of a std::string. | |
template<typename Sint > | |
Sint | TextToSint (char const *const text) |
Returns the signed, base 10 integer value parsed from the given text. | |
template<typename Uint > | |
Uint | TextToUint (char const *const text) |
Returns the unsigned, base 10 integer value parsed from the given text. | |
Float | TextToFloat (char const *const text) |
Returns the floating point value parsed from the given text. | |
Float | TextToFloat (char const *const text, char const **const end) |
Returns the floating point value parsed from the given text. | |
char const * | IOErrorString (IOError error) |
Returns textual representations of the IOError enums. | |
std::string | DirectoryPortion (std::string const &path) |
Returns only the directory portion of the given path. | |
std::string | FilenamePortion (std::string const &path) |
Returns only the filename portion of the given path. |
These functions are more or less for convenience, and don't provide any significant algorithmic computation.
char * Xrb::Util::StringDuplicate | ( | char const * | string_to_duplicate | ) |
Returns a newly allocated copy of the given string.
The returned string is a NULL-terminated ASCII string, of exactly the length of string_to_duplicate
.
Definition at line 79 of file xrb_util.cpp.
char Xrb::Util::Lowercase | ( | char | c | ) |
If c is an uppercase letter, returns it in lowercase, otherwise returns c.
c | The character to convert to lowercase. |
Definition at line 91 of file xrb_util.cpp.
char Xrb::Util::Uppercase | ( | char | c | ) |
If c is a lowercase letter, returns it in uppercase, otherwise returns c.
c | The character to convert to uppercase. |
Definition at line 99 of file xrb_util.cpp.
char Xrb::Util::EscapeCode | ( | char | c | ) |
Returns the escape character code for escaped characters.
For example, EscapeCode('') returns '0'.
This function returns the given character if it is not an escapable character (e.g. EscapeCode('j') returns 'j'.
EscapedChar(EscapeCode(c)) should return c.
Definition at line 164 of file xrb_util.cpp.
Referenced by CharacterLiteral(), and StringLiteral().
char Xrb::Util::EscapedChar | ( | char | c | ) |
Returns the escaped character for the given escape code.
For example, EscapedChar('0') returns ''.
This function returns the given character if it is not an escapable character (e.g. EscapedChar('h') returns 'h'.
EscapeCode(EscapedChar(c)) should return c.
Definition at line 182 of file xrb_util.cpp.
std::string Xrb::Util::CharacterLiteral | ( | char | c | ) |
Returns the single-quote-surrounded C-style character literal for the given character in the form of a std::string.
For example, CharacterLiteral('
') returns std::string("'\\n'"), while CharacterLiteral('j') returns std::string("'j'").
Definition at line 200 of file xrb_util.cpp.
References CharacterLiteralCharNeedsEscaping(), and EscapeCode().
std::string Xrb::Util::StringLiteral | ( | std::string const & | text | ) |
Returns the double-quote-surrounded C-style string literal for the given text in the form of a std::string.
For example, StringLiteral("eat shit\t\"and die\".") returns std::string("\"eat shit\t\\"and die\\\".\"").
Definition at line 211 of file xrb_util.cpp.
References EscapeCode(), and StringLiteralCharNeedsEscaping().
Float Xrb::Util::TextToFloat | ( | char const *const | text, | |
char const **const | end | |||
) | [inline] |
Returns the floating point value parsed from the given text.
The extra parameter will return a pointer to the portion of the string after the numeric value.
Definition at line 145 of file xrb_util.hpp.
std::string Xrb::Util::DirectoryPortion | ( | std::string const & | path | ) |
Returns only the directory portion of the given path.
The "slash" (directory delimiter) is '/' and the final '/' will be included in the return value.
Definition at line 247 of file xrb_util.cpp.
std::string Xrb::Util::FilenamePortion | ( | std::string const & | path | ) |
Returns only the filename portion of the given path.
The "slash" (directory delimiter) is '/'. This function returns everything after the final '/'.
Definition at line 256 of file xrb_util.cpp.