Пример #1
0
DwString::DwString(char *aBuf, size_t aSize, size_t aStart, size_t aLen)
{
    assert(aBuf != 0);
    assert(aSize > 0);
    assert(aLen < aSize);
    assert(aStart < aSize - aLen);
    if(sEmptyRep == 0)
    {
        sEmptyBuffer[0] = 0;
        sEmptyRep = new DwStringRep(sEmptyBuffer, kEmptyBufferSize);
        assert(sEmptyRep != 0);
    }
    DBG_STMT(sEmptyRep->CheckInvariants())
    // Set valid values, in case an exception is thrown
    mRep = new_rep_reference(sEmptyRep);
    mStart = 0;
    mLength = 0;
    DwStringRep *rep = new DwStringRep(aBuf, aSize);
    assert(rep != 0);
    if(rep != 0)
    {
        mRep = rep;
        mStart = aStart;
        mLength = aLen;
    }
    else /* if (rep == 0) */
    {
        delete [] aBuf;
    }
}
Пример #2
0
DwString::DwString(const DwString &aStr, size_t aPos, size_t aLen)
{
    assert(aPos <= aStr.mLength);
    if(sEmptyRep == 0)
    {
        sEmptyBuffer[0] = 0;
        sEmptyRep = new DwStringRep(sEmptyBuffer, kEmptyBufferSize);
        assert(sEmptyRep != 0);
    }
    DBG_STMT(aStr.CheckInvariants())
    size_t pos = DW_MIN(aPos, aStr.mLength);
    size_t len = DW_MIN(aLen, aStr.mLength - pos);
    if(len > 0)
    {
        mRep = new_rep_reference(aStr.mRep);
        mStart = aStr.mStart + pos;
        mLength = len;
    }
    else /* if (len == 0) */
    {
        mRep = new_rep_reference(sEmptyRep);
        mStart = 0;
        mLength = 0;
    }
}
Пример #3
0
DwString::DwString()
{
    if (sEmptyRep == 0) {
        sEmptyBuffer[0] = 0;
        sEmptyRep = new DwStringRep(sEmptyBuffer, kEmptyBufferSize);
        assert(sEmptyRep != 0);
    }
    DBG_STMT(sEmptyRep->CheckInvariants())
    mRep = new_rep_reference(sEmptyRep);
    mStart = 0;
    mLength = 0;
}
Пример #4
0
DwString::DwString(size_t aLen, char aChar)
{
    assert(aLen != (size_t)-1);
    if (sEmptyRep == 0) {
        sEmptyBuffer[0] = 0;
        sEmptyRep = new DwStringRep(sEmptyBuffer, kEmptyBufferSize);
        assert(sEmptyRep != 0);
    }
    DBG_STMT(sEmptyRep->CheckInvariants())
    // Set valid values, in case an exception is thrown
    mRep = new_rep_reference(sEmptyRep);
    mStart = 0;
    mLength = 0;
    _replace(0, mLength, aLen, aChar);
}
Пример #5
0
DwString::DwString(FILE* aFile , size_t aLen)
{
    assert(aFile != 0);
    assert(aLen != (size_t)-1);
    if (sEmptyRep == 0) {
        sEmptyBuffer[0] = 0;
        sEmptyRep = new DwStringRep(sEmptyBuffer, kEmptyBufferSize);
        assert(sEmptyRep != 0);
    }
    DBG_STMT(sEmptyRep->CheckInvariants())
    // Set valid values, in case an exception is thrown
    mRep = new DwStringRep(aFile, aLen);
    mStart = 0;
    mLength = aLen;
}
Пример #6
0
DwString::DwString(const char* aCstr)
{
    if (sEmptyRep == 0) {
        sEmptyBuffer[0] = 0;
        sEmptyRep = new DwStringRep(sEmptyBuffer, kEmptyBufferSize);
        assert(sEmptyRep != 0);
    }
    DBG_STMT(sEmptyRep->CheckInvariants())
    // Set valid values, in case an exception is thrown
    mRep = new_rep_reference(sEmptyRep);
    mStart = 0;
    mLength = 0;
    if ( aCstr ) {
        size_t len = strlen(aCstr);
        _replace(0, mLength, aCstr, len);
    }
}