mstring::MString Class Reference

A string class. More...

#include <mstring.h>

List of all members.

Public Member Functions

 MString ()
 MString (const char *str)
 MString (const MString &str)
 MString (char c, uint len)
 MString (const char *str, uint n)
virtual ~MString ()
MStringoperator= (const char *str)
MStringoperator= (const MString &str)
bool operator< (const char *str) const
bool operator<= (const char *str) const
bool operator== (const char *str) const
bool operator!= (const char *str) const
bool operator>= (const char *str) const
bool operator> (const char *str) const
MString operator+ (const char *str) const
MString operator+ (const MString &str) const
MStringoperator+= (const char *str)
MStringoperator+= (const MString &str)
MString operator * (uint n) const
MStringoperator *= (uint n)
 operator const char * () const
const char & operator[] (int pos) const
char & operator[] (int pos)
MString operator() (int start, int end) const
void clear ()
const char * get () const
uint len () const
bool isEmpty () const
MString left (uint len) const
MString right (uint len) const
MString mid (uint start, uint len=0xffffffff) const
MString trimLeft (const char c= '\0') const
MString trimRight (const char c= '\0') const
MString trimAll (const char c= '\0') const
MString padLeft (uint len, char c= ' ') const
MString padRight (uint len, char c= ' ') const
MString padCenter (uint len, char c= ' ') const
MString caseUpper () const
MString caseLower () const
bool startsWith (const char *str) const
bool endsWith (const char *str) const
MStringtoString (int val, int width=-1, char fillChar= ' ', NumericFormat format=DefaultFormat, NumericBase base=Dec)
MStringtoString (uint val, int width=-1, char fillChar= ' ', NumericFormat format=DefaultFormat, NumericBase base=Dec)
MStringtoString (long val, int width=-1, char fillChar= ' ', NumericFormat format=DefaultFormat, NumericBase base=Dec)
MStringtoString (ulong val, int width=-1, char fillChar= ' ', NumericFormat format=DefaultFormat, NumericBase base=Dec)
MStringtoString (float val, int precision=-1, int width=-1, char fillChar= ' ', NumericFormat format=DefaultFormat)
MStringtoString (double val, int precision=-1, int width=-1, char fillChar= ' ', NumericFormat format=DefaultFormat)
MStringboolToString (bool val, bool yesNo=false, const MBoolStrings *format=NULL)
MStringtimeToString (time_t val, TimeFormat which=Date_Time, const MTimeStrings *format=NULL)
int toInt (NumericBase base=Dec) const
uint toUInt (NumericBase base=Dec) const
long toLong (NumericBase base=Dec) const
ulong toULong (NumericBase base=Dec) const
double toDouble () const
int toBool (const MBoolStrings *format=NULL) const
time_t toTime (TimeFormat which=Date_Time, const MTimeStrings *format=NULL) const
uint occurs (const char *str) const
int find (const char *str, int pos=0) const
int at (const char *str, int n=1) const
MString section (const char *sep, int n) const
MStringList split (const char *sep, bool ignoreEmpty=false) const
MStringreplace (const char *str, const char *byStr)
MString wrap (uint width, uint indent=0, bool hanging=false) const
MStringappend (const char *str, const char *sep=MString::NL)

Static Public Member Functions

static MString version (bool verbose=true)
static void setNumLocale (bool on=true)
static void setTimeLocale (bool on=true)
static MString number (int val, int width=-1, char fillChar= ' ', NumericFormat format=DefaultFormat, NumericBase base=Dec)
static MString number (uint val, int width=-1, char fillChar= ' ', NumericFormat format=DefaultFormat, NumericBase base=Dec)
static MString number (long val, int width=-1, char fillChar= ' ', NumericFormat format=DefaultFormat, NumericBase base=Dec)
static MString number (ulong val, int width=-1, char fillChar= ' ', NumericFormat format=DefaultFormat, NumericBase base=Dec)
static MString number (float val, int precision=-1, int width=-1, char fillChar= ' ', NumericFormat format=DefaultFormat)
static MString number (double val, int precision=-1, int width=-1, char fillChar= ' ', NumericFormat format=DefaultFormat)
static MString boolean (bool val, bool yesNo=false, const MBoolStrings *format=NULL)
static MString time (time_t val, TimeFormat which=Date_Time, const MTimeStrings *format=NULL)

Static Public Attributes

static const MString NL

Protected Member Functions

void initClass ()
void newString (uint len)
void delString ()
virtual uint calcWidth () const
virtual MString constructIndent (uint width) const

Protected Attributes

char * _string
uint stringLen

Static Protected Attributes

static const MBoolStrings BOOLLOCALES []
static const MTimeStrings TIMELOCALES []


Detailed Description

A lightweight string class for handling null-terminated ASCII strings without any dependencies except for a standard C++ environment. This class wraps the C string functions and provides a convenient interface for processing strings.

Objects of this class can be used as input for all of its methods that expect a const char* parameter; unwrapping will be done implicitely by operator const char*().

Author:
Martin "Murphy" Gebert <Murphy dot Gebert at gmx dot de>


Constructor & Destructor Documentation

mstring::MString::MString (  ) 

Constructs an empty MString object.

mstring::MString::MString ( const char *  str  ) 

Constructs a MString object containing the given null-terminated string.

mstring::MString::MString ( const MString str  ) 

Constructs a copy of another MString object.

mstring::MString::MString ( char  c,
uint  len 
)

Constructs a MString of length len filled with character c.

mstring::MString::MString ( const char *  str,
uint  n 
)

Constructs a MString of n times the length of str and fills it with str.

virtual mstring::MString::~MString (  )  [virtual]

Destroys the MString object.


Member Function Documentation

MString& mstring::MString::operator= ( const char *  str  ) 

Assignes the string from a char array.

MString& mstring::MString::operator= ( const MString str  ) 

Assignes the string from another MString object.

bool mstring::MString::operator< ( const char *  str  )  const

Lexicographically compares the given to the contained string and returns true if contained string is less than the given.

bool mstring::MString::operator<= ( const char *  str  )  const

Lexicographically compares the given to the contained string and returns true if contained string is less or equal the given.

bool mstring::MString::operator== ( const char *  str  )  const

Compares the contained string with the given one, returns true if they're equal.

bool mstring::MString::operator!= ( const char *  str  )  const

Compares the contained string with the given one, returns true if they aren't equal.

bool mstring::MString::operator>= ( const char *  str  )  const

Lexicographically compares the given to the contained string and returns true if contained string is greater or equal the given.

bool mstring::MString::operator> ( const char *  str  )  const

Lexicographically compares the given to the contained string and returns true if contained string is greater than the given.

MString mstring::MString::operator+ ( const char *  str  )  const

Concatenates the given string to this MString and returns the result as a new MString.

MString mstring::MString::operator+ ( const MString str  )  const

Concatenates the given MString to this MString and returns the result as a new MString.

MString& mstring::MString::operator+= ( const char *  str  ) 

Appends a string to this MString.

MString& mstring::MString::operator+= ( const MString str  ) 

Appends a MString to this MString.

MString mstring::MString::operator * ( uint  n  )  const

Returns a MString which is n times the contained string concatenated.

MString& mstring::MString::operator *= ( uint  n  ) 

Assignes n times the contained string to this MString and returns a reference to it.

mstring::MString::operator const char * (  )  const

Returns a readonly pointer to the contained string.

See also:
Method get().

const char& mstring::MString::operator[] ( int  pos  )  const

Returns a const reference to the character at position pos in the contained string (begin of string: pos == 0), or the last character if pos points to a position behind the last character of the contained string, or the first character if pos points to a position before the first character of the contained string, or a reference to a NULL character if the string is empty.
If pos is negative then characters are counted backwards from the end of the contained string; -1 is the last character etc.

Watch operator precedence on pointers to MString instances! Correct invocation:

        (*mstrobj)[x]

char& mstring::MString::operator[] ( int  pos  ) 

As above, but returns a mutable reference to the character; can be used to assign single characters to a position in the string.

MString mstring::MString::operator() ( int  start,
int  end 
) const

Returns a slice of the string from position start until (and not including) position end. If start is out of range or end isn't larger than start an empty string will be returned.
From begin of the string: start = 0.
Until the end of the string: end = 0.
If a position is negative it will be counted from the end of the string; -1 is the last character, -2 the second last and so on.

Compare the slicing facility of Python <http://www.python.org>.

void mstring::MString::clear (  ) 

Discards the content of the MString object.

const char* mstring::MString::get (  )  const

Returns a readonly pointer to the contained string.

See also:
operator const char*().

uint mstring::MString::len (  )  const

Returns the length of the contained string.

bool mstring::MString::isEmpty (  )  const

Returns true if the MString is empty.

MString mstring::MString::left ( uint  len  )  const

Returns the len left characters of the contained string.

See also:
Method startsWith().

MString mstring::MString::right ( uint  len  )  const

Returns the len right characters of the contained string.

See also:
Method endsWith().

MString mstring::MString::mid ( uint  start,
uint  len = 0xffffffff 
) const

Returns len characters of the contained string, starting at position start (begin of string = pos. 0); if len is omitted then the rest of the string will be returned.

See also:
Method left(), method right(), operator()().

MString mstring::MString::trimLeft ( const char  c = '\0'  )  const

Returns the contained string without leading chars c; if c is empty it defaults to whitespaces.

MString mstring::MString::trimRight ( const char  c = '\0'  )  const

Returns the contained string without trailing chars c; if c is empty it defaults to whitespaces.

MString mstring::MString::trimAll ( const char  c = '\0'  )  const

Returns the contained string without leading and trailing chars c; if c is empty it defaults to whitespaces.

MString mstring::MString::padLeft ( uint  len,
char  c = ' ' 
) const

Returns the contained string padded on the left to len characters with c, if too long the string will be cut off on the right. c defaults to space.

MString mstring::MString::padRight ( uint  len,
char  c = ' ' 
) const

Returns the contained string padded on the right to len characters with c, if too long the string will be cut off on the left. c defaults to space.

MString mstring::MString::padCenter ( uint  len,
char  c = ' ' 
) const

Returns the contained string centered by padding it on both sides to len characters with c, if too long the string will be cut off on the right. c defaults to space.

MString mstring::MString::caseUpper (  )  const

Returns the contained string converted to uppercase.

MString mstring::MString::caseLower (  )  const

Returns the contained string converted to lowercase.

bool mstring::MString::startsWith ( const char *  str  )  const

Checks if the contained string starts with str. Always true for empty str.

bool mstring::MString::endsWith ( const char *  str  )  const

Checks if the contained string ends with str. Always true for empty str.

MString& mstring::MString::toString ( int  val,
int  width = -1,
char  fillChar = ' ',
NumericFormat  format = DefaultFormat,
NumericBase  base = Dec 
)

Converts the given integer value to a string, assignes it to this MString and returns a reference to this MString.
If a width > -1 is given the output will be right justified within this width by padding it on the left with fillChar. Format flags and a numeric base may be given for the conversion (currently only octal, decimal and hexadecimal are supported).

See also:
Method toInt(), static method number(int, int, char, NumericFormat, NumericBase).

MString& mstring::MString::toString ( uint  val,
int  width = -1,
char  fillChar = ' ',
NumericFormat  format = DefaultFormat,
NumericBase  base = Dec 
)

Converts the given unsigned integer value to a string, assignes it to this MString and returns a reference to this MString.
If a width > -1 is given the output will be right justified within this width by padding it on the left with fillChar. Format flags and a numeric base may be given for the conversion (currently only octal, decimal and hexadecimal are supported).

See also:
Method toUInt(), static method number(uint, int, char, NumericFormat, NumericBase).

MString& mstring::MString::toString ( long  val,
int  width = -1,
char  fillChar = ' ',
NumericFormat  format = DefaultFormat,
NumericBase  base = Dec 
)

Converts the given long integer value to a string, assignes it to this MString and returns a reference to this MString.
If a width > -1 is given the output will be right justified within this width by padding it on the left with fillChar. Format flags and a numeric base may be given for the conversion (currently only octal, decimal and hexadecimal are supported).

See also:
Method toLong(), static method number(long, int, char, NumericFormat, NumericBase).

MString& mstring::MString::toString ( ulong  val,
int  width = -1,
char  fillChar = ' ',
NumericFormat  format = DefaultFormat,
NumericBase  base = Dec 
)

Converts the given unsigned long integer value to a string, assignes it to this MString and returns a reference to this MString.
If a width > -1 is given the output will be right justified within this width by padding it on the left with fillChar. Format flags and a numeric base may be given for the conversion (currently only octal, decimal and hexadecimal are supported).

See also:
Method toULong(), static method number(ulong, int, char, NumericFormat, NumericBase).

MString& mstring::MString::toString ( float  val,
int  precision = -1,
int  width = -1,
char  fillChar = ' ',
NumericFormat  format = DefaultFormat 
)

Converts the given float value to a string, assignes it to this MString and returns a reference to this MString. Representation of the decimal point depends on the current locale environment.
Provide a precision if you want a fixed-point string. If a width > -1 is given the output will be right justified within this width by padding it on the left with fillChar.

See also:
Method setNumLocale(), method toDouble(), static method number(float, int, int, char, NumericFormat).

MString& mstring::MString::toString ( double  val,
int  precision = -1,
int  width = -1,
char  fillChar = ' ',
NumericFormat  format = DefaultFormat 
)

Converts the given double value to a string, assignes it to this MString and returns a reference to this MString. Representation of the decimal point depends on the current locale environment.
Provide a precision if you want a fixed-point string. If a width > -1 is given the output will be right justified within this width by padding it on the left with fillChar.

See also:
Method setNumLocale(), method toDouble(), static method number(double, int, int, char, NumericFormat).

MString& mstring::MString::boolToString ( bool  val,
bool  yesNo = false,
const MBoolStrings format = NULL 
)

Converts the given bool value to a string, assignes it to this MString and returns a reference to this MString. If no userdefined MBoolStrings are given conversion is performed according to the current locale environment if a fitting entry is available; else the default entry of MString::BOOLLOCALES will be used.
If yesNo=true the result will be the equivalent to "Yes" or "No" instead of "True" or "False". If no match is found the contained string keeps its current content; should occur only if there's no default entry.

See also:
Static array BOOLLOCALES, method setNumLocale(), method toBool(), static method boolean(bool, bool, const MBoolStrings*).

MString& mstring::MString::timeToString ( time_t  val,
TimeFormat  which = Date_Time,
const MTimeStrings format = NULL 
)

Converts the given time value into its string representation, using the specified time format (results either in a string containing a date, or a time of day, or both separated by a space, which is the default), assignes it to this MString and returns a reference to it. If no userdefined MTimeStrings are given conversion is performed according to the current locale environment; if no fitting entry in MString::TIMELOCALES is available the default entry is used. If MTimeStrings are provided by the user the locale setting is irrelevant.

See also:
Static array TIMELOCALES, method setTimeLocale(), method toTime(), static method time(time_t, TimeFormat, const MTimeStrings*).

int mstring::MString::toInt ( NumericBase  base = Dec  )  const

Extracts an integer value from the beginning of the contained string and calculates its value to the given base; base defaults to decimal numbers. Extraction terminates at the first character that isn't part of the numeric base, counting from 0 to 9 and then from A to Z, and is not case sensitive.

See also:
Method toString(int, int, char, NumericFormat, NumericBase), static method number(int, int, char, NumericFormat, NumericBase).

uint mstring::MString::toUInt ( NumericBase  base = Dec  )  const

Extracts an unsigned integer from the beginning of the contained string and calculates its value to the given base; base defaults to decimal numbers. Extraction terminates at the first character that isn't part of the numeric base, counting from 0 to 9 and then from A to Z, and is not case sensitive. Negative numbers create an overflow.

See also:
Method toString(uint, int, char, NumericFormat, NumericBase), static method number(uint, int, char, NumericFormat, NumericBase).

long mstring::MString::toLong ( NumericBase  base = Dec  )  const

Extracts a long integer value from the beginning of the contained string and calculates its value to the given base; base defaults to decimal numbers. Extraction terminates at the first character that isn't part of the numeric base, counting from 0 to 9 and then from A to Z, and is not case sensitive.

See also:
Method toString(long, int, char, NumericFormat, NumericBase), static method number(long, int, char, NumericFormat, NumericBase).

ulong mstring::MString::toULong ( NumericBase  base = Dec  )  const

Extracts an unsigned long integer from the beginning of the contained string and calculates its value to the given base; base defaults to decimal numbers. Extraction terminates at the first character that isn't part of the numeric base, counting from 0 to 9 and then from A to Z, and is not case sensitive. Negative numbers create an overflow.

See also:
Method toString(ulong, int, char, NumericFormat, NumericBase), static method number(ulong, int, char, NumericFormat, NumericBase).

double mstring::MString::toDouble (  )  const

Extracts a floating point value from the beginning of the contained string if it starts with a number. Recognition of the decimal point depends on the current locale environment.

See also:
Method setNumLocale(), method toString(float, int, int, char, NumericFormat), method toString(double, int, int, char, NumericFormat), static method number(float, int, int, char, NumericFormat), static method number(double, int, int, char, NumericFormat).

int mstring::MString::toBool ( const MBoolStrings format = NULL  )  const

Extracts a boolean value from the beginning of the contained string by comparing it either to the given userdefined MBoolStrings or searching MString::BOOLLOCALES for a match applicable to the current locale environment or the default entry. The comparison is case-insensitive and includes both the True/False and Yes/No string pairs.
Returns 1 if true, 0 if false or -1 if no matching string can be found.
ATTENTION: -1 casted to bool is interpreted as true! Workaround for to interpret an unknown string as false:

        bool b = (MString("?").toBool() > 0);
See also:
Static array BOOLLOCALES, method setNumLocale(), method boolToString(bool, bool, const MBoolStrings*), static method boolean(bool, bool, const MBoolStrings*).

time_t mstring::MString::toTime ( TimeFormat  which = Date_Time,
const MTimeStrings format = NULL 
) const

Extracts a time_t value from the beginning of the contained string by comparing it either to the given userdefine MTimeStrings or searching MString::TIMELOCALES for a match applicable to the current locale environment or the default entry. Returns -1 if no matching format string can be found or the given string is an invalid time.
When converting from a date the time will be set to 00:00:00 (midnight), from a time the date it will be set to the current day.
This method recognizes the following strftime() commands in the format string: %%, %Y, %y, %m, %d, %H, %M, %S, %p. Short years (%y) will be interpreted as the current century. All other characters will be compared to the contained string; the string will be treated as invalid if they don't match.

See also:
Static array TIMELOCALES, method setNumLocale(), method timeToString(time_t, TimeFormat, const MTimeStrings*), static method time(time_t, TimeFormat, const MTimeStrings*).

uint mstring::MString::occurs ( const char *  str  )  const

Returns the number of times the given string occurs in the contained string.

See also:
Method find(), method at().

int mstring::MString::find ( const char *  str,
int  pos = 0 
) const

Searches the given string str in the contained string, starting at position pos, and returns the position of the first occurance or -1 if not found. The first position in a string is 0. If pos is negative the search is performed backwards from the end of the contained string; last character is -1, second last -2 and so on.

See also:
Method at(), method occurs().

int mstring::MString::at ( const char *  str,
int  n = 1 
) const

Returns the position of the nth occurance of the given in the contained string or -1 if not found. If n is negative the search is performed backwards from the end of the contained string; -1 is the last occurance etc.

See also:
Method find(), method occurs().

MString mstring::MString::section ( const char *  sep,
int  n 
) const

Returns the content of the nth section, starting at n = 0, of the contained string as parted by the separator string sep, or an empty string if the section was not found. If n is negative counting starts at the end of the string.

MStringList mstring::MString::split ( const char *  sep,
bool  ignoreEmpty = false 
) const

Returns a list with the content of all sections parted by the separator string sep. If ingoreEmpty == true then empty sections won't be part of the list. If the separator is empty the list will contain the whole string split into single characters.

See also:
Class MStringList.

MString& mstring::MString::replace ( const char *  str,
const char *  byStr 
)

Replaces every occurance of string str with string byStr and returns a reference to this MString object.

MString mstring::MString::wrap ( uint  width,
uint  indent = 0,
bool  hanging = false 
) const

Wraps the contained string using MString::NL and returns a MString with the result. The lines will be wrapped at whitespaces or in mid-word if necessary, so that no line exceeds the given width. If an indent is passed each line will be indented by the given value, while the first line spans the whole width if hanging == true. Existing linebreaks are taken into account if they equal MString::NL, tabulators are not!
The metrics for width and indent is characters by default; you can reimplement the protected members calcWidth() and constructIndent() if you would like to use other algorithms to calculate string widths (e. g. pixels for proportional fonts).

MString& mstring::MString::append ( const char *  str,
const char *  sep = MString::NL 
)

Appends str to the contained string with sep as separator and returns a reference to this MString object. If sep is already terminating the contained string, or the contained string is empty, then first str and then sep will be appended, else sep separates contained string and appended str. sep defaults to the platform-dependent newline character.

static MString mstring::MString::version ( bool  verbose = true  )  [static]

Returns a MString with the version of the MString class; if verbose is false then the MString will only contain the version number, else name, version, license information and information about the environment.

static void mstring::MString::setNumLocale ( bool  on = true  )  [static]

Sets the decimal point character and other preferences to the local settings as extracted from the system, or to the default if on=false (concerns LC_NUMERIC only).
ATTENTION: Setting this to on=true changes the behaviour of your whole application, e. g. printf(), not only that of the MString object!

See also:
Define MSTRING_LOCALE.

static void mstring::MString::setTimeLocale ( bool  on = true  )  [static]

Sets the weekday names and other preferences to the local settings as extracted from the system, or to the default if on=false (concerns LC_TIME only).
ATTENTION: Setting this to on=true changes the behaviour of your whole application, e. g. strftime(), not only that of the MString object!

See also:
Define MSTRING_LOCALE.

static MString mstring::MString::number ( int  val,
int  width = -1,
char  fillChar = ' ',
NumericFormat  format = DefaultFormat,
NumericBase  base = Dec 
) [static]

Converts the given integer value to a MString.
Provided for convenience.

See also:
Method toString(int, int, char, NumericFormat, NumericBase), method toInt().

static MString mstring::MString::number ( uint  val,
int  width = -1,
char  fillChar = ' ',
NumericFormat  format = DefaultFormat,
NumericBase  base = Dec 
) [static]

Converts the given unsigned integer value to a MString.
Provided for convenience.

See also:
Method toString(uint, int, char, NumericFormat, NumericBase), method toUInt().

static MString mstring::MString::number ( long  val,
int  width = -1,
char  fillChar = ' ',
NumericFormat  format = DefaultFormat,
NumericBase  base = Dec 
) [static]

Converts the given long integer value to a MString.
Provided for convenience.

See also:
Method toString(long, int, char, NumericFormat, NumericBase), method toLong().

static MString mstring::MString::number ( ulong  val,
int  width = -1,
char  fillChar = ' ',
NumericFormat  format = DefaultFormat,
NumericBase  base = Dec 
) [static]

Converts the given unsigned long integer value to a MString.
Provided for convenience.

See also:
Method toString(ulong, int, char, NumericFormat, NumericBase), method toULong().

static MString mstring::MString::number ( float  val,
int  precision = -1,
int  width = -1,
char  fillChar = ' ',
NumericFormat  format = DefaultFormat 
) [static]

Converts the given float value to a MString.
Provided for convenience.

See also:
Method toString(float, int, int, char, NumericFormat), method toDouble().

static MString mstring::MString::number ( double  val,
int  precision = -1,
int  width = -1,
char  fillChar = ' ',
NumericFormat  format = DefaultFormat 
) [static]

Converts the given double value to a MString.
Provided for convenience.

See also:
Method toString(double, int, int, char, NumericFormat), method toDouble().

static MString mstring::MString::boolean ( bool  val,
bool  yesNo = false,
const MBoolStrings format = NULL 
) [static]

Converts the given bool value to a MString.
Provided for convenience.

See also:
Static array BOOLLOCALES, method setNumLocale(), method boolToString(bool, bool, const MBoolStrings*), method toBool().

static MString mstring::MString::time ( time_t  val,
TimeFormat  which = Date_Time,
const MTimeStrings format = NULL 
) [static]

Converts the given time_t value to a MString.
Provided for convenience.

See also:
Static array TIMELOCALES, method setTimeLocale(), method timeToString(time_t, TimeFormat, const MTimeStrings*), method toTime().

void mstring::MString::initClass (  )  [protected]

Initialize the class and its environment.
To be called from constructors only!

void mstring::MString::newString ( uint  len  )  [protected]

Reserves memory for a string of the given length including the terminator. Call delString() before to delete the old content.

void mstring::MString::delString (  )  [protected]

Deletes the contained string from memory and resets the buffered length.

virtual uint mstring::MString::calcWidth (  )  const [protected, virtual]

Returns the width of the current MString in characters.
Used by wrap(); reimplement for other metrics (e. g. pixels).

virtual MString mstring::MString::constructIndent ( uint  width  )  const [protected, virtual]

Returns a MString object with the corresponding number of spaces to span width characters.
Used by wrap() for the indentation; reimplement for other metrics (e. g. pixels) or to return other characters (e. g. tabulators).


Member Data Documentation

const MString mstring::MString::NL [static]

Provides the newline character(s) for the current platform: CR + LF on Windows systems, else LF.
Initialization in file mstring.cpp.

char* mstring::MString::_string [protected]

Pointer to the contained string; NULL if no string is assigned.

uint mstring::MString::stringLen [mutable, protected]

The buffered length of the contained string; if 0 it has to be calculated. This attribute can be changed from const members, too.

const MBoolStrings mstring::MString::BOOLLOCALES[] [static, protected]

Contains a list of definitions for the conversion of bool values to strings and vice versa in different locales. The relevant locale setting for this behaviour is LC_NUMERIC.
This list will be processed in order, which means a preceding entry with locale="de" overrides one with locale="de_CH" in a subsequent line. Therefore the default set of strings (locale="") has to be the last entry in this list.
Initialization in file mstring.cpp. Defaults to the english terms "True", "False", "Yes", "No".

See also:
Method setNumLocale(), method boolToString(bool, bool, const MBoolStrings*), method toBool(), static method boolean(bool, bool, const MBoolStrings*).

const MTimeStrings mstring::MString::TIMELOCALES[] [static, protected]

Contains a list of definitions for the conversion of time values to strings and vice versa in different locales. The relevant locale setting for this behaviour is LC_TIME.
This list will be processed in order, which means a preceding entry with locale="de" overrides one with locale="de_CH" in a subsequent line. Therefore the default set of strings (locale="") has to be the last entry in this list.
Initialization in file mstring.cpp. Defaults to the ISO 8601 date and time format "YYYY-MM-DD", "HH:MM:SS".

See also:
Method setTimeLocale(), method timeToString(time_t, TimeFormat, const MTimeStrings*), static method time(time_t, TimeFormat, const MTimeStrings*), method toTime().


Generated on Mon Jul 30 23:50:20 2007 for MString by  doxygen 1.5.2