本文整理汇总了C++中TLex8::Peek方法的典型用法代码示例。如果您正苦于以下问题:C++ TLex8::Peek方法的具体用法?C++ TLex8::Peek怎么用?C++ TLex8::Peek使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TLex8
的用法示例。
在下文中一共展示了TLex8::Peek方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SkipSpacesUntilNextLineBreak
// ---------------------------------------------------------------------------
// SdpUtil::SkipSpacesUntilNextLineBreak
// Skips spaces until next line break, if the line break can be found.
// Examples: " \r\n" -> "\r\n", "abc def\r\n" -> "abc def\r\n"
// ---------------------------------------------------------------------------
//
TBool SdpUtil::SkipSpacesUntilNextLineBreak( TLex8& aLexer )
{
TBool found = EFalse;
if ( aLexer.Peek() == KSPChar )
{
TInt spaceCount = 0;
while ( aLexer.Peek() == KSPChar )
{
spaceCount++;
aLexer.Get();
}
if ( aLexer.Peek() != KCRChar && aLexer.Peek() != KLFChar )
{
for ( TInt i=0; i < spaceCount; i++ )
{
aLexer.UnGet();
}
}
else
{
found = ETrue;
}
}
return found;
}
示例2: SkipToNextLine
void CTestConfig::SkipToNextLine(TLex8& aInput) const
{
const TChar cr('\n');
while (!aInput.Eos() && aInput.Peek() != cr)
{
aInput.Inc();
}
}
示例3: ChopElementsFromLineL
// ---------------------------------------------------------------------------
// SdpUtil::ChopElementsFromLineL
// Chops all the elements that are divided by delimiter from the string
// ---------------------------------------------------------------------------
//
void SdpUtil::ChopElementsFromLineL(
RArray<TPtrC8>& aArray,
TLex8& aLexer,
TChar aDelimiter,
TInt aErrCode )
{
// Chop the elements to the array from lexer
TBool eofcFound = EFalse;
while (!eofcFound)
{
aLexer.Mark();
// Parse single token, leave other special characters
// to token except aDelimiter | '\r' | '\n' | '\0'
while ( aLexer.Peek() != aDelimiter &&
aLexer.Peek() != KCRChar &&
aLexer.Peek() != KLFChar &&
aLexer.Peek() != KEofChar )
{
aLexer.Inc();
}
if ( aLexer.MarkedToken().Length() > 0 )
{
aArray.AppendL( aLexer.MarkedToken() );
}
if ( aDelimiter == KSPChar &&
aLexer.Peek() == aDelimiter )
{
SkipSpacesUntilNextLineBreak( aLexer );
}
// Check if its end-of-line
if ( aLexer.Peek() == KCRChar )
{
aLexer.Inc();
}
if ( aLexer.Peek() == KLFChar )
{
aLexer.Inc();
if ( aLexer.Peek() != KEofChar )
{
User::Leave( aErrCode );
}
eofcFound = ETrue;
}
else if ( aLexer.Peek() == KEofChar )
{
// EoF character not tolerated at the middle of the string
User::Leave( aErrCode );
}
else
{
aLexer.Inc();
}
}
}
示例4: CleanupClosePushL
// -----------------------------------------------------------------------------
// SdpUtil::GetElementsFromLineL
// Gets all the elements from a single line
// -----------------------------------------------------------------------------
//
RArray<TPtrC8> SdpUtil::GetElementsFromLineL(
TLex8& aLexer,
TChar aDelimiter,
TInt aErrCode )
{
RArray<TPtrC8> lineArray;
CleanupClosePushL( lineArray );
// Header is special case, because it is joined _without_
// space character with the first attribute, so it must be
// parsed separately
aLexer.Mark();
// curChar must be != KEqualChar at first comparison
for ( TChar curChar( KSPChar ); curChar != KEqualChar; )
{
curChar = aLexer.Peek();
// Syntax check
if ( curChar == KEofChar || curChar == KLFChar ||
curChar == KCRChar )
{
User::Leave( aErrCode );
}
aLexer.Inc();
}
// Append header to array
User::LeaveIfError( lineArray.Append( aLexer.MarkedToken() ) );
// Whitespace MUST NOT be used after the "=" sign
if (aLexer.Peek() == KSPChar)
{
User::Leave( aErrCode );
}
// Get the other elements from the string to the array
ChopElementsFromLineL( lineArray, aLexer, aDelimiter, aErrCode );
CleanupStack::Pop(); // lineArray
return lineArray;
}
示例5: GetNextElement
TInt CTestConfig::GetNextElement(TLex8& aInput, TChar aDelimiter, TPtrC8& aOutput)
{
if (aInput.Eos())
return KErrNotFound;
//Get to the start of the descriptor
while (!aInput.Eos() && aInput.Peek() != aDelimiter)
aInput.Inc();
aOutput.Set(aInput.MarkedToken());
if (!aInput.Eos())
aInput.SkipAndMark(1);
return KErrNone;
}
示例6: IsIntegerValue
// -----------------------------------------------------------------------------
// CWPPushMessage::IsIntegerValue
// -----------------------------------------------------------------------------
//
TBool CWPPushMessage::IsIntegerValue( TLex8& aPointer ) const
{
// Integer values either are above KShortIntegerMask or
// their first byte is <=KMaxLongIntegerLength.
TBool result( EFalse );
if( !aPointer.Eos() )
{
TUint first( aPointer.Peek() );
if( first > KShortIntegerMask || first <= KMaxLongIntegerLength )
{
result = ETrue;
}
}
return result;
}
示例7: HandleConversionException
// -----------------------------------------------------------------------------
// CUpnpRangeHeaderParser::HandleConversionException
// Handles conversion exceptions
// -----------------------------------------------------------------------------
//
TBool CUpnpRangeHeaderParser::HandleConversionException( TLex8& aNumber, TInt& aRangePos,
TInt aError )
{
if( aError == KErrOverflow )
{
aRangePos = KMaxTInt;
while ( aNumber.Peek().IsDigit() )
{
aNumber.Inc();
}
}
else if ( aError != KErrNone )
{
return EFalse;
}
return ETrue;
}
示例8: GetTextString
// -----------------------------------------------------------------------------
// CWPPushMessage::GetTextString
// -----------------------------------------------------------------------------
//
TPtrC8 CWPPushMessage::GetTextString( TLex8& aPointer ) const
{
// Text-string can be quoted.
if( aPointer.Peek() == KQuotedTextStringStart )
{
aPointer.Inc();
}
aPointer.Mark();
while( aPointer.Get() != EKeyNull )
{
// Nothing
}
// We don't want to have NULL in the resulting descriptor, so
// back that out.
aPointer.UnGet();
TPtrC8 result( aPointer.MarkedToken() );
aPointer.Inc();
return result;
}
示例9: GetVersionValue
// -----------------------------------------------------------------------------
// CWPPushMessage::GetVersionValue
// -----------------------------------------------------------------------------
//
TUint CWPPushMessage::GetVersionValue( TLex8& aPointer ) const
{
// Version-value is a short integer or text. Handle that.
TUint result( 0 );
if( !aPointer.Eos() )
{
TUint first( aPointer.Peek() );
if( first > KShortIntegerMask )
{
result = GetShortInteger( aPointer );
}
else
{
GetTextString( aPointer );
}
}
return result;
}
示例10: GetTextValue
// -----------------------------------------------------------------------------
// CWPPushMessage::GetTextValue
// -----------------------------------------------------------------------------
//
TPtrC8 CWPPushMessage::GetTextValue( TLex8& aPointer ) const
{
// Text-value can be quoted, so skip that first.
if( aPointer.Peek() == KQuotedStringStart )
{
aPointer.Inc();
}
aPointer.Mark();
// It is null-terminated
while( aPointer.Get() != EKeyNull )
{
// Do nothing
}
// We don't want to have NULL in the resulting descriptor, so
// back that out.
TPtrC8 result( aPointer.MarkedToken() );
result.Set( result.Left( Max( 0, result.Length()-1 ) ) );
return result;
}
示例11: GetIntegerValue
// -----------------------------------------------------------------------------
// CWPPushMessage::GetIntegerValue
// -----------------------------------------------------------------------------
//
TInt64 CWPPushMessage::GetIntegerValue( TLex8& aPointer ) const
{
// Integer value can be a short integer or a long integer.
// Short integer is always >KShortIntegerMask.
TInt64 result( 0 );
if( !aPointer.Eos() )
{
TUint first( aPointer.Peek() );
if( first > KShortIntegerMask )
{
result = GetShortInteger( aPointer );
}
else
{
result = GetLongInteger( aPointer );
}
}
return result;
}
示例12: GetFieldName
// -----------------------------------------------------------------------------
// CWPPushMessage::GetFieldName
// -----------------------------------------------------------------------------
//
TUint CWPPushMessage::GetFieldName( TLex8& aPointer ) const
{
// Field name can be a short integer or text.
TUint result( 0 );
if( !aPointer.Eos() )
{
TUint first( aPointer.Peek() );
if( first > KShortIntegerMask )
{
result = GetShortInteger( aPointer );
}
else
{
// Only well-known fields are read
GetTokenText( aPointer );
}
}
return result;
}
示例13: GetConstrainedEncoding
// -----------------------------------------------------------------------------
// CWPPushMessage::GetConstrainedEncoding
// -----------------------------------------------------------------------------
//
TUint CWPPushMessage::GetConstrainedEncoding( TLex8& aPointer ) const
{
// Constrained encoding can be extension media or short integer
TUint result( 0 );
if( !aPointer.Eos() )
{
TUint first( aPointer.Peek() );
if( first > KShortIntegerMask )
{
result = GetShortInteger( aPointer );
}
else
{
// Just skip the text version
GetTokenText( aPointer );
}
}
return result;
}
示例14: ReadConfigFileL
// Function to read a line from a buffer
GLDEF_C void ReadConfigFileL(RFile& aConfigFile, TListeners& aListeners, RSocketServ& aSocketServ, RConnection& aConnect)
{
TInt fileLen;
User::LeaveIfError(aConfigFile.Size(fileLen));
HBufC8* readBuffer = HBufC8::NewL(fileLen);
CleanupStack::PushL(readBuffer);
TPtr8 buff = readBuffer->Des();
// Read File
// Here, we read the whole file as we know it's small
TRequestStatus status;
aConfigFile.Read(buff, status);
User::WaitForRequest(status);
if(status.Int() != KErrNone && status.Int() != KErrEof)
{
User::LeaveIfError(status.Int());
}
HBufC8* tempBuffer = HBufC8::NewL(KLineSize);
CleanupStack::PushL(tempBuffer);
TPtr8 lineBuff = tempBuffer->Des();
TLex8 lex;
lex.Assign(buff);
/* Parse whole stream in to split it in lines
We discard commented line with #
*/
TBool error = EFalse;
while(!lex.Eos() && !error)
{
TBool comment = EFalse;
if(lex.Peek() == '#')
{
// We've got a comment
comment = ETrue;
}
TInt nbCharRead = 0; // To count number of character per line. Used to avoid a buffer overflow
while(!error && !lex.Eos() && lex.Peek() != '\r' && lex.Peek() != '\n')
{
// We look if we are allowed to append character. Otherwise we stop loopping.
if(nbCharRead < KLineSize)
{
lineBuff.Append(lex.Get());
nbCharRead++;
}
else
{
error = ETrue;
}
}
if(!comment)
{
// We create a new listener
TInt nbListeners = aListeners.Count();
if(nbListeners < KNbListeners)
{
aListeners.Append(CListener::NewL(aSocketServ, aConnect, CListenerOptions::NewL(lineBuff)));
aListeners[nbListeners]->AcceptL();
}
}
lineBuff.Zero();
if(lex.Peek() == '\r')
{
lex.Get(); // Get rid of \r
}
lex.Get(); // Get rid of \n
}
// Delete buffers
CleanupStack::PopAndDestroy(tempBuffer);
CleanupStack::PopAndDestroy(readBuffer);
if(error)
{
// We have a bad line in our configuration file so we delete all listeners
aListeners.ResetAndDestroy();
}
}