String_t Class Reference

String class which uses utf8 internally. More...

#include <UTString.h>

Inheritance diagram for String_t:
Buffer_t Path_t RefCountedString_t PathB_t

List of all members.

Public Member Functions

 String_t ()
 String_t (byte *buffer, int buffer_size)
 String_t (stringliteral *string)
 String_t (const utf8 *string)
 String_t (const String_t &copy)
 String_t (const wchar_t *string)
int LengthBytes () const
int LengthChars () const
bool IsEmpty () const
void MakeEmpty ()
bool IsASCII () const
void ToASCII (SimpleTypedBuffer_t< ascii7 > *buffer, bool escape_all, const ascii7 *escape_also) const
Status_t FromEscapedASCII (const ascii7 *ascii, ascii7 stop_at=0, int length=-1)
Status_t AppendFromEscapedASCII (const ascii7 *ascii, ascii7 stop_at=0, int length=-1)
void ToWChar (SimpleTypedBuffer_t< wchar_t > *buffer) const
const utf8UTF8 () const
stringliteralConstChars () const
 operator const utf8 * () const
void SetAndBorrow (stringliteral *set)
Status_t Set (stringliteral *set)
const String_toperator= (stringliteral *set)
Status_t Set (const utf8 *set)
const String_toperator= (const utf8 *set)
void Set (const String_t &set)
const String_toperator= (const String_t &set)
Status_t Set (const wchar_t *set)
const String_toperator= (const wchar_t *set)
Status_t SetLengthLimited (const utf8 *set, int num_chars)
void GetLeft (int length_chars, String_t *left) const
void GetRight (int length_chars, String_t *right) const
String_t Left (int length_chars) const
String_t Right (int length_chars) const
bool Printf (stringliteral *format,...)
bool PrintfAppend (stringliteral *format,...)
bool VPrintf (stringliteral *format, va_list args)
bool VPrintfAppend (stringliteral *format, va_list args)
void PrintByteArray (stringliteral *format, stringliteral *separator, const byte *data, int data_length)
void PrintByteArrayAppend (stringliteral *format, stringliteral *separator, const byte *data, int data_length)
void PrintByteArray (stringliteral *format, stringliteral *separator, const Buffer_t &buffer)
void PrintByteArrayAppend (stringliteral *format, stringliteral *separator, const Buffer_t &buffer)
void SetLineEndings (line_ending_type_t line_ending_type)
Status_t Append (stringliteral *append)
void operator+= (stringliteral *append)
Status_t Append (const utf8 *append)
void operator+= (const utf8 *append)
void Append (const String_t &append)
void operator+= (const String_t &append)
String_t operator+ (stringliteral *append) const
String_t operator+ (const utf8 *append) const
String_t operator+ (const String_t &append) const
Status_t Prepend (stringliteral *prepend)
Status_t Prepend (const utf8 *prepend)
void Prepend (const String_t &prepend)
void RemoveLeft (int length_chars)
void RemoveRight (int length_chars)
void operator-= (int length_chars)
String_t operator- (int length_char) const
void Remove (const utf8 *position_within_string, int bytes_to_remove)
Status_t ReplaceLeft (int remove_length_chars, stringliteral *replace)
Status_t ReplaceLeft (int remove_length_chars, const utf8 *replace_with)
void ReplaceLeft (int remove_length_chars, const String_t &replace_with)
Status_t ReplaceRight (int remove_length_chars, stringliteral *replace)
Status_t ReplaceRight (int remove_length_chars, const utf8 *replace_with)
void ReplaceRight (int remove_length_chars, const String_t &replace_with)
void RemoveWhitespace (bool start=true, bool end=true)
bool Equals (stringliteral *compare) const
bool operator== (stringliteral *compare) const
bool operator!= (stringliteral *compare) const
bool Equals (const utf8 *compare) const
bool operator== (const utf8 *compare) const
bool operator!= (const utf8 *compare) const
bool Equals (const String_t &compare) const
bool operator== (const String_t &compare) const
bool operator!= (const String_t &compare) const
bool EqualsIgnoreCase (stringliteral *compare) const
bool EqualsIgnoreCase (const utf8 *compare) const
bool EqualsIgnoreCase (const String_t &compare) const
bool LeftEquals (stringliteral *compare) const
bool LeftEquals (const utf8 *compare) const
bool LeftEquals (const String_t &compare) const
bool RightEquals (stringliteral *compare) const
bool RightEquals (const utf8 *compare) const
bool RightEquals (const String_t &compare) const
bool LeftEqualsIgnoreCase (stringliteral *compare) const
bool LeftEqualsIgnoreCase (const utf8 *compare) const
bool LeftEqualsIgnoreCase (const String_t &compare) const
bool RightEqualsIgnoreCase (stringliteral *compare) const
bool RightEqualsIgnoreCase (const utf8 *compare) const
bool RightEqualsIgnoreCase (const String_t &compare) const
int Compare (stringliteral *compare, int char_limit=-1) const
int Compare (const utf8 *compare, int char_limit=-1) const
int Compare (const String_t &compare, int char_limit=-1) const
int CompareIgnoreCase (stringliteral *compare, int char_limit=-1, bool numeric_sort_numbers=true) const
int CompareIgnoreCase (const utf8 *compare, int char_limit=-1, bool numeric_sort_numbers=true) const
int CompareIgnoreCase (const String_t &compare, int char_limit=-1, bool numeric_sort_numbers=true) const
bool operator< (const String_t &compare) const
bool operator<= (const String_t &compare) const
bool operator> (const String_t &compare) const
bool operator>= (const String_t &compare) const
int FindSubstringOffsetChars (stringliteral *find, bool case_sensitive=true, int start_at_offset=0, bool front_to_back=true)
int FindSubstringOffsetChars (const utf8 *find, bool case_sensitive=true, int start_at_offset=0, bool front_to_back=true)
int FindSubstringOffsetChars (const String_t &find, bool case_sensitive=true, int start_at_offset=0, bool front_to_back=true)
int FindSubstringOffsetBytes (stringliteral *find, bool case_sensitive=true, int start_at_offset=0, bool front_to_back=true)
int FindSubstringOffsetBytes (const utf8 *find, bool case_sensitive=true, int start_at_offset=0, bool front_to_back=true)
int FindSubstringOffsetBytes (const String_t &find, bool case_sensitive=true, int start_at_offset=0, bool front_to_back=true)

Static Public Member Functions

static bool DoLineEndingsMatch (const utf8 *string, line_ending_type_t line_ending=eLINEENDING_native, bool *ended_with_line_ending=NULL)
static int CountUTF8Chars (const utf8 *string, int stop_at_count=-1, int *byte_count=NULL, bool stop_at_count_is_byte_limit=false)

Detailed Description

utf8 string class with conversions to and from wchar_t (unicode) and ASCII, standard-compliant printf functionality, dynamic buffer growth management by virtue of inheritance from Buffer_t and a variety of functions for common string operations. Other than the stringliteral constructor and the SetAndBorrow function, all means of setting a string, including operator = and the Set functions, will result in this string owning its own copy of the string. The two exceptions mentioned will "borrow" the existing string pointer, which must remain valid for as long as this string object is valid. Those represent optimizatons to avoid unnecessary memory allocation and copying for the few cases where it is safe to optimize in that way.

Definition at line 50 of file UTString.h.


Constructor & Destructor Documentation

String_t::String_t (  )  [inline]

Empty string constructor.

Definition at line 1014 of file UTString.h.

String_t::String_t ( byte buffer,
int  buffer_size 
) [inline]

Constructor for a string which initially uses a stack-allocated buffer of the specified size. If the required size grows beyond that size, the buffer will be reallocated from the heap.

Definition at line 1024 of file UTString.h.

String_t::String_t ( stringliteral string  ) 

String which persistently references a string literal; the pointer is borrowed, therefore the string object is dependent on the pointer with which it was constructed. The contents of that pointer must remain valid for the life of the string object. Any manipulation of the string will cause the contents to be copied to a dynamically allocated buffer. At that point, the string object will no longer be dependent on the contents of the string literal constant.

String_t::String_t ( const utf8 string  ) 

String which copies a UTF8 string fully independent of the original; const string pointers are not borrowed, therefore a copied string becomes fully autonomous.

String_t::String_t ( const String_t copy  )  [inline]

Copy constructor, which creates a string fully independent of the original; const string pointers are not borrowed, therefore a copied string becomes fully autonomous.

Definition at line 1036 of file UTString.h.

String_t::String_t ( const wchar_t *  string  )  [inline]

Unicode constructor. The string parameter is converted to UTF8 since that is the internal format for the String_t class.

Definition at line 1048 of file UTString.h.


Member Function Documentation

int String_t::LengthBytes (  )  const [inline]

Returns the length of the string in bytes, not including the terminating null character. Note that non-ASCII characters in UTF8 require more than one byte to store them, so this is not the same as the character count.

Definition at line 1056 of file UTString.h.

int String_t::LengthChars (  )  const [inline]

Returns the length of the string in characters, not including the terminating null character. Note that non-ASCII characters in UTF8 require more than one byte to store them, so this is not the same as the byte count.

Definition at line 1063 of file UTString.h.

bool String_t::IsEmpty (  )  const [inline]

Returns a boolean value indicating whether the string is empty.

Definition at line 1070 of file UTString.h.

void String_t::MakeEmpty (  )  [inline]

Removes all existing text from the string.

Definition at line 1077 of file UTString.h.

bool String_t::IsASCII (  )  const [inline]

Returns a boolean value indicating whether the string is comprised entirely of ASCII characters.

Definition at line 1085 of file UTString.h.

void String_t::ToASCII ( SimpleTypedBuffer_t< ascii7 > *  buffer,
bool  escape_all,
const ascii7 escape_also 
) const

Converts the string to ASCII. Non-ASCII characters will be converted to "\xNN" sequences. buffer->NumValidItems() indicates the number of characters in the resulting ASCII character sequence, including the terminating null. If escape_all is true, '\' will be converted to "\\", carriage returns will be converted to "\r", linefeeds to "\n", tabs to "\t". Any character in the escape_also string will also be escaped. If no additional characters are to be escaped, escape_also should be NULL;

Status_t String_t::FromEscapedASCII ( const ascii7 ascii,
ascii7  stop_at = 0,
int  length = -1 
) [inline]

Converts the specified ASCII string to UTF8. Escape sequences are converted back to their unescaped characters. If stop_at is not 0, the conversion process will stop when an unescaped character matching stop_at is reached. Returns true on success, or false if the source ASCII string is invalid. If length is not -1, conversion will stop after length bytes of input have been consumed, even if the string is not null terminated at that point. length should only be used to cut off conversion if the source ascii is not null terminated but of known length. If length is exhausted with an incomplete escape sequence, an error status will be returned, so length cannot be used to limit the amount of available data consumed while remaining synchronized with escape sequence byte count requirements. If the conversion succeeds, returns the number of bytes consumed. If the conversion fails, returns an error status.

Definition at line 1092 of file UTString.h.

Status_t String_t::AppendFromEscapedASCII ( const ascii7 ascii,
ascii7  stop_at = 0,
int  length = -1 
)

See FromEscapedASCII for documentation, but appends to any existing string contents.

void String_t::ToWChar ( SimpleTypedBuffer_t< wchar_t > *  buffer  )  const

Converts the string to wchar_t (unicode). If wchar_t is defined to be a 16-bit type, characters too large to fit in wchar_t will be converted to "\xNNNNNN" sequences. buffer->NumValidItems() indicates the number of characters in the resulting wchar_t sequence, including the terminating null.

const utf8 * String_t::UTF8 (  )  const [inline]

Returns a pointer to the UTF8-encoded character buffer.

Definition at line 1109 of file UTString.h.

stringliteral * String_t::ConstChars (  )  const [inline]

Returns the same thing as UTF8(), but implicitly casts it to a const char* for passing to a system function

Definition at line 1116 of file UTString.h.

String_t::operator const utf8 * (  )  const [inline]

Conversion operator which returns a pointer to the UTF8-encoded character buffer

Definition at line 1102 of file UTString.h.

void String_t::SetAndBorrow ( stringliteral set  ) 

Set function which persistently references a string literal; the pointer is borrowed, therefore the string object is dependent on the pointer to which it was set. The contents of that pointer must remain valid for the life of the string object. Any manipulation of the string will cause the contents to be copied to a dynamically allocated buffer. At that point, the string object will no longer be dependent on the contents of the string literal constant.

Status_t String_t::Set ( stringliteral set  )  [inline]

Set function which creates a string fully independent of the constant string literal; the pointer is not borrowed, therefore a copied string becomes fully autonomous. In the event that the UTF8 input data is not valid, the string will be set to an empty state and an error status will be returned.

Reimplemented in Path_t.

Definition at line 1123 of file UTString.h.

const String_t & String_t::operator= ( stringliteral set  )  [inline]

operator = which creates a string fully independent of the constant string literal; the pointer is not borrowed, therefore a copied string becomes fully autonomous. In the event that UTF8 input data is not valid, an assertion failure will occur. If the validity of the string input cannot be guaranteed at compile time, the Set function should be used instead so that the returned status can be checked.

Reimplemented in Path_t, and PathB_t.

Definition at line 1130 of file UTString.h.

Status_t String_t::Set ( const utf8 set  ) 

Set function which creates a string fully independent of the constant string input; the pointer is not borrowed, therefore a copied string becomes fully autonomous. In the event that UTF8 input data is not valid, the string will be set to an empty state and an error status will be returned.

Reimplemented in Path_t.

const String_t & String_t::operator= ( const utf8 set  )  [inline]

operator = which creates a string fully independent of the constant string input; the pointer is not borrowed, therefore a copied string becomes fully autonomous. In the event that UTF8 input data is not valid, an assertion failure will occur. If the validity of the string input cannot be guaranteed at compile time, the Set function should be used instead so that the returned status can be checked.

Reimplemented in Path_t, and PathB_t.

Definition at line 1142 of file UTString.h.

void String_t::Set ( const String_t set  ) 

Set function which copies the string from the set parameter. The object will be fully independent of the constant string input; the pointer is not borrowed, therefore a copied string becomes fully autonomous.

Reimplemented in Path_t.

const String_t & String_t::operator= ( const String_t set  )  [inline]

operator = which copies the string from the set parameter. The object will be fully independent of the constant string input; the pointer is not borrowed, therefore a copied string becomes fully autonomous.

Reimplemented in Path_t.

Definition at line 1154 of file UTString.h.

Status_t String_t::Set ( const wchar_t *  set  ) 

Set function which converts the wchar_t (unicode) input to UTF8. If wchar_t is defined to be greater than 21 bits in size, it is possible for the input data to contain invalid unicode characters. In that case, in the event that the input data is not valid, the string will be set to an empty state and an error status will be returned.

const String_t & String_t::operator= ( const wchar_t *  set  )  [inline]

operator = which converts the wchar_t (unicode) input to UTF8. If wchar_t is defined to be greater than 21 bits in size, it is possible for the input data to contain invalid unicode characters. In that case, in the event that the input data is not valid, an assertion failure will occur. If the validity of the string input cannot be guaranteed at compile time, the Set function should be used instead so that the returned status can be checked.

Definition at line 1162 of file UTString.h.

Status_t String_t::SetLengthLimited ( const utf8 set,
int  num_chars 
)

Set function which creates a string fully independent of the constant string input; the pointer is not borrowed, therefore a copied string becomes fully autonomous. In the event that UTF8 input data is not valid, the string will be set to an empty state and an error status will be returned. The length of the data set is limited to num_chars. Not that this is a character, not byte, count.

void String_t::GetLeft ( int  length_chars,
String_t left 
) const

Obtains the first length_chars characters of this in the output string object pointed to by the left parameter. Note that since length_chars is a character count, it will not match the byte count if the string contains non-ASCII characters.

void String_t::GetRight ( int  length_chars,
String_t right 
) const

Obtains the last length_chars characters of this in the output string object pointed to by the left parameter. Note that since length_chars is a character count, it will not match the byte count if the string contains non-ASCII characters.

String_t String_t::Left ( int  length_chars  )  const

Obtains the first length_chars characters of this in the returned string object. This function is provided for convenience and should not be used when efficiency is needed due to the copy constructors invoked by return-by-value conventions. When efficiency is a concern, use the GetLeft function instead. Note that since length_chars is a character count, it will not match the byte count if the string contains non-ASCII characters.

String_t String_t::Right ( int  length_chars  )  const

Obtains the last length_chars characters of this in the returned string object. This function is provided for convenience and should not be used when efficiency is needed due to the copy constructors invoked by return-by-value conventions. When efficiency is a concern, use the GetRight function instead. Note that since length_chars is a character count, it will not match the byte count if the string contains non-ASCII characters.

bool String_t::Printf ( stringliteral format,
  ... 
) [inline]

Prints to this using a printf-style format string. The format string is ANSI-standard compliant, supporting "%lld" and "%ls" to represent int64 and wchar_t* respectively, for example. A nonstandard format of "%S" is provided to convert a Status_t object to its text equivalent, converting an error status to its corresponding error text and including any explanatory text attached to the Status_t object. When using the "%S" format, a pointer to the Status_t should be passed in the varargs list. When printing pointers, don't use "%x", use "%p" instead. Don't use "%08p" either, assuming 32-bit addresses. Use 0p so that the field width will be automatically adjusted to the pointer size.

Definition at line 1170 of file UTString.h.

bool String_t::PrintfAppend ( stringliteral format,
  ... 
) [inline]

Prints to this using a printf-style format string, appending the rendered text after any existing contents. The format string is ANSI-standard compliant, supporting "%lld" and "%ls" to represent int64 and wchar_t* respectively, for example. A nonstandard format of "%S" is provided to convert a Status_t object to its text equivalent, converting an error status to its corresponding error text and including any explanatory text attached to the Status_t object. When using the "%S" format, a pointer to the Status_t should be passed in the varargs list. When printing pointers, don't use "%x", use "%p" instead. Don't use "%08p" either, assuming 32-bit addresses. Use 0p so that the field width will be automatically adjusted to the pointer size.

Definition at line 1181 of file UTString.h.

bool String_t::VPrintf ( stringliteral format,
va_list  args 
) [inline]

Prints to this using a printf-style format string and va_list variable arguments, similar to vsprintf. The format string is ANSI-standard compliant, supporting "%lld" and "%ls" to represent int64 and wchar_t* respectively, for example. A nonstandard format of "%S" is provided to convert a Status_t object to its text equivalent, converting an error status to its corresponding error text and including any explanatory text attached to the Status_t object. When using the "%S" format, a pointer to the Status_t should be passed in the varargs list. When printing pointers, don't use "%x", use "%p" instead. Don't use "%08p" either, assuming 32-bit addresses. Use 0p so that the field width will be automatically adjusted to the pointer size.

Definition at line 1191 of file UTString.h.

bool String_t::VPrintfAppend ( stringliteral format,
va_list  args 
) [inline]

Prints to this using a printf-style format string and va_list variable arguments, similar to vsprintf, appending the rendered text after any existing contents. The format string is ANSI- standard compliant, supporting "%lld" and "%ls" to represent int64 and wchar_t* respectively, for example. A nonstandard format of "%S" is provided to convert a Status_t object to its text equivalent, converting an error status to its corresponding error text and including any explanatory text attached to the Status_t object. When using the "%S" format, a pointer to the Status_t should be passed in the varargs list. When printing pointers, don't use "%x", use "%p" instead. Don't use "%08p" either, assuming 32-bit addresses. Use 0p so that the field width will be automatically adjusted to the pointer size.

Definition at line 1198 of file UTString.h.

void String_t::PrintByteArray ( stringliteral format,
stringliteral separator,
const byte data,
int  data_length 
) [inline]

Prints a byte array into a string, using a printf-style format for each byte, including the first and last byte, and inserting the separator before each byte except the first.

Definition at line 1205 of file UTString.h.

void String_t::PrintByteArrayAppend ( stringliteral format,
stringliteral separator,
const byte data,
int  data_length 
)

Prints a byte array into a string, using a printf-style format for each byte, including the first and last byte, and inserting the separator before each byte except the first. The rendered text is appended to the end of any existing text.

void String_t::PrintByteArray ( stringliteral format,
stringliteral separator,
const Buffer_t buffer 
) [inline]

Prints a byte array into a string, using a printf-style format for each byte, including the first and last byte, and inserting the separator before each byte except the first.

Definition at line 1216 of file UTString.h.

void String_t::PrintByteArrayAppend ( stringliteral format,
stringliteral separator,
const Buffer_t buffer 
) [inline]

Prints a byte array into a string, using a printf-style format for each byte, including the first and last byte, and inserting the separator before each byte except the first. The rendered text is appended to the end of any existing text.

Definition at line 1226 of file UTString.h.

void String_t::SetLineEndings ( line_ending_type_t  line_ending_type  ) 

Converts any line endings to the format specified by type. The supported formats are UNIX ("\n"), DOS ("\r\n"), and native, native being the normal line endings on the target operating system. When converting to UNIX line endings, any "\r\n" or "\r" not followed by "\n" sequences are converted to "\n". When converting to DOS line endings, any "\n" which is not preceded by "\r" or any "\r" which is not followed by "\n" is converted to "\r\n".

static bool String_t::DoLineEndingsMatch ( const utf8 string,
line_ending_type_t  line_ending = eLINEENDING_native,
bool *  ended_with_line_ending = NULL 
) [static]

Returns true if the line endings in the specified string match the specified format, or false if they do not. If ended_with_line_ending is not NULL, it will be set to indicate whether, matching or not, the string ended with a carriage return or linefeed.

Status_t String_t::Append ( stringliteral append  )  [inline]

Appends the specified text. In the event that the UTF8 input data is not valid, an error status will be returned.

Reimplemented in Path_t.

Definition at line 1235 of file UTString.h.

void String_t::operator+= ( stringliteral append  )  [inline]

Appends the specified text. In the event that the UTF8 input data is not valid, an assertion failure will occur. If the validity of the string input cannot be guaranteed at compile time, the Append function should be used instead so that the returned status can be checked.

Reimplemented in Path_t.

Definition at line 1242 of file UTString.h.

Status_t String_t::Append ( const utf8 append  ) 

Appends the specified text. In the event that the UTF8 input data is not valid, an error status will be returned.

Reimplemented in Path_t.

void String_t::operator+= ( const utf8 append  )  [inline]

Appends the specified text. In the event that the UTF8 input data is not valid, an assertion failure will occur. If the validity of the string input cannot be guaranteed at compile time, the Append function should be used instead so that the returned status can be checked.

Reimplemented in Path_t.

Definition at line 1253 of file UTString.h.

void String_t::Append ( const String_t append  ) 

Appends the specified text.

Reimplemented in Path_t.

void String_t::operator+= ( const String_t append  )  [inline]

Appends the specified text.

Reimplemented in Path_t.

Definition at line 1264 of file UTString.h.

String_t String_t::operator+ ( stringliteral append  )  const [inline]

Returns a concatenation of this and the append parameter. This operator is provided for convenience and should not be used when efficiency is needed due to the copy constructors invoked by return-by-value conventions. In the event that the UTF8 input data is not valid, an assertion failure will occur. If the validity of the string input cannot be guaranteed at compile time, the Append function should be used instead so that the returned status can be checked.

Reimplemented in Path_t.

Definition at line 1271 of file UTString.h.

String_t String_t::operator+ ( const utf8 append  )  const [inline]

Returns a concatenation of this and the append parameter. This operator is provided for convenience and should not be used when efficiency is needed due to the copy constructors invoked by return-by-value conventions. In the event that the UTF8 input data is not valid, an assertion failure will occur. If the validity of the string input cannot be guaranteed at compile time, the Append function should be used instead so that the returned status can be checked.

Reimplemented in Path_t.

Definition at line 1284 of file UTString.h.

String_t String_t::operator+ ( const String_t append  )  const [inline]

Returns a concatenation of this and the append parameter. This operator is provided for convenience and should not be used when efficiency is needed due to the copy constructors invoked by return-by-value conventions.

Reimplemented in Path_t.

Definition at line 1297 of file UTString.h.

Status_t String_t::Prepend ( stringliteral prepend  )  [inline]

Inserts the specified text at the beginning of this. In the event that the UTF8 input data is not valid, an error status will be returned.

Definition at line 1306 of file UTString.h.

Status_t String_t::Prepend ( const utf8 prepend  ) 

Inserts the specified text at the beginning of this. In the event that the UTF8 input data is not valid, an error status will be returned.

void String_t::Prepend ( const String_t prepend  ) 

Inserts the specified text at the beginning of this.

void String_t::RemoveLeft ( int  length_chars  ) 

Removes length_chars characters from the beginning of this. Note that if the removed characters are not all ASCII, more than length_chars bytes will be removed. If the length in characters (not bytes) of this was shorter than length_chars prior to character removal, an assertion failure will occur.

void String_t::RemoveRight ( int  length_chars  ) 

Removes length_chars characters from the end of this. Note that if the removed characters are not all ASCII, more than length_chars bytes will be removed. If the length in characters (not bytes) of this was shorter than length_chars prior to character removal, an assertion failure will occur.

void String_t::operator-= ( int  length_chars  )  [inline]

Removes length_chars characters from the end of this. Note that if the removed characters are not all ASCII, more than length_chars bytes will be removed. If the length in characters (not bytes) of this was shorter than length_chars prior to character removal, an assertion failure will occur.

Definition at line 1313 of file UTString.h.

String_t String_t::operator- ( int  length_char  )  const [inline]

Returns a string object which is a copy of this with length_chars removed from the end. Note that if the removed characters are not all ASCII, more than length_chars bytes will be removed. If the length in characters (not bytes) of this was shorter than length_chars prior to character removal, an assertion failure will occur. This operator is provided for convenience and should not be used when efficiency is needed due to the copy constructors invoked by return-by-value conventions.

Definition at line 1320 of file UTString.h.

void String_t::Remove ( const utf8 position_within_string,
int  bytes_to_remove 
)

Removes the specified number of bytes, which must be complete characters, from the string at the specified position, which must be within the string. bytes_to_remove cannot exceed the number of bytes available to the end of the string, and may not include the null terminator. If any of these requirements are not met, an assertion failure will occur.

Status_t String_t::ReplaceLeft ( int  remove_length_chars,
stringliteral replace 
) [inline]

Removes the first remove_length_chars from this and replaces them with the contents of the replace parameter. If the length in characters (not bytes) of this was shorter than remove_length_chars prior to character removal, an assertion failure will occur. If the UTF8 input data is not valid, an error status will be returned. The length of the replacement does not need to match the length in characters or bytes of the removed portion.

Definition at line 1329 of file UTString.h.

Status_t String_t::ReplaceLeft ( int  remove_length_chars,
const utf8 replace_with 
)

Removes the first remove_length_chars from this and replaces them with the contents of the replace parameter. If the length in characters (not bytes) of this was shorter than remove_length_chars prior to character removal, an assertion failure will occur. If the UTF8 input data is not valid, an error status will be returned. The length of the replacement does not need to match the length in characters or bytes of the removed portion.

void String_t::ReplaceLeft ( int  remove_length_chars,
const String_t replace_with 
)

Removes the first remove_length_chars from this and replaces them with the contents of the replace parameter. If the length in characters (not bytes) of this was shorter than remove_length_chars prior to character removal, an assertion failure will occur. The length of the replacement does not need to match the length in characters or bytes of the removed portion.

Status_t String_t::ReplaceRight ( int  remove_length_chars,
stringliteral replace 
) [inline]

Removes the last remove_length_chars from this and replaces them with the contents of the replace parameter. If the length in characters (not bytes) of this was shorter than remove_length_chars prior to character removal, an assertion failure will occur. If the UTF8 input data is not valid, an error status will be returned. The length of the replacement does not need to match the length in characters or bytes of the removed portion.

Definition at line 1336 of file UTString.h.

Status_t String_t::ReplaceRight ( int  remove_length_chars,
const utf8 replace_with 
)

Removes the last remove_length_chars from this and replaces them with the contents of the replace parameter. If the length in characters (not bytes) of this was shorter than remove_length_chars prior to character removal, an assertion failure will occur. If the UTF8 input data is not valid, an error status will be returned. The length of the replacement does not need to match the length in characters or bytes of the removed portion.

void String_t::ReplaceRight ( int  remove_length_chars,
const String_t replace_with 
)

Removes the last remove_length_chars from this and replaces them with the contents of the replace parameter. If the length in characters (not bytes) of this was shorter than remove_length_chars prior to character removal, an assertion failure will occur. The length of the replacement does not need to match the length in characters or bytes of the removed portion.

void String_t::RemoveWhitespace ( bool  start = true,
bool  end = true 
)

Removes whitespace from the beginning and/or end of this.

bool String_t::Equals ( stringliteral compare  )  const [inline]

Compares this against the specified string and returns true if the strings are the same, otherwise false.

Definition at line 1343 of file UTString.h.

bool String_t::operator== ( stringliteral compare  )  const [inline]

Compares this against the specified string and returns true if the strings are the same, otherwise false.

Definition at line 1350 of file UTString.h.

bool String_t::operator!= ( stringliteral compare  )  const [inline]

Compares this against the specified string and returns true if the strings are not the same, otherwise false.

Definition at line 1357 of file UTString.h.

bool String_t::Equals ( const utf8 compare  )  const

Compares this against the specified string and returns true if the strings are the same, otherwise false.

bool String_t::operator== ( const utf8 compare  )  const [inline]

Compares this against the specified string and returns true if the strings are the same, otherwise false.

Definition at line 1364 of file UTString.h.

bool String_t::operator!= ( const utf8 compare  )  const [inline]

Compares this against the specified string and returns true if the strings are not the same, otherwise false.

Definition at line 1371 of file UTString.h.

bool String_t::Equals ( const String_t compare  )  const

Compares this against the specified string and returns true if the strings are the same, otherwise false.

bool String_t::operator== ( const String_t compare  )  const [inline]

Compares this against the specified string and returns true if the strings are the same, otherwise false.

Definition at line 1378 of file UTString.h.

bool String_t::operator!= ( const String_t compare  )  const [inline]

Compares this against the specified string and returns true if the strings are not the same, otherwise false.

Definition at line 1385 of file UTString.h.

bool String_t::EqualsIgnoreCase ( stringliteral compare  )  const [inline]

Compares this against the specified string, ignoring case differences, and returns true if the strings are the same, otherwise false.

Definition at line 1392 of file UTString.h.

bool String_t::EqualsIgnoreCase ( const utf8 compare  )  const [inline]

Compares this against the specified string, ignoring case differences, and returns true if the strings are the same, otherwise false.

Definition at line 1403 of file UTString.h.

bool String_t::EqualsIgnoreCase ( const String_t compare  )  const

Compares this against the specified string, ignoring case differences, and returns true if the strings are the same, otherwise false.

bool String_t::LeftEquals ( stringliteral compare  )  const [inline]

Compares the beginning of this against the specified string, considering only the length of the string to be compared against, and returns true if the strings are the same, otherwise false. If the compare string is longer than this, returns false.

Definition at line 1410 of file UTString.h.

bool String_t::LeftEquals ( const utf8 compare  )  const

Compares the beginning of this against the specified string, considering only the length of the string to be compared against, and returns true if the strings are the same, otherwise false. If the compare string is longer than this, returns false.

bool String_t::LeftEquals ( const String_t compare  )  const [inline]

Compares the beginning of this against the specified string, considering only the length of the string to be compared against, and returns true if the strings are the same, otherwise false. If the compare string is longer than this, returns false.

Definition at line 1417 of file UTString.h.

bool String_t::RightEquals ( stringliteral compare  )  const [inline]

Compares the end of this against the specified string, considering only the length of the string to be compared against, and returns true if the strings are the same, otherwise false. If the compare string is longer than this, returns false.

Definition at line 1424 of file UTString.h.

bool String_t::RightEquals ( const utf8 compare  )  const [inline]

Compares the end of this against the specified string, considering only the length of the string to be compared against, and returns true if the strings are the same, otherwise false. If the compare string is longer than this, returns false.

Definition at line 1433 of file UTString.h.

bool String_t::RightEquals ( const String_t compare  )  const [inline]

Compares the end of this against the specified string, considering only the length of the string to be compared against, and returns true if the strings are the same, otherwise false. If the compare string is longer than this, returns false.

Definition at line 1440 of file UTString.h.

bool String_t::LeftEqualsIgnoreCase ( stringliteral compare  )  const [inline]

Compares the beginning of this against the specified string, considering only the length of the string to be compared against and ignoring case differences, and returns true if the strings are the same, otherwise false. If the compare string is longer than this, returns false.

Definition at line 1447 of file UTString.h.

bool String_t::LeftEqualsIgnoreCase ( const utf8 compare  )  const

Compares the beginning of this against the specified string, considering only the length of the string to be compared against and ignoring case differences, and returns true if the strings are the same, otherwise false. If the compare string is longer than this, returns false.

bool String_t::LeftEqualsIgnoreCase ( const String_t compare  )  const [inline]

Compares the beginning of this against the specified string, considering only the length of the string to be compared against and ignoring case differences, and returns true if the strings are the same, otherwise false. If the compare string is longer than this, returns false.

Definition at line 1458 of file UTString.h.

bool String_t::RightEqualsIgnoreCase ( stringliteral compare  )  const [inline]

Compares the end of this against the specified string, considering only the length of the string to be compared against and ignoring case differences, and returns true if the strings are the same, otherwise false. If the compare string is longer than this, returns false.

Definition at line 1465 of file UTString.h.

bool String_t::RightEqualsIgnoreCase ( const utf8 compare  )  const [inline]

Compares the end of this against the specified string, considering only the length of the string to be compared against and ignoring case differences, and returns true if the strings are the same, otherwise false. If the compare string is longer than this, returns false.

Definition at line 1474 of file UTString.h.

bool String_t::RightEqualsIgnoreCase ( const String_t compare  )  const [inline]

Compares the end of this against the specified string, considering only the length of the string to be compared against and ignoring case differences, and returns true if the strings are the same, otherwise false. If the compare string is longer than this, returns false.

Definition at line 1481 of file UTString.h.

int String_t::Compare ( stringliteral compare,
int  char_limit = -1 
) const [inline]

Compares this against the specified string and returns 0 if they are equal, a negative number if this is before compare alphabetically, or a positive number if this is after compare alphabetically. If char_limit is not -1, the comparison stops and returns 0 after the specified number of characters.

Definition at line 1488 of file UTString.h.

int String_t::Compare ( const utf8 compare,
int  char_limit = -1 
) const

Compares this against the specified string and returns 0 if they are equal, a negative number if this is before compare alphabetically, or a positive number if this is after compare alphabetically. If char_limit is not -1, the comparison stops and returns 0 after the specified number of characters.

int String_t::Compare ( const String_t compare,
int  char_limit = -1 
) const [inline]

Compares this against the specified string and returns 0 if they are equal, a negative number if this is before compare alphabetically, or a positive number if this is after compare alphabetically. If char_limit is not -1, the comparison stops and returns 0 after the specified number of characters.

Definition at line 1495 of file UTString.h.

int String_t::CompareIgnoreCase ( stringliteral compare,
int  char_limit = -1,
bool  numeric_sort_numbers = true 
) const [inline]

Compares this against the specified string, ignoring case differences. and returns 0 if they are equal, a negative number if this is before compare alphabetically, or a positive number if this is after compare alphabetically. If char_limit is not -1, the comparison stops and returns 0 after the specified number of characters. If numeric_sort_numbers is true, instances of one or more numeric characters will be sorted numerically such that "10" will come after "9".

Definition at line 1502 of file UTString.h.

int String_t::CompareIgnoreCase ( const utf8 compare,
int  char_limit = -1,
bool  numeric_sort_numbers = true 
) const [inline]

Compares this against the specified string, ignoring case differences. and returns 0 if they are equal, a negative number if this is before compare alphabetically, or a positive number if this is after compare alphabetically. If char_limit is not -1, the comparison stops and returns 0 after the specified number of characters. If numeric_sort_numbers is true, instances of one or more numeric characters will be sorted numerically such that "10" will come after "9".

Definition at line 1515 of file UTString.h.

int String_t::CompareIgnoreCase ( const String_t compare,
int  char_limit = -1,
bool  numeric_sort_numbers = true 
) const [inline]

Compares this against the specified string, ignoring case differences. and returns 0 if they are equal, a negative number if this is before compare alphabetically, or a positive number if this is after compare alphabetically. If char_limit is not -1, the comparison stops and returns 0 after the specified number of characters. If numeric_sort_numbers is true, instances of one or more numeric characters will be sorted numerically such that "10" will come after "9".

Definition at line 1524 of file UTString.h.

bool String_t::operator< ( const String_t compare  )  const [inline]

Compares this against the specified string, ignoring case differences. and returns true if this comes before compare alphabetically. Instances of one or more numeric characters will be sorted numerically such that "10" will come after "9".

Definition at line 1533 of file UTString.h.

bool String_t::operator<= ( const String_t compare  )  const [inline]

Compares this against the specified string, ignoring case differences. Returns true if this comes before compare alphabetically or if the strings are equal. Instances of one or more numeric characters will be sorted numerically such that "10" will come after "9".

Definition at line 1540 of file UTString.h.

bool String_t::operator> ( const String_t compare  )  const [inline]

Compares this against the specified string, ignoring case differences. Returns true if this comes after compare alphabetically. Instances of one or more numeric characters will be sorted numerically such that "10" will come after "9".

Definition at line 1547 of file UTString.h.

bool String_t::operator>= ( const String_t compare  )  const [inline]

Compares this against the specified string, ignoring case differences. Returns true if this comes after compare alphabetically or if the strings are equal. Instances of one or more numeric characters will be sorted numerically such that "10" will come after "9".

Definition at line 1554 of file UTString.h.

static int String_t::CountUTF8Chars ( const utf8 string,
int  stop_at_count = -1,
int *  byte_count = NULL,
bool  stop_at_count_is_byte_limit = false 
) [static]

Counts the characters (not bytes) in the specified UTF8 string, optionally limited in the number of characters to be counted and optionally providing a byte count corresponding to the counted characters. Returns the number of characters counted, not including the terminating null and limited to stop_at_count characters unless stop_at_count is -1. If the string was bad, returns -1.

Parameters:
string The string for which to count UTF8 characters.
stop_at_count If stop_at_count is -1, counts all characters up to the terminating null character in string. If stop_at_count is not -1, the function will cease counting at the specified character count, typically used to obtain a byte count for this number of characters. The null character is not included in the byte count.
byte_count If byte_count is not NULL, *byte_count will be set to the number of bytes required to hold the counted number of characters from the beginning of the specified string.
stop_at_count_is_byte_limit If stop_at_count_is_byte_limit is true, stop_at_count stops at a byte count rather than a character count.
int String_t::FindSubstringOffsetChars ( stringliteral find,
bool  case_sensitive = true,
int  start_at_offset = 0,
bool  front_to_back = true 
) [inline]

Returns the offset in characters of the next instance of the specified substring starting in this at start_at_offset and searching in the direction specified by front_to_back. If the substring is not found, returns -1. To start at the end of the string searching back to front, start_at_offset can be set to -1. If find occurs at start_at_offset, start_at_offset will be returned. The returned offset is relative to the beginning of the string, not start_at_offset or an offset from the end of the string.

Definition at line 1561 of file UTString.h.

int String_t::FindSubstringOffsetChars ( const utf8 find,
bool  case_sensitive = true,
int  start_at_offset = 0,
bool  front_to_back = true 
)

Returns the offset in characters of the next instance of the specified substring starting in this at start_at_offset and searching in the direction specified by front_to_back. If the substring is not found, returns -1. To start at the end of the string searching back to front, start_at_offset can be set to -1. If find occurs at start_at_offset, start_at_offset will be returned. The returned offset is relative to the beginning of the string, not start_at_offset or an offset from the end of the string.

int String_t::FindSubstringOffsetChars ( const String_t find,
bool  case_sensitive = true,
int  start_at_offset = 0,
bool  front_to_back = true 
) [inline]

Returns the offset in characters of the next instance of the specified substring starting in this at start_at_offset and searching in the direction specified by front_to_back. If the substring is not found, returns -1. To start at the end of the string searching back to front, start_at_offset can be set to -1. If find occurs at start_at_offset, start_at_offset will be returned. The returned offset is relative to the beginning of the string, not start_at_offset or an offset from the end of the string.

Definition at line 1574 of file UTString.h.

int String_t::FindSubstringOffsetBytes ( stringliteral find,
bool  case_sensitive = true,
int  start_at_offset = 0,
bool  front_to_back = true 
) [inline]

Returns the offset in bytes of the next instance of the specified substring starting in this at start_at_offset and searching in the direction specified by front_to_back. If the substring is not found, returns -1. To start at the end of the string searching back to front, start_at_offset can be set to -1. If find occurs at start_at_offset, start_at_offset will be returned. The returned offset is relative to the beginning of the string, not start_at_offset or an offset from the end of the string.

Definition at line 1584 of file UTString.h.

int String_t::FindSubstringOffsetBytes ( const utf8 find,
bool  case_sensitive = true,
int  start_at_offset = 0,
bool  front_to_back = true 
)

Returns the offset in bytes of the next instance of the specified substring starting in this at start_at_offset and searching in the direction specified by front_to_back. If the substring is not found, returns -1. To start at the end of the string searching back to front, start_at_offset can be set to -1. If find occurs at start_at_offset, start_at_offset will be returned. The returned offset is relative to the beginning of the string, not start_at_offset or an offset from the end of the string.

int String_t::FindSubstringOffsetBytes ( const String_t find,
bool  case_sensitive = true,
int  start_at_offset = 0,
bool  front_to_back = true 
) [inline]

Returns the offset in bytes of the next instance of the specified substring starting in this at start_at_offset and searching in the direction specified by front_to_back. If the substring is not found, returns -1. To start at the end of the string searching back to front, start_at_offset can be set to -1. If find occurs at start_at_offset, start_at_offset will be returned. The returned offset is relative to the beginning of the string, not start_at_offset or an offset from the end of the string.

Definition at line 1597 of file UTString.h.


The documentation for this class was generated from the following file:

Generated on Tue Dec 14 22:35:07 2010 for UT library by  doxygen 1.6.1