aboutsummaryrefslogtreecommitdiff
path: root/src/fbasicstring.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/fbasicstring.h')
-rw-r--r--src/fbasicstring.h98
1 files changed, 97 insertions, 1 deletions
diff --git a/src/fbasicstring.h b/src/fbasicstring.h
index a532d69..853625c 100644
--- a/src/fbasicstring.h
+++ b/src/fbasicstring.h
@@ -947,7 +947,7 @@ namespace Bu
947 return pFirst->pData; 947 return pFirst->pData;
948 } 948 }
949 949
950 MyType getSubStr( long iStart, long iSize=-1 ) const 950 MyType getSubStrIdx( long iStart, long iSize=-1 ) const
951 { 951 {
952 if( iStart < 0 ) 952 if( iStart < 0 )
953 iStart = 0; 953 iStart = 0;
@@ -965,6 +965,50 @@ namespace Bu
965 return ret; 965 return ret;
966 } 966 }
967 967
968 MyType getSubStr( const_iterator iBegin,
969 const_iterator iEnd=typename MyType::const_iterator() ) const
970 {
971 if( !iBegin.isValid() )
972 return MyType();
973 if( iBegin.pChunk == iEnd.pChunk )
974 {
975 return MyType( iBegin.pChunk->pData+iBegin.iPos,
976 iEnd.iPos-iBegin.iPos );
977 }
978 else if( !iEnd.isValid() )
979 {
980 MyType ret;
981 ret.append(
982 iBegin.pChunk->pData+iBegin.iPos,
983 iBegin.pChunk->nLength-iBegin.iPos
984 );
985 for( Chunk *pCur = iBegin.pChunk->pNext;
986 pCur; pCur = pCur->pNext )
987 {
988 ret.append( pCur->pData, pCur->nLength );
989 }
990 return ret;
991 }
992 else
993 {
994 MyType ret;
995 ret.append(
996 iBegin.pChunk->pData+iBegin.iPos,
997 iBegin.pChunk->nLength-iBegin.iPos
998 );
999 for( Chunk *pCur = iBegin.pChunk->pNext;
1000 pCur != iEnd.pChunk; pCur = pCur->pNext )
1001 {
1002 ret.append( pCur->pData, pCur->nLength );
1003 }
1004 ret.append(
1005 iEnd.pChunk->pData,
1006 iEnd.iPos
1007 );
1008 return ret;
1009 }
1010 }
1011
968 /** 1012 /**
969 * (std::string compatability) Get a pointer to the string array. 1013 * (std::string compatability) Get a pointer to the string array.
970 *@returns (chr *) The string data. 1014 *@returns (chr *) The string data.
@@ -1401,6 +1445,7 @@ namespace Bu
1401 const_iterator find( const chr cChar, 1445 const_iterator find( const chr cChar,
1402 const_iterator iStart=typename MyType::const_iterator() ) const 1446 const_iterator iStart=typename MyType::const_iterator() ) const
1403 { 1447 {
1448 if( !iStart ) iStart = begin();
1404 for( ; iStart; iStart++ ) 1449 for( ; iStart; iStart++ )
1405 { 1450 {
1406 if( cChar == *iStart ) 1451 if( cChar == *iStart )
@@ -1412,6 +1457,7 @@ namespace Bu
1412 const_iterator find( const chr *sText, int nLen, 1457 const_iterator find( const chr *sText, int nLen,
1413 const_iterator iStart=typename MyType::const_iterator() ) const 1458 const_iterator iStart=typename MyType::const_iterator() ) const
1414 { 1459 {
1460 if( !iStart ) iStart = begin();
1415 for( ; iStart; iStart++ ) 1461 for( ; iStart; iStart++ )
1416 { 1462 {
1417 if( iStart.compare( sText, nLen ) ) 1463 if( iStart.compare( sText, nLen ) )
@@ -1423,6 +1469,7 @@ namespace Bu
1423 const_iterator find( const MyType &rStr, 1469 const_iterator find( const MyType &rStr,
1424 const_iterator iStart=typename MyType::const_iterator() ) const 1470 const_iterator iStart=typename MyType::const_iterator() ) const
1425 { 1471 {
1472 if( !iStart ) iStart = begin();
1426 for( ; iStart; iStart++ ) 1473 for( ; iStart; iStart++ )
1427 { 1474 {
1428 if( iStart.compare( rStr ) ) 1475 if( iStart.compare( rStr ) )
@@ -1434,6 +1481,7 @@ namespace Bu
1434 const_iterator find( const MyType &rStr, int nLen, 1481 const_iterator find( const MyType &rStr, int nLen,
1435 const_iterator iStart=typename MyType::const_iterator() ) const 1482 const_iterator iStart=typename MyType::const_iterator() ) const
1436 { 1483 {
1484 if( !iStart ) iStart = begin();
1437 for( ; iStart; iStart++ ) 1485 for( ; iStart; iStart++ )
1438 { 1486 {
1439 if( iStart.compare( rStr, nLen ) ) 1487 if( iStart.compare( rStr, nLen ) )
@@ -1442,6 +1490,54 @@ namespace Bu
1442 return end(); 1490 return end();
1443 } 1491 }
1444 1492
1493 iterator find( const chr cChar,
1494 const_iterator iStart=typename MyType::const_iterator() )
1495 {
1496 if( !iStart ) iStart = begin();
1497 for( ; iStart; iStart++ )
1498 {
1499 if( cChar == *iStart )
1500 return iterator( iStart.pChunk, iStart.iPos );
1501 }
1502 return end();
1503 }
1504
1505 iterator find( const chr *sText, int nLen,
1506 const_iterator iStart=typename MyType::const_iterator() )
1507 {
1508 if( !iStart ) iStart = begin();
1509 for( ; iStart; iStart++ )
1510 {
1511 if( iStart.compare( sText, nLen ) )
1512 return iterator( iStart.pChunk, iStart.iPos );
1513 }
1514 return end();
1515 }
1516
1517 iterator find( const MyType &rStr,
1518 const_iterator iStart=typename MyType::const_iterator() )
1519 {
1520 if( !iStart ) iStart = begin();
1521 for( ; iStart; iStart++ )
1522 {
1523 if( iStart.compare( rStr ) )
1524 return iterator( iStart.pChunk, iStart.iPos );
1525 }
1526 return end();
1527 }
1528
1529 iterator find( const MyType &rStr, int nLen,
1530 const_iterator iStart=typename MyType::const_iterator() )
1531 {
1532 if( !iStart ) iStart = begin();
1533 for( ; iStart; iStart++ )
1534 {
1535 if( iStart.compare( rStr, nLen ) )
1536 return iterator( iStart.pChunk, iStart.iPos );
1537 }
1538 return end();
1539 }
1540
1445 /** 1541 /**
1446 * Find the index of the first occurrance of cChar 1542 * Find the index of the first occurrance of cChar
1447 *@param sText (const chr *) The string to search for. 1543 *@param sText (const chr *) The string to search for.