MCPcopy Create free account
hub / github.com/ValveSoftware/GameNetworkingSockets / GetDelimitedString

Method GetDelimitedString

src/tier1/utlbuffer.cpp:742–796  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

740}
741
742void CUtlBuffer::GetDelimitedString( CUtlCharConversion *pConv, char *pString, int nMaxChars )
743{
744 if ( !IsText() || !pConv )
745 {
746 GetString( pString, nMaxChars );
747 return;
748 }
749
750 if (!IsValid())
751 {
752 *pString = 0;
753 return;
754 }
755
756 if ( nMaxChars == 0 )
757 {
758 nMaxChars = INT_MAX;
759 }
760
761 // this will fire if, for example, you're trying to use a static utlcharconversion
762 // from a static constructor which runs before the utlcharconversion is constructed
763 Assert( pConv && pConv->GetDelimiterLength() > 0 );
764
765
766 EatWhiteSpace();
767 if ( !PeekStringMatch( 0, pConv->GetDelimiter(), pConv->GetDelimiterLength() ) )
768 return;
769
770 // Pull off the starting delimiter
771 SeekGet( SEEK_CURRENT, pConv->GetDelimiterLength() );
772
773 int nRead = 0;
774 while ( IsValid() )
775 {
776 if ( PeekStringMatch( 0, pConv->GetDelimiter(), pConv->GetDelimiterLength() ) )
777 {
778 SeekGet( SEEK_CURRENT, pConv->GetDelimiterLength() );
779 break;
780 }
781
782 char c = GetDelimitedCharInternal( pConv );
783
784 if ( nRead < nMaxChars )
785 {
786 pString[nRead] = c;
787 ++nRead;
788 }
789 }
790
791 if ( nRead >= nMaxChars )
792 {
793 nRead = nMaxChars - 1;
794 }
795 pString[nRead] = '\0';
796}
797
798
799//-----------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 2

GetDelimiterLengthMethod · 0.80
GetDelimiterMethod · 0.80

Tested by

no test coverage detected