MISTRING Class Reference

General string class. More...

#include <mi32/mistring.h>

Inheritance diagram for MISTRING:

Inheritance graph
SMLSTRING
[legend]
List of all members.

Public Types

enum  ENCODING { ENCODING_URI = 0, ENCODING_XML = 1, ENCODING_HTML = 2 }
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 MIUNICODE *str, int start=0, int end=INT32_MAX)
void Assign (const MISTRING &str, int start=0, int end=INT32_MAX)
void AssignFromSizeAbbr (INT64 size)
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
MISTRINGConvertFrom (ENCODING Encoding)
MISTRINGConvertTo (ENCODING Encoding)
double ConvertToDouble () const
int FindNextInSet (const MISTRING &chars, int start=0) const
int FindNextNotInSet (const MISTRING &chars, int start=0) const
int FindNextOf (MIUNICODE 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 (MIUNICODE c, int start=INT32_MAX) const
void FmtEnableSubstitution (bool enable=true)
void FmtSetBase (int base)
void FmtSetFill (MIUNICODE 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 MIUNICODEGetReference () const
MIUNICODEGetString () 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 MIUNICODE *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 MIUNICODE *ustr)
 MISTRING (const MISTRING &rhs)
 MISTRING ()
 operator const MIUNICODE * () const
MISTRINGoperator+= (MIUNICODE c)
MISTRINGoperator+= (const char *rhs)
MISTRINGoperator+= (const MIUNICODE *rhs)
MISTRINGoperator+= (const MISTRING &rhs)
MISTRINGoperator<< (TEXTID textid)
MISTRINGoperator<< (const MISTRING &s)
MISTRINGoperator<< (const STRUTF8 &s)
MISTRINGoperator<< (const MIUNICODE *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 MIUNICODE *rhs)
MISTRINGoperator= (TEXTID textid)
MISTRINGoperator= (const STRUTF8 &rhs)
MISTRINGoperator= (const MISTRING &rhs)
const MIUNICODEoperator[] (int idx) const
void Pad (MIUNICODE c, int numchars)
void PadToLength (MIUNICODE 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, MIUNICODE c)
ERRVALUE Reserve (int numchars)
bool Search (const UCREGEXP &regex, UINT32 &MatchStart, UINT32 &MatchEnd, UINT32 Start=0) const
bool Search (const MIUNICODE *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 MIUNICODE *regexp, MILIST< MISTRING > &list, int maxitems=0) const
int Split (MIUNICODE ch, MILIST< MISTRING > &list, int maxitems=0) const
void Truncate (int length)
 ~MISTRING ()

Static Public Member Functions

static 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 310 of file mistring.h.


Member Enumeration Documentation

enum MISTRING::ENCODING

Enumerator:
ENCODING_URI  Encoding to use URI non-reserved characters.
ENCODING_XML  Encoding to use XML non-reserved characters.
ENCODING_HTML  Encoding to use HTML, convert from MicroImages test style formatting codes.

Definition at line 313 of file mistring.h.

enum MISTRING::FLOATFMT

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

Definition at line 319 of file mistring.h.

enum MISTRING::LINETERM

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

Definition at line 325 of file mistring.h.


Constructor & Destructor Documentation

MISTRING::MISTRING (  ) 

Default constructor.

MISTRING::MISTRING ( const MISTRING rhs  ) 

Copy constructor.

MISTRING::MISTRING ( const MIUNICODE ustr  ) 

Construct from MIUNICODE* 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 MIUNICODE str,
int  start = 0,
int  end = INT32_MAX 
)

Assign from MIUNICODE string.

Parameters:
str  Buffer holding MIUNICODE 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

void MISTRING::AssignFromSizeAbbr ( INT64  size  ) 

Assign to string from 'size' Will append KB, MB, GB, .

.. depending on the value of 'size'

Parameters:
size  Size to generate abbreviated form from

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, -1 to compare to end of 'str'

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, -1 to use length of comparison string

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, -1 to compare to end of 'str'

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, -1 to use length of comparison string

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

MISTRING& MISTRING::ConvertFrom ( ENCODING  Encoding  ) 

Convert from an encoding specified by 'Encoding' parameter The will replace encoded characters in-place with reserved replacements Eg: for XML '&' would be replaced with '&'.

For HTML '20' will be replaced with 'space'

Returns:
: 'this' to facilitate use in '<<' operations

MISTRING& MISTRING::ConvertTo ( ENCODING  Encoding  ) 

Convert to an encoding specified by 'Encoding' parameter The will replace reserved characters in-place with known replacements Eg: for XML '&' would be replaced with '&'.

For HTML 'space' will be replaced with '20' WARNING: To convert to URI or XML, the conversion must occur in pieces, not the whole thing

Returns:
: 'this' to facilitate use in '<<' operations

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 ( MIUNICODE  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 ( MIUNICODE  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 ( MIUNICODE  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

static 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 MIUNICODE* MISTRING::GetReference (  )  const

Get string reference.

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

Returns:
Pointer to internal string, do not free!

MIUNICODE* 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 MIUNICODE sep 
)

Join all the strings in an MISTRINGLIST into one string.

MISTRING::operator const MIUNICODE * (  )  const

Cast to (const MIUNICODE *).

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+= ( MIUNICODE  c  ) 

Append single character (Unicode or ASCII).

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

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

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

Concatenation from MIUNICODE* 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 MISTRING s  ) 

Format and put MISTRING into string.

MISTRING& MISTRING::operator<< ( const STRUTF8 s  ) 

Format and put STRUTF8 string into string.

MISTRING& MISTRING::operator<< ( const MIUNICODE s  ) 

Format and put MIUNICODE 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 MIUNICODE 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  ) 

Assignment from char* (ASCII/ISO-Latin1). Systems where wchar_t is not same as UINT16(MIUNICODE).

MISTRING& MISTRING::operator= ( const MIUNICODE rhs  ) 

Assignment from MIUNICODE* string.

MISTRING& MISTRING::operator= ( TEXTID  textid  )