Free Electron
|
Automatically reference-counted string container. More...
#include <DualString.h>
Public Member Functions | |
DualString (void) | |
Construct an empty string. More... | |
DualString (const DualString &operand) | |
Copy constructor. More... | |
DualString (const FESTRING_I8 *operand) | |
Construct using a signed byte buffer. More... | |
DualString (const FESTRING_U8 *operand) | |
Construct using a unsigned byte buffer. More... | |
DualString (const FESTRING_WIDE *operand) | |
Construct using a wide buffer, presumably Unicode. More... | |
DualString (I32 operand) | |
allow init as 0 in templates More... | |
operator const FESTRING_I8 * (void) const | |
Cast the contents of the 8-bit buffer as signed bytes. More... | |
operator const FESTRING_U8 * (void) const | |
Cast the contents of the 8-bit buffer as unsigned bytes. More... | |
operator const FESTRING_WIDE * (void) const | |
Cast the contents of the wide buffer as Unicode. More... | |
DualString & | operator= (const DualString &operand) |
Compare to another DualString. More... | |
DualString & | operator= (const FESTRING_I8 *operand) |
Compare to a signed byte buffer (using 8-bit). More... | |
DualString & | operator= (const FESTRING_U8 *operand) |
Compare to an unsigned byte buffer (using 8-bit). More... | |
DualString & | operator= (const FESTRING_WIDE *operand) |
Compare to an unicode buffer (using wide chars). More... | |
I32 | compare (const DualString &operand) const |
Standard string compare: returns -1, 0, or 1 if the string is alphabetically less than, equal, or greater than the operand. More... | |
BWORD | operator< (const DualString &operand) const |
BWORD | dotMatch (const DualString &operand) const |
Compares to another string assuming the given string is a dot-delimited ordered list containing optional substrings. More... | |
void | forceUppercase (void) |
Force all applicable characters to upper case. More... | |
void | forceLowercase (void) |
Force all applicable characters to lower case. More... | |
U32 | length (void) const |
Return the number of represented characters, but not necessarily the size of any buffer. More... | |
DualString & | sPrintf (const char *fmt,...) |
Populate the string in the manner of sprintf(). More... | |
DualString & | catf (const char *fmt,...) |
Populate the string as with SPrintf(), but by concatenating the results to the existing string. More... | |
DualString & | cat (std::list< DualString > &strList, DualString sep="") |
Concatenate the strings in a list. More... | |
DualString & | vsPrintf (const char *fmt, va_list ap) |
Populate using variable arg format. More... | |
const FESTRING_I8 * | raw (void) const |
Return the contents of the 8-bit buffer cast as signed bytes. More... | |
const FESTRING_I8 * | c_str (void) const |
Return the contents of the 8-bit buffer cast as signed bytes. More... | |
const FESTRING_U8 * | rawU8 (void) const |
Return the contents of the 8-bit buffer cast as unsigned bytes. More... | |
const FESTRING_WIDE * | rawWide (void) const |
Return the contents of the wide buffer cast in native unicode format. More... | |
void | output (std::ostream &ostrm) const |
void | input (std::istream &istrm) |
Private Member Functions | |
DualString | copy (void) const |
Returns a new string with a copied underlying representation. More... | |
void | init (void) |
void | forceCase (BWORD upper) |
void | confirm8 (void) |
void | confirmWide (void) |
virtual Rep * | newRep (void) |
virtual void | deleteRep (void) |
Static Private Member Functions | |
static U32 | strlenWide (const FESTRING_WIDE *buffer) |
Private Attributes | |
Rep * | m_pRep |
Automatically reference-counted string container.
Designed to behave as a native type, like float or int. All allocation worries are completely hidden.
To assign a string just use simple assignments.
You can compare strings in a boolean or lexical fashion.
To print a string in printf fashion, cast it to (char*) or use c_str().
Operates in multiple formats with JIT conversion.
TODO consider fixed local buffer for small strings to avoid new()
Reference: Stroustrup C++ Ref Man, 2nd ed., pg. 248
fe::DualString::DualString | ( | void | ) |
Construct an empty string.
fe::DualString::DualString | ( | const DualString & | operand | ) |
Copy constructor.
fe::DualString::DualString | ( | const FESTRING_I8 * | operand | ) |
Construct using a signed byte buffer.
fe::DualString::DualString | ( | const FESTRING_U8 * | operand | ) |
Construct using a unsigned byte buffer.
fe::DualString::DualString | ( | const FESTRING_WIDE * | operand | ) |
Construct using a wide buffer, presumably Unicode.
fe::DualString::DualString | ( | I32 | operand | ) |
allow init as 0 in templates
|
inline |
Return the contents of the 8-bit buffer cast as signed bytes.
Referenced by cat(), catf(), fe::operator!=(), and output().
DualString & fe::DualString::cat | ( | std::list< DualString > & | strList, |
DualString | sep = "" |
||
) |
DualString & fe::DualString::catf | ( | const char * | fmt, |
... | |||
) |
Populate the string as with SPrintf(), but by concatenating the results to the existing string.
References c_str(), sPrintf(), and vsPrintf().
Referenced by cat(), forceLowercase(), and fe::operator!=().
I32 fe::DualString::compare | ( | const DualString & | operand | ) | const |
Standard string compare: returns -1, 0, or 1 if the string is alphabetically less than, equal, or greater than the operand.
Referenced by fe::operator!=(), and fe::operator==().
|
private |
Returns a new string with a copied underlying representation.
Note that the normal operator=() uses the same representation. This method is provided in case data from an alternate heap may be destroyed. This is primarily a Win32 DLL issue. Note that DualString is already safe across live heaps.
References length().
BWORD fe::DualString::dotMatch | ( | const DualString & | operand | ) | const |
Compares to another string assuming the given string is a dot-delimited ordered list containing optional substrings.
Returns true if strings are exactly the same, or if they match only up to the length of the operand and the operand's terminating zero matches a period.
|
inline |
Force all applicable characters to lower case.
References cat(), catf(), length(), sPrintf(), and vsPrintf().
|
inline |
Force all applicable characters to upper case.
U32 fe::DualString::length | ( | void | ) | const |
Return the number of represented characters, but not necessarily the size of any buffer.
Referenced by copy(), and forceLowercase().
|
inline |
Cast the contents of the 8-bit buffer as signed bytes.
|
inline |
Cast the contents of the 8-bit buffer as unsigned bytes.
|
inline |
Cast the contents of the wide buffer as Unicode.
DualString & fe::DualString::operator= | ( | const DualString & | operand | ) |
Compare to another DualString.
Referenced by output().
|
inline |
Compare to a signed byte buffer (using 8-bit).
DualString & fe::DualString::operator= | ( | const FESTRING_U8 * | operand | ) |
Compare to an unsigned byte buffer (using 8-bit).
DualString & fe::DualString::operator= | ( | const FESTRING_WIDE * | operand | ) |
Compare to an unicode buffer (using wide chars).
void fe::DualString::output | ( | std::ostream & | ostrm | ) | const |
only works for 8bit and does too much copying
References c_str(), and operator=().
|
inline |
Return the contents of the 8-bit buffer cast as signed bytes.
const FESTRING_U8 * fe::DualString::rawU8 | ( | void | ) | const |
Return the contents of the 8-bit buffer cast as unsigned bytes.
const FESTRING_WIDE * fe::DualString::rawWide | ( | void | ) | const |
Return the contents of the wide buffer cast in native unicode format.
DualString & fe::DualString::sPrintf | ( | const char * | fmt, |
... | |||
) |
Populate the string in the manner of sprintf().
References vsPrintf().
Referenced by catf(), and forceLowercase().
DualString & fe::DualString::vsPrintf | ( | const char * | fmt, |
va_list | ap | ||
) |
Populate using variable arg format.
Referenced by catf(), forceLowercase(), and sPrintf().