MISTRING Class Reference

General string class. More...

#include <mi32/mistring.h>

Inheritance diagram for MISTRING:

Inheritance graph
[legend]
List of all members.

Public Types

enum  FLOATFMT { FLOATFMT_General = 0, FLOATFMT_Fixed = 1, FLOATFMT_Scientific = 2 }
enum  LINETERM { LINETERM_LF = 0, LINETERM_CR = 1, LINETERM_CRLF = 2 }

Public Member Functions

void Append (const MISTRING &str, int start=0, int end=INT32_MAX)
void Assign (const void *str, CHAR_ENCODING encoding)
void Assign (const UNICODE *str, int start=0, int end=INT32_MAX)
void Assign (const MISTRING &str, int start=0, int end=INT32_MAX)
bool CheckLineTermination (LINETERM lineterm) const
void Clear ()
int Compare (int SrcStart, const MISTRING &str, int OtherStart, int len) const
int Compare (const MISTRING &str, int len) const
int Compare (const MISTRING &str) const
int CompareNoCase (int SrcStart, const MISTRING &str, int OtherStart, int len) const
int CompareNoCase (const MISTRING &str, int len) const
int CompareNoCase (const MISTRING &str) const
double ConvertToDouble () const
int FindNextInSet (const MISTRING &chars, int start=0) const
int FindNextNotInSet (const MISTRING &chars, int start=0) const
int FindNextOf (UNICODE c, int start=0) const
int FindNextOf (const MISTRING &str, int start=0) const
int FindPrevInSet (const MISTRING &chars, int start=INT32_MAX) const
int FindPrevNotInSet (const MISTRING &chars, int start=INT32_MAX) const
int FindPrevOf (UNICODE c, int start=INT32_MAX) const
void FmtEnableSubstitution (bool enable=true)
void FmtSetBase (int base)
void FmtSetFill (UNICODE fill)
void FmtSetFloat (FLOATFMT floatmode)
void FmtSetPrecision (int precision)
void FmtSetSign (bool sign)
void FmtSetWidth (int width)
void * GetEncoded (CHAR_ENCODING encoding) const
int GetLength () const
const UNICODEGetReference () const
UNICODEGetString () const
MISTRING GetSubString (int start, int end) const
MISTRING GetSubString (int start) const
bool IniRead (INIHANDLE handle, const char *group, const char *field)
bool IniReadML (INIHANDLE handle, const char *group, const char *field)
void IniWrite (INIHANDLE handle, const char *group, const char *field) const
void IniWriteML (INIHANDLE handle, const char *group, const char *field) const
void Insert (int start, const MISTRING &str, int strstart=0, int strend=INT32_MAX)
bool IsEmpty () const
void Join (const MILIST< MISTRING > &list, const char *sep="")
void Join (const MILIST< MISTRING > &list, const UNICODE *sep)
 MISTRING (double value)
 MISTRING (unsigned int value)
 MISTRING (int value)
 MISTRING (const void *str, CHAR_ENCODING encoding)
DEPRECATED MISTRING (const char *msggroup, const char *msgkey)
 MISTRING (TEXTID textid)
 MISTRING (const STRUTF8 &rhs)
 MISTRING (const char *str)
 MISTRING (const UNICODE *ustr)
 MISTRING (const MISTRING &rhs)
 MISTRING ()
 operator const UNICODE * () const
MISTRINGoperator+= (UNICODE c)
MISTRINGoperator+= (const char *rhs)
MISTRINGoperator+= (const UNICODE *rhs)
MISTRINGoperator+= (const MISTRING &rhs)
MISTRINGoperator<< (TEXTID textid)
MISTRINGoperator<< (const UNICODE *s)
MISTRINGoperator<< (const char *s)
MISTRINGoperator<< (double f)
MISTRINGoperator<< (float f)
MISTRINGoperator<< (UINT64 n)
MISTRINGoperator<< (unsigned long n)
MISTRINGoperator<< (unsigned int n)
MISTRINGoperator<< (unsigned short n)
MISTRINGoperator<< (INT64 n)
MISTRINGoperator<< (long n)
MISTRINGoperator<< (int n)
MISTRINGoperator<< (short n)
MISTRINGoperator<< (unsigned char n)
MISTRINGoperator<< (signed char n)
MISTRINGoperator<< (char c)
MISTRINGoperator<< (bool b)
MISTRINGoperator<< (STR_OP op)
MISTRINGoperator= (const char *rhs)
MISTRINGoperator= (const UNICODE *rhs)
MISTRINGoperator= (TEXTID textid)
MISTRINGoperator= (const STRUTF8 &rhs)
MISTRINGoperator= (const MISTRING &rhs)
const UNICODEoperator[] (int idx) const
void Pad (UNICODE c, int numchars)
void PadToLength (UNICODE c, int length)
void Remove (int start, int end)
void Replace (int start, int end, const MISTRING &str, int strstart=0, int strend=INT32_MAX)
void Replace (int index, UNICODE c)
ERRVALUE Reserve (int numchars)
bool Search (const UCREGEXP &regex, UINT32 &MatchStart, UINT32 &MatchEnd, UINT32 Start=0) const
bool Search (const UNICODE *str, UINT32 &MatchStart, UINT32 &MatchEnd, bool bIgnoreCase=false, UINT32 Start=0) const
bool SetLineTermination (LINETERM lineterm)
void SetLowerCase (int start=0)
void SetUpperCase (int start=0)
int Split (const UNICODE *regexp, MILIST< MISTRING > &list, int maxitems=0) const
int Split (UNICODE ch, MILIST< MISTRING > &list, int maxitems=0) const
void Truncate (int length)
 ~MISTRING ()

Static Public Member Functions

const MISTRINGGetEmpty ()

Detailed Description

General string class.

Supports internationalization, Unicode and various character set encodings.

MISTRING supports use of '<<' to 'put' values into the string similar to iostream. When using '<<' the current MISTRING is first searched for a formatting code or a substitution placeholder. Formatting codes in the form d, s, f, etc. are searched for first. The first code compatible with the value being put into the string will be used. Thus, if a number is being put then any d, u, f, etc code will be used. These formatting codes can also specify the width and precision if desired. Thus, '%.8f' may be used to specify 8 decimal places of precision. These settings only apply to the current value being put into the string. If no width, precision, etc is specified then any previously set formatting state settings will apply. If no -style formatting code is found then a search is made for substitution placeholders in the form $1, $2, etc. The lowest numbered placeholder will be replaced with the value being put into the string. Finally, if no placeholder is found then the value being put will be appended to the end of the string.

Definition at line 285 of file mistring.h.


Member Enumeration Documentation

enum MISTRING::FLOATFMT
 

Enumeration values:
FLOATFMT_General  General (equivalent to "%G").
FLOATFMT_Fixed  Fixed (equivalent to "%f").
FLOATFMT_Scientific  Scientific (equivalent to "%E").

Definition at line 288 of file mistring.h.

enum MISTRING::LINETERM
 

Enumeration values:
LINETERM_LF  Terminate lines with '\n'.
LINETERM_CR  Terminate lines with '\r'.
LINETERM_CRLF  Terminate lines with '\r\n'.

Definition at line 294 of file mistring.h.


Constructor & Destructor Documentation

MISTRING::MISTRING  ) 
 

Default constructor.

MISTRING::MISTRING const MISTRING rhs  ) 
 

Copy constructor.

MISTRING::MISTRING const UNICODE ustr  ) 
 

Construct from UNICODE* string (implicit).

MISTRING::MISTRING const char *  str  )  [explicit]
 

Construct from char* string.

MISTRING::MISTRING const STRUTF8 rhs  ) 
 

Construct from STRUTF8 string (implicit).

MISTRING::MISTRING TEXTID  textid  ) 
 

Construct from TEXTID (implicit).

Parameters:
textid  Messsage text ID

DEPRECATED MISTRING::MISTRING const char *  msggroup,
const char *  msgkey
 

Construct from message file group and key.

Deprecated, use TEXTID instead.

Parameters:
msggroup  Message file group
msgkey  Message file key

MISTRING::MISTRING const void *  str,
CHAR_ENCODING  encoding
 

Construct from string in specified encoding.

MISTRING::MISTRING int  value  )  [explicit]
 

Construct from integer with default formatting.

MISTRING::MISTRING unsigned int  value  )  [explicit]
 

Construct from unsigned integer with default formatting.

MISTRING::MISTRING double  value  )  [explicit]
 

Construct from floating-point with default formatting.

MISTRING::~MISTRING  ) 
 


Member Function Documentation

void MISTRING::Append const MISTRING str,
int  start = 0,
int  end = INT32_MAX
 

Append from MISTRING.

Parameters:
str  String to append
start  Starting position in 'str' to append to this string
end  Ending position in 'str' to append to this string

void MISTRING::Assign const void *  str,
CHAR_ENCODING  encoding
 

Assign from string in specified encoding.

Assign from partial char string is not supported due to character encoding

Parameters:
str  Buffer holding appropriately-terminated string
encoding  Encoding of string

void MISTRING::Assign const UNICODE str,
int  start = 0,
int  end = INT32_MAX
 

Assign from UNICODE string.

Parameters:
str  Buffer holding UNICODE string
start  Starting position in 'str' to assign to this string
end  Ending position in 'str' to assign to this string

void MISTRING::Assign const MISTRING str,
int  start = 0,
int  end = INT32_MAX
 

Assign from MISTRING.

Parameters:
str  Buffer holding MISTRING
start  Starting position in 'str' to assign to this string
end  Ending position in 'str' to assign to this string

bool MISTRING::CheckLineTermination LINETERM  lineterm  )  const
 

Determine if string consistently uses specified line termination.

Returns:
true if specified termination used, false if not.
Parameters:
lineterm  Line termination

void MISTRING::Clear  ) 
 

Clear the string.

int MISTRING::Compare int  SrcStart,
const MISTRING str,
int  OtherStart,
int  len
const
 

Case-sensitive comparison, length limited (similar to strncmp).

Returns:
0 if strings equal, -1 if this < str, 1 if this > str.
Parameters:
SrcStart  Start position of 'this' string
str  String to compare to
OtherStart  Start position of 'str'
len  Maximum number of characters to compare

int MISTRING::Compare const MISTRING str,
int  len
const
 

Case-sensitive comparison, length limited (similar to strncmp).

Returns:
0 if strings equal, -1 if this < str, 1 if this > str.
Parameters:
str  String to compare to
len  Maximum number of characters to compare

int MISTRING::Compare const MISTRING str  )  const
 

Case-sensitive comparison (similar to strcmp).

Returns:
0 if strings equal, -1 if this < str, 1 if this > str.
Parameters:
str  String to compare to

int MISTRING::CompareNoCase int  SrcStart,
const MISTRING str,
int  OtherStart,
int  len
const
 

Case-insensitive comparison, length limited (similar to strnicmp).

Returns:
0 if equal, -1 if this < str, 1 if this > str.
Parameters:
SrcStart  Start position of 'this' string
str  String to compare to
OtherStart  Start position of 'str'
len  Maximum number of characters to compare

int MISTRING::CompareNoCase const MISTRING str,
int  len
const
 

Case-insensitive comparison, length limited (similar to strnicmp).

Returns:
0 if equal, -1 if this < str, 1 if this > str.
Parameters:
str  String to compare to
len  Maximum number of characters to compare

int MISTRING::CompareNoCase const MISTRING str  )  const
 

Case-insensitive comparison (similar to stricmp).

Returns:
0 if strings equal, -1 if this < str, 1 if this > str.
Parameters:
str  String to compare to

double MISTRING::ConvertToDouble  )  const
 

Convert string to double-precision numeric value.

Returns:
Converted value or 0.0 if unable to convert.

int MISTRING::FindNextInSet const MISTRING chars,
int  start = 0
const
 

Find next occurrence in given set of characters (similar to strpbrk).

Returns:
Character position or -1 if not found.
Parameters:
chars  Characters to search for
start  Starting position, default is start of string

int MISTRING::FindNextNotInSet const MISTRING chars,
int  start = 0
const
 

Find next occurrence not in given set of characters.

Returns:
Character position or -1 if not found.
Parameters:
chars  Characters to search for
start  Starting position, default is start of string

int MISTRING::FindNextOf UNICODE  c,
int  start = 0
const
 

Find next occurrence of given character (similar to strchr).

Returns:
Position of character or -1 if not found.
Parameters:
c  Character to search for
start  Starting position, default is start of string

int MISTRING::FindNextOf const MISTRING str,
int  start = 0
const
 

Find next occurrence of given string (similar to strstr).

Returns:
Starting position of substring or -1 if not found.
Parameters:
str  String to search for
start  Starting position, default is start of string

int MISTRING::FindPrevInSet const MISTRING chars,
int  start = INT32_MAX
const
 

Find previous occurrence in given set of characters.

Returns:
Position or -1 if not found.
Parameters:
chars  Characters to search for
start  Starting position, default is end of string

int MISTRING::FindPrevNotInSet const MISTRING chars,
int  start = INT32_MAX
const
 

Find previous occurrence not in given set of characters.

Returns:
Position or -1 if not found.
Parameters:
chars  Characters to search for
start  Starting position, default is end of string

int MISTRING::FindPrevOf UNICODE  c,
int  start = INT32_MAX
const
 

Find previous occurrence of given character (similar to strrchr).

Returns:
Position of character or -1 if not found.
Parameters:
c  Character to search for
start  Starting position, default is end of string

void MISTRING::FmtEnableSubstitution bool  enable = true  ) 
 

Enable substitution during formatting.

Initial default is enabled.

Parameters:
enable  'true' to enable, 'false' to disable

void MISTRING::FmtSetBase int  base  ) 
 

Set integer base.

Parameters:
base  Integer base 2-36

void MISTRING::FmtSetFill UNICODE  fill  ) 
 

Set fill character for padding.

Parameters:
fill  Fill character

void MISTRING::FmtSetFloat FLOATFMT  floatmode  ) 
 

Set floating point formatting mode.

Parameters:
floatmode  Floating point formatting mode

void MISTRING::FmtSetPrecision int  precision  ) 
 

Set precision (number of decimal places) for floating-point output.

Parameters:
precision  Floating-point precision

void MISTRING::FmtSetSign bool  sign  ) 
 

Set whether to shown sign for positive numbers.

Sign is only shown if integer base is 10.

Parameters:
sign  True to show sign, false to not

void MISTRING::FmtSetWidth int  width  ) 
 

Set minimum width for next formatted value.

Note that at width setting only applies to one value after which time it will reset to 0 (minimum).

Parameters:
width  Minimum width

const MISTRING& MISTRING::GetEmpty  )  [static]
 

Get reference to empty string.

void* MISTRING::GetEncoded CHAR_ENCODING  encoding  )  const
 

Get string in specified encoding.

Returns:
Encoded string caller must free.
Parameters:
encoding  Encoding

int MISTRING::GetLength  )  const
 

Get length in characters.

Returns:
Length in characters.

const UNICODE* MISTRING::GetReference  )  const
 

Get string reference.

Used to avoid static_cast<const UNICODE*>(MISTRING).

Returns:
Pointer to internal string, do not free!

UNICODE* MISTRING::GetString  )  const
 

Get allocated string.

Returns:
Pointer to string, caller must free

MISTRING MISTRING::GetSubString int  start,
int  end
const
 

Retrieve sub-string.

Returns:
Substring from position up to specified length.
Parameters:
start  Starting position
end  Ending position (inclusive)

MISTRING MISTRING::GetSubString int  start  )  const
 

Retrieve sub-string.

Returns:
Substring from position to end of string.
Parameters:
start  Starting position

bool MISTRING::IniRead INIHANDLE  handle,
const char *  group,
const char *  field
 

Read string from .ini file.

Returns:
true if entry in file, false if not
Parameters:
handle  Ini Handle created by IniOpen()
group  Group to look for ini entry, App Name if =0
field  Field to read string from

bool MISTRING::IniReadML INIHANDLE  handle,
const char *  group,
const char *  field
 

Read multi-line string from .ini file.

Returns:
true if entry in file, false if not
Parameters:
handle  Ini Handle created by IniOpen()
group  Group to look for ini entry, App Name if =0
field  Field to read string from

void MISTRING::IniWrite INIHANDLE  handle,
const char *  group,
const char *  field
const
 

Write string to .ini file.

Parameters:
handle  Ini Handle created by IniOpen()
group  Group to write ini entry, App Name if =0
field  Field to write string to

void MISTRING::IniWriteML INIHANDLE  handle,
const char *  group,
const char *  field
const
 

Write multi-line string to .ini file.

Parameters:
handle  Ini Handle created by IniOpen()
group  Group to write ini entry, App Name if =0
field  Field to write string to

void MISTRING::Insert int  start,
const MISTRING str,
int  strstart = 0,
int  strend = INT32_MAX
 

Insert all or part of another string at specified position.

Parameters:
start  Position to insert before
str  String to insert
strstart  Start of replace string
strend  End of replace string

bool MISTRING::IsEmpty  )  const
 

Determine if string is empty.

Returns:
true if string is empty, false if not.

void MISTRING::Join const MILIST< MISTRING > &  list,
const char *  sep = ""
 

Join all the strings in an MISTRINGLIST into one string The char* variant of this function exists because most often, you want to join the strings together with simple whitespace or commas.

void MISTRING::Join const MILIST< MISTRING > &  list,
const UNICODE sep
 

Join all the strings in an MISTRINGLIST into one string.

MISTRING::operator const UNICODE *  )  const
 

Cast to (const UNICODE *).

Cast to non-const is not supported as destruction cannot be enforced for temporaries. Cast to UINT8* or char* is not permitted as encoding cannot be specified.

MISTRING& MISTRING::operator+= UNICODE  c  ) 
 

Append single character (Unicode or ASCII).

MISTRING& MISTRING::operator+= const char *  rhs  ) 
 

Concatenation from char* (ASCII/ISO-Latin1).

MISTRING& MISTRING::operator+= const UNICODE rhs  ) 
 

Concatenation from UNICODE* string.

MISTRING& MISTRING::operator+= const MISTRING rhs  ) 
 

Concatenation from MISTRING.

MISTRING& MISTRING::operator<< TEXTID  textid  ) 
 

Format and text from TEXTID put into string.

MISTRING& MISTRING::operator<< const UNICODE s  ) 
 

Format and put UNICODE string into string.

MISTRING& MISTRING::operator<< const char *  s  ) 
 

Format and put ASCII string into string.

MISTRING& MISTRING::operator<< double  f  ) 
 

Format and put (double) value into string.

MISTRING& MISTRING::operator<< float  f  ) 
 

Format and put (float) value into string.

MISTRING& MISTRING::operator<< UINT64  n  ) 
 

Format and put (UINT64) value into string.

MISTRING& MISTRING::operator<< unsigned long  n  ) 
 

Format and put (unsigned long) value into string.

MISTRING& MISTRING::operator<< unsigned int  n  ) 
 

Format and put UINT32 (unsigned int) value into string.

MISTRING& MISTRING::operator<< unsigned short  n  ) 
 

Format and put UINT16 (unsigned short) value into string.

Warning, use of UNICODE will result in numeric value being put into string.

MISTRING& MISTRING::operator<< INT64  n  ) 
 

Format and put (INT64) value into string.

MISTRING& MISTRING::operator<< long  n  ) 
 

Format and put (long) value into string.

MISTRING& MISTRING::operator<< int  n  ) 
 

Format and put INT32 (int) value into string.

MISTRING& MISTRING::operator<< short  n  ) 
 

Format and put INT16 (short) value into string.

MISTRING& MISTRING::operator<< unsigned char  n  ) 
 

Format and put UINT8 (unsigned char) numeric value into string.

MISTRING& MISTRING::operator<< signed char  n  ) 
 

Format and put INT8 (signed char) numeric value into string.

MISTRING& MISTRING::operator<< char  c  ) 
 

Format and put single character into string.

MISTRING& MISTRING::operator<< bool  b  ) 
 

Format and put 'bool' value into string.

MISTRING& MISTRING::operator<< STR_OP  op  ) 
 

Perform operation on string.

MISTRING& MISTRING::operator= const char *  rhs  ) 
 

Systems where wchar_t is not same as UINT16(UNICODE).

MISTRING& MISTRING::operator= const UNICODE rhs  ) 
 

Assignment from UNICODE* string.

MISTRING& MISTRING::operator= TEXTID  textid  ) 
 

Assignment from TEXTID.

MISTRING& MISTRING::operator= const STRUTF8 rhs  ) 
 

Assignment from STRUTF8.

MISTRING& MISTRING::operator= const MISTRING rhs  ) 
 

Assignment from MISTRING.

const UNICODE& MISTRING::operator[] int  idx  )  const
 

Read array element.

void MISTRING::Pad UNICODE  c,
int  numchars