INTEGRATION: CWS adc18 (1.12.22); FILE MERGED
2007/10/18 12:09:49 np 1.12.22.3: Remove warning about uninitialized base class in StreamStr copy ctor. 2007/09/20 12:51:41 np 1.12.22.2: #i81775# 2007/09/20 12:16:14 np 1.12.22.1: #i81775#
This commit is contained in:
parent
392e23b666
commit
d8b10abf59
1 changed files with 129 additions and 28 deletions
|
@ -4,9 +4,9 @@
|
|||
*
|
||||
* $RCSfile: streamstr.cxx,v $
|
||||
*
|
||||
* $Revision: 1.12 $
|
||||
* $Revision: 1.13 $
|
||||
*
|
||||
* last change: $Author: hr $ $Date: 2006-06-19 14:31:06 $
|
||||
* last change: $Author: hr $ $Date: 2007-11-02 17:46:49 $
|
||||
*
|
||||
* The Contents of this file are made available subject to
|
||||
* the terms of GNU Lesser General Public License Version 2.1.
|
||||
|
@ -43,13 +43,14 @@
|
|||
#include <cstdarg> // std::va_list and friends
|
||||
|
||||
#include <cosv/comfunc.hxx>
|
||||
#include <cosv/template/swelist.hxx>
|
||||
#include <cosv/tpl/swelist.hxx>
|
||||
|
||||
|
||||
|
||||
namespace csv
|
||||
{
|
||||
|
||||
|
||||
// Maximal sizes of resulting integers in text form:
|
||||
const uintt C_short_max_size = sizeof(short) * 3;
|
||||
const uintt C_int_max_size = sizeof(int) * 3;
|
||||
|
@ -63,7 +64,8 @@ StreamStr::Advance(size_type i_nAddedSize)
|
|||
|
||||
|
||||
StreamStr::StreamStr( size_type i_nCapacity )
|
||||
: nCapacity1( i_nCapacity + 1 ),
|
||||
: bostream(),
|
||||
nCapacity1( i_nCapacity + 1 ),
|
||||
dpData( new char [i_nCapacity + 1] ),
|
||||
pEnd(dpData),
|
||||
pCur(dpData),
|
||||
|
@ -74,7 +76,8 @@ StreamStr::StreamStr( size_type i_nCapacity )
|
|||
|
||||
StreamStr::StreamStr( const char * i_sInitStr,
|
||||
size_type i_nCapacity )
|
||||
: nCapacity1(0),
|
||||
: bostream(),
|
||||
nCapacity1(0),
|
||||
dpData(0),
|
||||
pEnd(0),
|
||||
pCur(0),
|
||||
|
@ -92,7 +95,8 @@ StreamStr::StreamStr( size_type i_nGuessedCapacity,
|
|||
const char * str1,
|
||||
const char * str2,
|
||||
... )
|
||||
: nCapacity1( i_nGuessedCapacity + 1 ),
|
||||
: bostream(),
|
||||
nCapacity1( i_nGuessedCapacity + 1 ),
|
||||
dpData( new char [i_nGuessedCapacity + 1] ),
|
||||
pEnd(dpData),
|
||||
pCur(dpData),
|
||||
|
@ -129,6 +133,25 @@ StreamStr::StreamStr( const self & i_rOther )
|
|||
strcpy( dpData, i_rOther.dpData ); // SAFE STRCPY (#100211# - checked)
|
||||
}
|
||||
|
||||
StreamStr::StreamStr(csv::bstream & i_source)
|
||||
: bostream(),
|
||||
nCapacity1(0),
|
||||
dpData(0),
|
||||
pEnd(0),
|
||||
pCur(0),
|
||||
eMode(str::overwrite)
|
||||
{
|
||||
i_source.seek(0, csv::end);
|
||||
nCapacity1 = static_cast<size_type>(i_source.position()) + 1;
|
||||
i_source.seek(0);
|
||||
|
||||
dpData = new char[nCapacity1];
|
||||
i_source.read(dpData, nCapacity1 - 1);
|
||||
pCur = dpData + nCapacity1 - 1;
|
||||
pEnd = pCur;
|
||||
*pCur = '\0';
|
||||
}
|
||||
|
||||
StreamStr::~StreamStr()
|
||||
{
|
||||
delete [] dpData;
|
||||
|
@ -339,6 +362,33 @@ StreamStr::resize( size_type i_nMinimumCapacity )
|
|||
Resize(i_nMinimumCapacity);
|
||||
}
|
||||
|
||||
void
|
||||
StreamStr::swap( StreamStr & io_swap )
|
||||
{
|
||||
size_type
|
||||
n = io_swap.nCapacity1;
|
||||
io_swap.nCapacity1 = nCapacity1;
|
||||
nCapacity1 = n;
|
||||
|
||||
char *
|
||||
p = io_swap.dpData;
|
||||
io_swap.dpData = dpData;
|
||||
dpData = p;
|
||||
|
||||
p = io_swap.pEnd;
|
||||
io_swap.pEnd = pEnd;
|
||||
pEnd = p;
|
||||
|
||||
p = io_swap.pCur;
|
||||
io_swap.pCur = pCur;
|
||||
pCur = p;
|
||||
|
||||
insert_mode
|
||||
m = io_swap.eMode;
|
||||
io_swap.eMode = eMode;
|
||||
eMode = m;
|
||||
}
|
||||
|
||||
StreamStr &
|
||||
StreamStr::seekp( seek_type i_nCount,
|
||||
seek_dir i_eDirection )
|
||||
|
@ -571,6 +621,17 @@ StreamStr::strip_frontback_whitespace()
|
|||
strip_back_whitespace();
|
||||
}
|
||||
|
||||
void
|
||||
StreamStr::remove( iterator i_begin,
|
||||
iterator i_end )
|
||||
{
|
||||
csv_assert(i_begin >= dpData AND i_begin <= pEnd);
|
||||
csv_assert(i_end >= dpData AND i_end <= pEnd);
|
||||
csv_assert(i_end >= i_begin);
|
||||
MoveData(i_end, pEnd, i_begin - i_end);
|
||||
pCur = pEnd;
|
||||
}
|
||||
|
||||
void
|
||||
StreamStr::replace( position_type i_nStart,
|
||||
size_type i_nSize,
|
||||
|
@ -600,10 +661,14 @@ StreamStr::replace( position_type i_nStart,
|
|||
*pEnd = '\0';
|
||||
}
|
||||
|
||||
if (i_aReplacement.nLength > 0)
|
||||
{
|
||||
memcpy( dpData + i_nStart, i_aReplacement.sStr, i_aReplacement.nLength );
|
||||
Advance(i_aReplacement.nLength);
|
||||
}
|
||||
|
||||
eMode = eOldMode;
|
||||
pCur = pEnd;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -738,6 +803,7 @@ class StreamStrPool
|
|||
StreamStrPool();
|
||||
~StreamStrPool();
|
||||
private:
|
||||
// Non-copyable
|
||||
StreamStrPool(StreamStrPool &); // not defined
|
||||
void operator =(StreamStrPool &); // not defined
|
||||
|
||||
|
@ -867,8 +933,8 @@ StreamStr::MoveData( char * i_pStart,
|
|||
}
|
||||
else if (i_nDiff < 0)
|
||||
{
|
||||
register const char * pSrc = i_pStart;
|
||||
register char * pDest = i_pStart + i_nDiff;
|
||||
const char * pSrc = i_pStart;
|
||||
char * pDest = i_pStart + i_nDiff;
|
||||
for ( ; pSrc != i_pEnd; ++pSrc, ++pDest )
|
||||
{
|
||||
*pDest = *pSrc;
|
||||
|
@ -876,7 +942,7 @@ StreamStr::MoveData( char * i_pStart,
|
|||
}
|
||||
}
|
||||
|
||||
// Dummy, needed for debug-versions of some compilers.
|
||||
// Does nothing, only the name of this function is needed.
|
||||
void
|
||||
c_str()
|
||||
{
|
||||
|
@ -884,5 +950,40 @@ c_str()
|
|||
}
|
||||
|
||||
|
||||
} // namespace csv
|
||||
|
||||
void
|
||||
Split( std::vector<String> & o_list,
|
||||
const char * i_text )
|
||||
{
|
||||
const char *
|
||||
pCurrentToken = 0;
|
||||
bool
|
||||
white = false;
|
||||
for (const char * p = i_text; *p != '\0'; ++p)
|
||||
{
|
||||
white = UINT8(*p) > 32;
|
||||
if (pCurrentToken != 0)
|
||||
{
|
||||
if (white)
|
||||
{
|
||||
o_list.push_back(String(pCurrentToken, p));
|
||||
pCurrentToken = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( NOT white)
|
||||
pCurrentToken = p;
|
||||
} // endif (bInToken) else
|
||||
} // end for
|
||||
|
||||
if (pCurrentToken != 0)
|
||||
{
|
||||
o_list.push_back(String(pCurrentToken));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace csv
|
||||
|
|
Loading…
Reference in a new issue