本文整理汇总了C++中TChar::IsSpace方法的典型用法代码示例。如果您正苦于以下问题:C++ TChar::IsSpace方法的具体用法?C++ TChar::IsSpace怎么用?C++ TChar::IsSpace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TChar
的用法示例。
在下文中一共展示了TChar::IsSpace方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Eat
TBool TfrLex::Eat( TLex& aLex, const TChar aChar )
{
TLexMark unget;
if ( aChar.IsSpace() )
{
// A space character requires its own logic = go over
// the other space characters - x gets the next char.
TChar x;
aLex.Mark(unget);
while ( x = aLex.Get(), x.IsSpace() && x != aChar )
{};
if ( x == aChar )
return ETrue;
}
else
{
// For other, non-space, characters: skip spaces and
// get the next character x.
aLex.SkipSpace();
aLex.Mark(unget);
if ( aLex.Get() == aChar )
return ETrue;
}
// The character wasn't there, unget to the start point.
aLex.UnGetToMark(unget);
return EFalse;
}
示例2: while
// ---------------------------------------------------------------------------------
// CUpnpTmFilteredAppList::RemoveWhiteSpace
// Method is used to remove leading and trailing whitespaces from the descriptor's data
// @param aData Descriptor's data from which whitespaces have to be removed
// @return Returns the descriptor having no white spaces
// ---------------------------------------------------------------------------------
//
const TDesC8& CUpnpTmFilteredAppList::RemoveWhiteSpace( TPtrC8& aData )
{
OstTraceFunctionEntry0( CUPNPTMFILTEREDAPPLIST_REMOVEWHITESPACE_ENTRY );
// Removes the leading white spaces
TInt length = aData.Length();
TInt i = 0;
TBool done = EFalse;
while( !done && i < length )
{
TChar current = aData[i];
done = !current.IsSpace();
if( !done )
++i;
}
aData.Set(aData.Mid(i)); /* aData now does not have any white space character
ahead of its actual data */
// Removes the trailing white spaces
length = aData.Length();
i = 0;
done = EFalse;
while( !done && i < length )
{
TChar current = aData[(length-1) - i];
done = !current.IsSpace();
if( !done )
++i;
}
aData.Set(aData.Left(aData.Length() - i)); /* aData now does not have any white space character
following the actual data */
OstTraceFunctionExit0( CUPNPTMFILTEREDAPPLIST_REMOVEWHITESPACE_EXIT );
return aData;
}
示例3: IsAtStartOfNewLine
TBool CTestConfig::IsAtStartOfNewLine(const TDesC8& aSource, const TLex8& aLex, TBool aIgnoreSpaces) const
{
TInt offset(aLex.MarkedOffset());
__ASSERT_ALWAYS(offset != 0, User::Invariant());
TChar ch = NULL;
if (aIgnoreSpaces)
{
while (offset--)
{
ch = aSource[offset];
if (ch == KScriptLFChar || ch == KScriptCRChar || !ch.IsSpace())
break;
}
}
else
ch = aSource[offset-1];
TBool ret(EFalse);
if (offset <= 0)
ret = ETrue;
else
ret = (ch == KScriptLFChar || ch == KScriptCRChar);
return ret;
}
示例4: ParseBufferLC
void CATBase::ParseBufferLC()
//
// Parses buffer
//
/**
* This function is currently not used by the Etel regression test harness.
*/ {
LOGTEXT(_S8("CATBase Parse the Buffer List"));
iBuffer.Set(iIo->GetRxBufferLC(iBufferMarker));
TInt pos=iBuffer.FindF(KOKString);
if(pos==KErrNotFound)
{
LOGTEXT(_S8("CATBase Error - Cannot find OK'"));
User::Leave(pos);
}
// Place everything before the OK into buffer
iBuffer.Set(iBuffer.Left(pos));
TLex8 yyLex(iBuffer);
TChar peek;
// Look for '=' sign and move seeker cursor to the right of it if it exists
pos=iBuffer.Find(_L8("="));
if (pos!=KErrNotFound)
{
yyLex.Inc(pos+1);
}
// Move cursor past any spaces or open brackets
yyLex.SkipSpace();
peek=yyLex.Peek();
if ((TUint)peek=='(' || (TUint)peek=='[' || (TUint)peek=='{')
yyLex.Inc();
yyLex.SkipSpace();
peek = yyLex.Peek();
do
{
// Search for the next character that is not a comma, and mark it. Keep looking at
// subsequent characters until it is a space,comma,closing bracket or end of string.
// Store the string (between marked character and current character) as an item in
// an array of CATParamListEntry object pointers.
if (peek!=',')
{
yyLex.Mark();
do
{
yyLex.Inc();
peek=yyLex.Peek();
}
while (peek!=',' && !peek.IsSpace() && peek!=')'&& peek!=']'&& peek!='}' && !yyLex.Eos());
CATParamListEntry* aParamListEntry = new (ELeave) CATParamListEntry(yyLex.MarkedToken());
iRxResults.AddLast(*aParamListEntry);
}
// Move cursor to the next non-space character, and end the loop if it is a closing
// bracket or the end of the buffer.
yyLex.Inc();
yyLex.SkipSpace();
peek = yyLex.Peek();
}
while (!yyLex.Eos() && peek!=')'&& peek!=']'&& peek!='}');
}
示例5: GetL
TPtrC TfrLex::GetL( TLex& aLex, const TChar aChar )
{
// Skip spaces and mark the token's start point.
aLex.SkipSpace();
TLexMark mark;
aLex.Mark(mark);
if (aLex.Peek() == '"' )
{
// Skip the " and do find next " followed by eos, space or aChar.
aLex.Inc();
TChar x;
while ( x = aLex.Get(), !x.Eos() )
{
if ( x == '"' )
{
// Found a " character - but is it the end of the token?
x = aLex.Peek(); // peek the next character
if ( x.Eos() || x.IsSpace() || x == aChar )
// End of token: return token.
return aLex.MarkedToken(mark);
}
}
// Unget and L E A V E because did not find the end " of token.
aLex.UnGetToMark(mark);
User::Leave(KErrArgument);
return aLex.MarkedToken(mark); // never reached (l e a v e).
}
else
{
// Is not a "*" token: find eos or the next space or the aChar
// and return the token.
TChar x;
while ( x = aLex.Peek(), !x.Eos() && !x.IsSpace() && x != aChar )
aLex.Inc();
return aLex.MarkedToken(mark);
}
}
示例6: GetSetting
TInt CIniData::GetSetting(const TDesC &aValue, TPtrC &aSetting)
/**
Retrieves the value for a particular setting within a block
@param aValue The setting to be retrieved
@param aSetting On return it contains the value for the setting
@return KErrNone if successful or KErrArgument for fields simply left blank. If the global BlockState is unknown returns KErrNotReady.
*/
{
TInt valid(KErrNotReady);
if (BlockState != E_UNKNOWN)
{
// first check for CONDITION field
// if we are NOT looking for this field, we need to trim off any condition
// field from the block because there may be a setting within it we
// want to ignore during our search for this field
TPtrC pBlock(block);
TInt tempEnd = blockEnd;
TPtrC Condition = CONDITION;
if (aValue.Compare(Condition) != 0)
{
TPtr varCondToken = iToken->Des();
_LIT(varCondTokenString, "%S=");
varCondToken.Format(varCondTokenString, &Condition);
TInt CondPos = pBlock.FindF(varCondToken);
if (CondPos != KErrNotFound)
{
tempEnd = CondPos;
}
}
// now look for the actual value
TBool searchAgain = EFalse;
_LIT(varTokenString, "%S=");
TPtr varToken = iToken->Des();
varToken.Format(varTokenString, &aValue);
TInt pos = KErrNotFound;
do
{
searchAgain = EFalse;
pos = pBlock.FindF(varToken);
if (pos != KErrNotFound && pos < tempEnd)
{
// check that this is a complete match, not a substring
// match against another similar field, e.g. LoginScript
// must only match against "LoginScript" not "UseLoginScript"
if (pos > 0)
{
// Previous character must be white space
const TChar previousCharacter = pBlock[pos - 1];
if (previousCharacter.IsSpace())
{
// make sure we haven't overrun our block
TInt length = varToken.Length();
if (pos + length < tempEnd)
{
TLex lex(pBlock.Mid(pos + length));
// if enclosed by quotes, extract the text within
if (lex.Peek() == '"')
{
lex.SkipAndMark(1); // start of data
// stop at end of quote or line
while(lex.Peek() != '"' && lex.Peek() != 10 && lex.Peek() != 13)
{
lex.Inc();
}
}
else if(lex.Peek() == 10 || lex.Peek() == 13) // skip empty or blank field value
{
return KErrArgument;
}
else // skip any unwanted spaces or tabs in a field value
{
TBool fieldValFound=EFalse;
while(lex.Peek() != 10 && lex.Peek() != 13)
{
if(!fieldValFound)
{
while(lex.Peek() == 9 || lex.Peek() == 32) // skip any space or a tab
{
lex.SkipAndMark(1);
}
if(lex.Peek() == 10 || lex.Peek() == 13) // field value simply filled with space or tab
{
return KErrArgument;
}
}
fieldValFound=ETrue; // start of real data
lex.Inc();
}
}
aSetting.Set(lex.MarkedToken().Ptr(),lex.MarkedToken().Length());
valid = KErrNone;
}
}
//.........这里部分代码省略.........
示例7: NextToken
// ----------------------------------------------------------------------------
// TTunnelParser::NextToken
// Returns the next token type in the input stream. iToken gets the value of
// the (string) token.
// ----------------------------------------------------------------------------
//
TTunnelParser::TTokenType TTunnelParser::NextToken ()
{
TChar ch;
TTokenType val;
SkipSpaceAndMark ();
if (Eos ())
val = ETokenTypeEof;
else
{
ch = Get ();
switch (ch)
{
case '{':
val = ETokenTypeBraceLeft;
break;
case '}':
val = ETokenTypeBraceRight;
break;
case '(':
val = ETokenTypeParLeft;
break;
case ')':
val = ETokenTypeParRight;
break;
case '=':
val = ETokenTypeEqual;
break;
case ',':
val = ETokenTypeComma;
break;
case '#':
val = ETokenTypeComment;
while (!Eos())
{
ch = Get();
if (ch == '\n' || ch == '\r')
break;
}
break;
default:
// Integers, ip addresses, etc. are mapped to strings.
val = ETokenTypeString;
while (!Eos ())
{
ch = Peek ();
if (ch == '{' || ch == '}' ||
ch == '(' || ch == ')' ||
ch == '=' || ch == '#' ||
ch == ',' || ch.IsSpace ())
break;
Inc ();
}
}
}
iToken.Set (MarkedToken ());
SkipSpaceAndMark ();
return val;
}
示例8: SearchPhoneNumberL
/**
Search algorithm for searching phone numbers
@param aText Text that will be parsed
@return ETrue if any Phone Number items were found else returns EFalse
@leave KErrNone, if successful; otherwise one of the other system-wide error codes.
@panic ETulPanicDescriptorLength in debug build if item's position
and/or length is out of the document's range.
*/
TBool CTulAddressStringTokenizer::SearchPhoneNumberL( const TDesC& aText )
{
TLexMark startMark; // Points to the start of the found phone number
TLexMark endMark; // Points to the end of the found phone number
TLexMark mark;
const TInt end = aText.Length();
TLex number = aText;
while ( !(number.Eos()) )
{
TInt numberCount = 0; // How many real numbers (1234567890)
TInt bracketsOpen = 0; // How many brackets are currently open
TInt brackets = 0; // How many brackets overall
TChar charac = number.Peek();
while( (!(IsValidPhoneNumberChar( charac ) || charac == '+'
|| charac == '(' ) || charac == '-' || charac == '.' || charac == '/')
&& !(number.Eos()) && number.Offset() < end )
{
number.Inc();
charac = number.Peek();
}
if ( number.Offset() >= end )
break;
if ( number.Peek() == '#' )
{
number.Inc();
if (number.Peek() == '.' )
continue;
number.UnGet();
}
if ( number.Peek() == '+' )
{ // '+' has to be followed by a number (not # or * ...)
number.Inc();
if ( !(number.Peek().IsDigit()) )
continue;
number.UnGet();
}
if ( number.Peek() == '(' )
{ // '(' has to be followed by valid phone number
// character (whitespaces are allowed before) or '+' is a next character
number.Inc();
if ( !(number.Peek() == '+') )
{
number.Mark(mark);
number.SkipSpace();
charac = number.Peek();
if ( !( IsValidPhoneNumberChar(charac) || charac == '+'
|| charac == '(' ) || charac == '-' || charac == '.' || charac == '/')
{
number.Inc();
continue;
}
else
{
number.UnGetToMark(mark);
number.UnGet();
number.Mark(startMark);
}
}
else
{
number.UnGet();
number.Mark(startMark);
number.Inc();
}
bracketsOpen++;
brackets++;
}
else
number.Mark(startMark);
if ( number.Peek().IsDigit() ) // If the character was a number
numberCount++;
else if ( bracketsOpen > 0 )
{
number.Inc();
TChar next = number.Peek();
TInt bracketsOpen2 = bracketsOpen;
while( (IsValidPhoneNumberChar( next ) || next.IsSpace()
|| next == '(' || next == ')' || next == 'p' || next == '+'
|| next == 'w' ) && !(number.Eos()) && number.Offset() < end)
//.........这里部分代码省略.........