- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
CStringUtf8::iterator& CStringUtf8::iterator::operator++()
{
m_ptr += CCharUtf8Ref::s_bytesForUTF8Sequence[*m_ptr];
return *this;
}
CStringUtf8 CStringUtf8::subString( size_t startChar, size_t count ) const
{
iterator start = this->begin();
while( start!=this->end() && startChar>0 )
{
start++;
startChar--;
}
iterator afterLast = start;
while( afterLast!=this->end() && count!=0 )
{
afterLast++;
count--;
}
return CStringUtf8( start.c_ptr(), afterLast.c_ptr() );
}
CStringUtf8::iterator CStringUtf8::findSubString( CStringUtf8 const& sample, CStringUtf8::iterator startFrom ) const
{
CStringUtf8::iterator pos = startFrom;
CStringUtf8::iterator foundPos = pos;
CStringUtf8::iterator samplePos = sample.begin();
for( ;; )
{
if( samplePos==sample.end() )
return foundPos;
if( pos==this->end() )
return this->end();
if( *samplePos == *pos )
{
if( samplePos==sample.begin() )
foundPos = pos;
samplePos++;
pos++;
}
else
{
if( samplePos==sample.begin() )
pos++;
samplePos = sample.begin();
}
}
}
std::vector<CStringUtf8> CStringUtf8::componentsSeparatedByString( CStringUtf8 const& separator ) const
{
std::vector<CStringUtf8> comps;
size_t sepLen = std::distance( separator.begin(), separator.end() );
size_t startPos = 0;
CStringUtf8::iterator itStart = begin();
if( sepLen > 0 )
{
CStringUtf8::iterator itEnd;
while( ( itEnd = findSubString( separator, itStart ) ) != end() )
{
size_t cnt = std::distance( itStart, itEnd );
CStringUtf8 str = subString( startPos, cnt );
comps.push_back( str );
itStart = itEnd;
std::advance( itStart, sepLen );
startPos += cnt + sepLen;
}
}
size_t cnt = std::distance( itStart, end() );
if( cnt > 0 )
{
CStringUtf8 str = subString( startPos, cnt );
comps.push_back( str );
}
return comps;
}