コード例 #1
0
ファイル: dwstring.cpp プロジェクト: serghei/kde3-kdepim
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.cpp プロジェクト: serghei/kde3-kdepim
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);
    }
}