----------------------------------------------------------------------------- This version of PeekStringLength converts \" to \\ and " to \, etc. It also reads a " at the beginning and end of the string -----------------------------------------------------------------------------
| 521 | // It also reads a " at the beginning and end of the string |
| 522 | //----------------------------------------------------------------------------- |
| 523 | int CUtlBuffer::PeekDelimitedStringLength( CUtlCharConversion *pConv, bool bActualSize ) |
| 524 | { |
| 525 | if ( !IsText() || !pConv ) |
| 526 | return PeekStringLength(); |
| 527 | |
| 528 | // Eat preceding whitespace |
| 529 | int nOffset = 0; |
| 530 | if ( IsText() ) |
| 531 | { |
| 532 | nOffset = PeekWhiteSpace( nOffset ); |
| 533 | } |
| 534 | |
| 535 | if ( !PeekStringMatch( nOffset, pConv->GetDelimiter(), pConv->GetDelimiterLength() ) ) |
| 536 | return 0; |
| 537 | |
| 538 | // Try to read ending ", but don't accept \" |
| 539 | int nActualStart = nOffset; |
| 540 | nOffset += pConv->GetDelimiterLength(); |
| 541 | int nLen = 1; // Starts at 1 for the '\0' termination |
| 542 | |
| 543 | do |
| 544 | { |
| 545 | if ( PeekStringMatch( nOffset, pConv->GetDelimiter(), pConv->GetDelimiterLength() ) ) |
| 546 | break; |
| 547 | |
| 548 | if ( !CheckPeekGet( nOffset, 1 ) ) |
| 549 | break; |
| 550 | |
| 551 | char c = *(const char*)PeekGet( nOffset ); |
| 552 | ++nLen; |
| 553 | ++nOffset; |
| 554 | if ( c == pConv->GetEscapeChar() ) |
| 555 | { |
| 556 | int nLength = pConv->MaxConversionLength(); |
| 557 | if ( !CheckArbitraryPeekGet( nOffset, nLength ) ) |
| 558 | break; |
| 559 | |
| 560 | pConv->FindConversion( (const char*)PeekGet(nOffset), &nLength ); |
| 561 | nOffset += nLength; |
| 562 | } |
| 563 | } while (true); |
| 564 | |
| 565 | return bActualSize ? nLen : nOffset - nActualStart + pConv->GetDelimiterLength() + 1; |
| 566 | } |
| 567 | |
| 568 | |
| 569 | //----------------------------------------------------------------------------- |
nothing calls this directly
no test coverage detected