class CCL::MutableCString

Overview

Mutable C-String class, safe for ASCII-encoded text only! More…

#include <cstring.h>

class MutableCString:
    public CCL::CString,
    public Core::MutableCStringTraits
{
public:
    // construction

    MutableCString (CStringPtr text = nullptr);
    MutableCString (CStringRef string);
    MutableCString (const MutableCString& string);
    MutableCString (StringRef string, TextEncoding encoding = Text::kASCII);

    // methods

    MutableCString& empty ();
    MutableCString& append (StringRef string, TextEncoding encoding = Text::kASCII);
    MutableCString& truncate (int index);
    MutableCString& insert (int index, CStringPtr otherString);
    MutableCString& replace (int index, int count, CStringPtr otherString);
    MutableCString& replace (char oldChar, char newChar);
    MutableCString& toLowercase ();
    MutableCString& toUppercase ();
    MutableCString& trimWhitespace ();
    MutableCString& operator = (CStringPtr text);
    MutableCString& operator = (CStringRef string);
    MutableCString& operator = (const MutableCString& string);
    MutableCString& operator = (StringRef string);
    MutableCString& operator += (StringRef string);
};

Inherited Members

public:
    // fields

    CStringPtr text;
    ICString* theString;
    static const CString kEmpty;

    // methods

    CStringPtr str () const;
    bool isEmpty () const;
    int length () const;
    bool copyTo (char* charBuffer, int bufferSize) const;
    int index (CStringPtr other) const;
    bool contains (CStringPtr other) const;
    bool startsWith (CStringPtr other) const;
    bool endsWith (CStringPtr other) const;
    int index (char c) const;
    int index (uchar c) const;
    int lastIndex (char c) const;
    int lastIndex (uchar c) const;
    bool contains (char c) const;
    int compare (CStringPtr other, bool caseSensitive = true) const;
    bool getIntValue (int32& value) const;
    bool getIntValue (int64& value) const;
    int scanInt (int fallback = 0) const;
    int64 scanLargetInt (int64 fallback = 0) const;
    bool getHexValue (int64& value) const;
    bool getFloatValue (double& value) const;
    bool getFloatValue (float& value) const;
    float scanFloat (float fallback = 0) const;
    double scanDouble (double fallback = 0) const;
    unsigned int getHashCode () const;
    bool operator == (CStringPtr other) const;
    bool operator != (CStringPtr other) const;

    template  <class S>
    bool operator == (const CStringTraits <S>& other) const;

    template  <class S>
    bool operator != (const CStringTraits <S>& other) const;

    bool equalsUnsafe (CStringPtr other) const;
    char at (int index) const;
    char firstChar () const;
    char lastChar () const;
    char operator [] (int index) const;
    operator CStringPtr () const;
    static bool isAlpha (char c);
    static bool isAlphaNumeric (char c);
    static bool isWhitespace (char c);
    static bool isDigit (char c);
    static bool isASCII (char c);
    static bool isLowercase (char c);
    static bool isUppercase (char c);
    static char toLowercase (char c);
    static char toUppercase (char c);
    MutableCString subString (int index, int count = -1) const;
    MutableCString getBetween (CStringPtr prefix, CStringPtr suffix) const;
    bool getBetween (MutableCString& result, CStringPtr prefix, CStringPtr suffix) const;
    void toUnicode (String& string, TextEncoding encoding = Text::kASCII) const;
    CString& operator = (CStringPtr text);
    CString& operator = (CStringRef other);
    static CStringRef getLineEnd (TextLineFormat lineFormat = Text::kSystemLineFormat);
    T& init (CStringPtr string);
    T& append (CStringPtr string, int count = -1);
    T& append (char c);
    T& append (uchar uc);
    T& appendFormat (const char* format, ...);
    T& appendFormatArgs (const char* format, va_list marker);
    T& appendInteger (int32 value);
    T& appendInteger (int64 value);
    T& appendInteger (uint32 value);
    T& appendInteger (uint64 value);
    T& operator += (char c);
    T& operator += (uchar uc);
    T& operator += (CStringPtr text);

Detailed Documentation

Mutable C-String class, safe for ASCII-encoded text only!

Construction

MutableCString (CStringPtr text = nullptr)

Construct with C-String.

MutableCString (CStringRef string)

Construct with C-String.

MutableCString (const MutableCString& string)

Copy constructor.

MutableCString (StringRef string, TextEncoding encoding = Text::kASCII)

Construct with Unicode String.

Methods

MutableCString& empty ()

Empty string.

MutableCString& append (StringRef string, TextEncoding encoding = Text::kASCII)

Append Unicode String.

MutableCString& truncate (int index)

Truncate string at given position.

MutableCString& insert (int index, CStringPtr otherString)

Insert string at given position.

MutableCString& replace (int index, int count, CStringPtr otherString)

Replace range by other string.

MutableCString& replace (char oldChar, char newChar)

Replace all occurances of one character with another.

MutableCString& toLowercase ()

Change all alphabetical characters to lowercase.

MutableCString& toUppercase ()

Change all alphabetical characters to uppercase.

MutableCString& trimWhitespace ()

Remove all whitespace at beginning and end.

MutableCString& operator = (CStringPtr text)

Assign C-String.

MutableCString& operator = (CStringRef string)

Assign C-String.

MutableCString& operator = (const MutableCString& string)

Assign mutable C-String.

MutableCString& operator = (StringRef string)

Assign Unicode String.

MutableCString& operator += (StringRef string)

Append Unicode String.