String
// Dynamically sized string using po2 memory.
class RVAPI String
{
public:
// Number of characters in string.
uint GetLen() const;
// Check if string ignores case during comparisons.
bool IsIgnoreCase() const;
// Implicitly convert this string object to a native C string.
operator wcstr () const;
// Assign [string] to this string.
String &operator = (wcstr string);
// Append [string] to this string.
String &operator += (wcstr string);
// Check if this string is less than [string]. If this string's [ignoreCase] is set case is ignored.
bool operator < (wcstr string) const { return Compare(*this, string, IsIgnoreCase()) < 0; }
// Check if this string is less than or equal to [string]. If this string's [ignoreCase] is set case is ignored.
bool operator <= (wcstr string) const { return Compare(*this, string, IsIgnoreCase()) <= 0; }
// Check if this string is equal to [string]. If this string's [ignoreCase] is set case is ignored.
bool operator == (wcstr string) const { return Compare(*this, string, IsIgnoreCase()) == 0; }
// Check if this string is not equal to [string]. If this string's [ignoreCase] is set case is ignored.
bool operator != (wcstr string) const { return Compare(*this, string, IsIgnoreCase()) != 0; }
// Check if this string is greater than or equal to [string]. If this string's [ignoreCase] is set case is ignored.
bool operator >= (wcstr string) const { return Compare(*this, string, IsIgnoreCase()) >= 0; }
// Check if this string is greater than [string]. If this string's [ignoreCase] is set case is ignored.
bool operator > (wcstr string) const { return Compare(*this, string, IsIgnoreCase()) > 0; }
// Compare [stringA] to [stringB]. Returns -1 if less than, 0 if equal to or 1 if greater than.
// Set [ignoreCase] to ignore case for this comparison.
static int Compare(wcstr stringA, wcstr stringB, bool ignoreCase = true);
// Assign [string] to this string. [string] can contain printf style format specifiers.
// Pass list of arguments [...] to match the format specifiers if any.
String &Format(uint reserve, wcstr string, ...);
// Same as Format() except arguments are passed as a stdlib va_list.
String &FormatArgs(uint reserve, wcstr string, va_list args);
// Clear string contents.
String &Clear();
// Internal.
void *operator () () const { return (void *)wobj; };
// Constructor to create an empty string buffer for storing and manipulating a string.
// Set [incr] to the estimated maximum characters. Set [ignoreCase] to ignore case for
// this string.
String(uint incr = 128, int ignoreCase = true);
// Constructor to create a string object intialized with [string].
// Set [ignoreCase] to ignore case for this string.
String(wcstr string, int ignoreCase = true);
// Destructor.
~String();
private:
byte wobj[32];
};