Reference » Collections and iterators » MString

Elgrint::MString class

Declared in MString.h

Description

Linear ordered collection of MChar (Unicode-16) elements.
Read more...

MString

Base class: Collection

Initializers:

Name Description
MString(src) Conversion constructor. Implicitly converts a string literal (character array) into MString.
MString(src,precision) Conversion constructor. Implicitly converts a floating point value to MString.
MString(src) Conversion constructor. Implicitly converts an integer value to MString.
MString(src) Conversion constructor. Implicitly converts a single Unicode-16 character to MString.
MString(src,startPos,endPos) Sub-string copy constructor. Creates a new string from a portion of an existing string.
MString<T>(src,delimiter) Conversion constructor. Converts a generic MVector to MString (not implicitly).
MString(src) Conversion constructor. Implicitly converts a bool variable to MString.
MString(src) Conversion constructor. Implicitly converts a single ASCII character to MString.

Mutators:

Name Description
append(str,startPos,endPos) Appends a portion of str from startPos and up to but not including endPos to this string.
operator<<(src) Concatenates this string and T (similar to append).
popBack(count) Removes up to count characters from the end of the string.
setChar(pos,newChar) Changes the character at the specified position.

Revealers:

Name Description
findFirst(subStr,startPos) Returns the starting position of the first subStr in this string after startPos.
findFirstNotOf(chars,startPos) Returns the index of the first character in this string, that is not equal to any of the specified characters.
findFirstOf(chars,startPos) Returns the index of the first occurrence of any of the specified characters.
findLast(subStr,startPos) Returns the starting position of the last subStr in this string before startPos.
findLastNotOf(chars,startPos) Returns the index of the first character from the end of the string or from startPos (whichever is smaller), which is not equal to any of the specified characters.
findLastOf(chars,startPos) Returns the index of the first character from the end of the string or from startPos (whichever is smaller), which is equal to one of the specified characters.
getLast() Returns a copy of the last character in the string before the null-terminator.
operator!=(str) Returns true iff this and str strings are not identical to each other.
operator<(str) Returns true iff this string is less than str, according to lexicographic comparison.
operator<=(str) Returns true iff this string is less than or equal to str, according to lexicographic comparison.
operator==(str) Returns true iff this and str strings are identical to each other.
operator>(str) Returns true iff this string is greater than str, according to lexicographic comparison.
operator>=(str) Returns true iff this string is greater than or equal to str, according to lexicographic comparison.
operator[](pos) Returns a copy of the character at position pos.

Converters:

Name Description
convToLower() Returns a string which is a lowercase version of this.
convToUnicode16() Converts this string to a null-terminated Unicode-16 sequence (in O(1) time).
convToUnicode32() Converts this string to a null-terminated Unicode-32 sequence.
convToUnicode8() Converts this string to a null-terminated Unicode-8 sequence.
convToUpper() Returns a string which is an uppercase version of this.
operator>>(dest) Converts this string to a floating-point number, if possible.
operator>>(dest) Converts this string to an integer number, if possible.
operator>>(dest) Converts this string to a Unicode-16 character, if possible.
operator>>(dest) Converts this string to a Boolean value, if possible.
operator>>(dest) Converts this string to an ASCII character, if possible.
parseTo<T>(dest,delimChars,unionChar,mergeDelims) Parses the string into a set of T-type elements.

Global functions:

Name Description
ConvUnicodeToString(utf16) Converts a sequence of Unicode-16 elements to MString.
ConvUnicodeToString(utf32) Converts a sequence of Unicode-32 elements to MString.
ConvUnicodeToString(utf8) Converts a sequence of Unicode-8 elements to MString.
operator+<T>(str,x) Concatenates str and x, and returns the result. A convenient wrapper of operator<<(T).

Details

Contains a null-terminated string in the Unicode-16 format (each character is a 16-bit integer). The string can be searched and edited with great efficiency.

The most powerful ability of MString is the implicit conversion from various types (using a variety of constructors and operator<< overloads), and explicit conversion to various types (using operator>> overloads and parseTo function). These conversions are predefined for all built-in and atomic types, including both regular and wide-char C++ string literals, and for some other Elgrint types, and even their vectors (of MVector type). These conversions can be expanded to almost any other type by overloading operator<< and operator>> for that type. The operator<< is also used for concatenation, and so is the binary operator+, but both are usually (even if not always) based on the append function.

Even though MString works in Unicode-16, it supports conversions between all three standard Unicode formats, including Unicode-8 and Unicode-32. A string can also be converted to its uppercase or lowercase representation.

'MString' is based on MVector, so it allows character being inserted or removed only at the end of the string (right before the null-terminator).

'MString' doesn't have any iterators, because they are not necessary. The operator[] revealer is practically as efficient as an iterator (and safer too). Other than that, MString behaves like any other Collection.

'MString' is used extensively throughout the Elgrint interface for various purposes.

Remarks

Let us know

Please Contact us to report any errors on this page, or to suggest any improvements.

Miranor Home | About Miranor | About Elgrint | Create account | Login | Account settings | Contact Us | Privacy Policy | Site map

© Copyright 2014 by Miranor. All rights reserved. By using this site you agree to the Terms of Use.

Page last updated on August 10th, 2014.