template class Core::CStringBuffer

Overview

Fixed-size C-String buffer class, safe for ASCII-encoded text only! More…

#include <corestringbuffer.h>

template <int maxSize>
class CStringBuffer:
    public Core::CStringTraits,
    public Core::MutableCStringTraits,
    public Core::CStringClassifier
{
public:
    // construction

    CStringBuffer(CStringPtr text = nullptr);

    // methods

    CStringBuffer& empty();
    CStringBuffer& truncate(int index);
    CStringBuffer& insert(int index, CStringPtr otherString);
    CStringBuffer& remove(int index, int count);
    CStringBuffer& replace(int index, int count, CStringPtr otherString);
    CStringBuffer& replace(char oldChar, char newChar);
    void subString(CStringBuffer& result, int index, int count = -1) const;
    CStringBuffer& trimWhitespace();
    CStringBuffer<maxSize>& toLowercase();
    CStringBuffer<maxSize>& toUppercase();
    CStringBuffer& operator = (CStringPtr text);
    CStringBuffer& assignInteger(int value);
    char* getBuffer();
    int getSize() const;
    static char toLowercase(char c);
    static char toUppercase(char c);
};

// direct descendants

class FileName;
class RegTypeString;

Inherited Members

public:
    // 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;
    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);
    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);

Detailed Documentation

Fixed-size C-String buffer class, safe for ASCII-encoded text only!

Methods

CStringBuffer& empty()

Empty string.

CStringBuffer& truncate(int index)

Truncate string at given position.

CStringBuffer& insert(int index, CStringPtr otherString)

Insert string at given position.

CStringBuffer& remove(int index, int count)

Remove characters at given position.

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

Replace range by other string.

CStringBuffer& replace(char oldChar, char newChar)

Replace all occurrences of one character with another.

void subString(CStringBuffer& result, int index, int count = -1) const

Create substring.

CStringBuffer& trimWhitespace()

Remove leading/trailing whitespace, but not in between any other characters.

CStringBuffer<maxSize>& toLowercase()

convert to lower case string.

CStringBuffer<maxSize>& toUppercase()

convert to upper case string.

CStringBuffer& operator = (CStringPtr text)

Assign C-String.

CStringBuffer& assignInteger(int value)

Assign integer value (replaces previous content).

char* getBuffer()

Get buffer pointer.

int getSize() const

Get buffer size.

static char toLowercase(char c)

Convert to lowercase character.

static char toUppercase(char c)

Convert to uppercase character.