当前位置: 首页>>代码示例>>C++>>正文


C++ TPtrC::Match方法代码示例

本文整理汇总了C++中TPtrC::Match方法的典型用法代码示例。如果您正苦于以下问题:C++ TPtrC::Match方法的具体用法?C++ TPtrC::Match怎么用?C++ TPtrC::Match使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TPtrC的用法示例。


在下文中一共展示了TPtrC::Match方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Recognize

TBool CCmdRemark::Recognize( const TDesC& aCommand  )
{
// Obey the command family's step over mode.
SetStepOver(Family()->StepOver());

// Check if is empty or begins with # character.
TPtrC cmd = TfrLex::Trim(aCommand);

//	look for empty, # or //
return ((cmd.Length() == 0) || (cmd.Match( _L("#*")) == 0) || (cmd.Match(_L("//*")) == 0 ));
}
开发者ID:kuailexs,项目名称:symbiandump-mw2,代码行数:11,代码来源:CCmdStandard.cpp

示例2: GetCommandStringParameterL

TBool CDataWrapperBase::GetCommandStringParameterL(const TDesC& aSectName, const TDesC& aKeyName, TPtrC& aResult)
	{
	TBool	ret=EFalse;

	if ( aSectName.Length()!=0 )
		{
		ret=CDataWrapper::GetStringFromConfig(aSectName, aKeyName, aResult);

		for ( TInt index=iInclude.Count(); (index>0) && (!ret); )
			{
			ret=iInclude[--index]->FindVar(aSectName, aKeyName, aResult);
			}
		}

	if ( ret )
		{
		if ( aResult.Match(KMatch)!=KErrNotFound )
			{
			//	We have an entry of the format
			//	entry =*{section,entry}*
			//	where * is one or more characters
			//	We need to construct this from other data in the ini file replacing {*,*}
			//	with the data from
			//	[section]
			//	entry =some_value
			HBufC*	buffer=HBufC::NewLC(aResult.Length());
			buffer->Des().Copy(aResult);

			TInt	startLength=KStart().Length();
			TInt	sparatorLength=KSeparator().Length();
			TInt	endLength=KEnd().Length();
			TInt	bufferLength;
			TInt	start;
			TInt	sparator;
			TInt	end;
			TPtrC	remaining;
			TLex	lex;
			do
				{
				bufferLength=buffer->Length();
				start=buffer->Find(KStart);

				remaining.Set(buffer->Des().Right(bufferLength-start-startLength));
				sparator=remaining.Find(KSeparator);
				remaining.Set(remaining.Right(remaining.Length()-sparator-sparatorLength));
				sparator += (start + startLength);

				end=remaining.Find(KEnd) + sparator + sparatorLength;

				TPtrC	sectionName(buffer->Ptr()+start+startLength, sparator-start-startLength);
				TPtrC	keyName(buffer->Ptr()+sparator+sparatorLength, end-sparator-sparatorLength);
				sectionName.Set(TLex(sectionName).NextToken());
				keyName.Set(TLex(keyName).NextToken());

				TInt	entrySize=0;
				TPtrC	entryData;
				TBool	found=CDataWrapper::GetStringFromConfig(sectionName, keyName, entryData);
				for ( TInt index=iInclude.Count(); (index>0) && (!found);  )
					{
					found=iInclude[--index]->FindVar(sectionName, keyName, entryData);
					}
				if ( found )
					{
					entrySize=entryData.Length();
					}

				TInt	newLength=start + bufferLength - end - endLength + entrySize;
				HBufC*	bufferNew=HBufC::NewLC(newLength);
				bufferNew->Des().Copy(buffer->Ptr(), start);
				if ( entrySize>0 )
					{
					bufferNew->Des().Append(entryData);
					}
				bufferNew->Des().Append(buffer->Ptr() + end + endLength, bufferLength - end - endLength);
				CleanupStack::Pop(bufferNew);
				CleanupStack::PopAndDestroy(buffer);
				buffer=bufferNew;
				CleanupStack::PushL(buffer);
				}
			while ( buffer->Match(KMatch)!=KErrNotFound );
			iBuffer.Append(buffer);
			CleanupStack::Pop(buffer);
			aResult.Set(*buffer);
			INFO_PRINTF4(KDataRead, &aSectName, &aKeyName , &aResult);
			}
		}

	return ret;
	}
开发者ID:cdaffara,项目名称:symbiandump-os1,代码行数:89,代码来源:DataWrapperBase.cpp

示例3: SearchUrlL

/**
Search fixed start URLs, i.e. URLs without schema (www., wap.).
Also finds IPv4 addresses (*.*.*.*).
As a special case, supports deprecated hardcoded schematic addresses finding 
(http://, https://, rtsp://) to make sure deprecated search cases work 
as they did previously.

@param aText Text that will be parsed
@param aFindFixedSchemas If true, will find old fixed schematic URLs also
@return ETrue if any URL are 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::SearchUrlL( const TDesC& aText, const TBool aFindFixedSchemas )
    {
    TLex text = aText;
    while ( !text.Eos() )
        {
        while( !(text.Eos()) && !IsValidUrlChar( text.Peek() ) )
            text.Inc();

        text.Mark();
        while( !(text.Eos()) && IsValidUrlChar( text.Peek() ) )
            text.Inc();

        TPtrC tokenPtr = text.MarkedToken();
        TBool wasValidUrl = EFalse;

        if ( aFindFixedSchemas )	// Search for http://
            wasValidUrl = ParseUrlL( KHttpUrlAddress, tokenPtr, text.Offset() );
        
        if (aFindFixedSchemas && !wasValidUrl)	// Search for https://
            wasValidUrl = ParseUrlL( KHttpsUrlAddress, tokenPtr, text.Offset() );

        if (aFindFixedSchemas && !wasValidUrl) // Search for rtsp://
            wasValidUrl = ParseUrlL( KRtspUrlAddress, tokenPtr, text.Offset() );

        if ( !wasValidUrl )	// Search for www.
            wasValidUrl = ParseUrlL( KWwwUrlAddress, tokenPtr, text.Offset() );

        if ( !wasValidUrl )	// Search for wap.
            wasValidUrl = ParseUrlL( KWapUrlAddress, tokenPtr, text.Offset() );

        if ( !wasValidUrl )	// Search for IP-address (xxx.xxx.xxx.xxx)
            { 
            if ( tokenPtr.Match( KIPAddress ) != KErrNotFound )
                {
                TInt periods = 0;
                wasValidUrl = ETrue;
                TBool endWithPunctuation = EFalse;
                TBool betweenBrackets = EFalse;

                // First see if token ends with ",",".","!","?",";" or ":"
                TChar charac = tokenPtr[tokenPtr.Length() - 1];
                TChar charac0 = tokenPtr[0];
                if ( charac == ',' || charac == '.' ||
                     charac == '!' || charac == '?' ||
                     charac == ';' || charac == ':' )
                    {
                    endWithPunctuation = ETrue;
                    }
                // Or if it starts and ends with brackets or quotation marks
                else if ( ( charac0 == '(' && charac == ')' )
                       || ( charac0 == '"' && charac == '"' )
                       || ( charac0 == '[' && charac == ']' )
                       || ( charac0 == '<' && charac == '>' ) )
                    {
                    betweenBrackets = ETrue;
                    }

                TInt i = 0;
                TInt tokensEnd = tokenPtr.Length();
                if ( endWithPunctuation )
                    tokensEnd--;
                else if ( betweenBrackets )
                    {
                    i = 1;
                    tokensEnd--;
                    }

                // Take a closer look to see if a valid IP-address
                TBuf<3> ipPart;
                TInt numbers = 0;
                for ( ; i < tokensEnd; i++ )
                    {
                    if ( !( ((TChar)tokenPtr[i]).IsDigit() || tokenPtr[i] == '.' ) )
                        {
                        wasValidUrl = EFalse;
                        break;
                        }

                    if ( tokenPtr[i] == '.' )
                        periods++;
                    else
                        numbers++;

                    if ( numbers > KNumbersInIpAddress || periods > KDotsInIpAddress )
                        {
                        wasValidUrl = EFalse;
                        break;
//.........这里部分代码省略.........
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:101,代码来源:tuladdressstringtokenizer.cpp

示例4: ProcessL

TInt CCmdIf::ProcessL(const TDesC &aCommand)
{
// Complete the test machine - will then get the next cmd
Machine()->CompleteRequest();

//	this converts the first parameter (if found) into something useful!
TPtrC param;
TRAPD(error, param.Set(ParamsL(aCommand)));
if (error != KErrNone)
	return Error(error, TFR_KFmtErrBadCmd, &Keyphrase());

TLex parse(param);
if (!parse.Eos() && !parse.Peek().IsSpace())
	return Error(error, TFR_KFmtErrBadCmd, &Keyphrase());

parse.SkipSpace();
if (parse.Eos())
	//	no parameters so invalid command
	return Error(error, TFR_KFmtErrBadCmd, &Keyphrase());

//	convert into our LValue
TPtrC lvalue;
TRAP(error, lvalue.Set(TfrLex::GetL(parse)));
if (error != KErrNone)
	return Error(error, TFR_KFmtErrBadCmd, &Keyphrase());

lvalue.Set(TfrLex::Peel(lvalue));
if (lvalue.Length() > 32)
	return Error(error, TFR_KFmtErrBadCmd, &Keyphrase());

//	now check that the second 'param' is one of our comparison tokens...
TPtrC opr;
TRAP(error, opr.Set(TfrLex::GetL(parse)));
if (error != KErrNone) 
	return Error(KErrArgument, TFR_KFmtErrBadCmd, &opr);

//	check is valid length
opr.Set(TfrLex::Peel(opr));
if (opr.Length() > 16) 
	return Error(KErrArgument, THA_KErrParameterLong, &opr);

//	check operator is one of our known list
//	Param shall be HTTP or WSP
opr.Set(TfrLex::TrimAndPeel(opr));
TBool eValue;
if (opr.CompareF(KTxtEquals) == 0)
	eValue = TCO_Equals;

else if (opr.CompareF(KTxtNotEqual) == 0)
	eValue = TCO_NotEqual;

else if (opr.CompareF(KTxtGreaterThan) == 0)
	eValue = TCO_GreaterThan;

else if (opr.CompareF(KTxtLessThan) == 0)
	eValue = TCO_LessThan;

else if (opr.CompareF(KTxtGreaterThanEq) == 0)
	eValue = TCO_GreaterThanEq;

else if (opr.CompareF(KTxtLessThanEq) == 0)
	eValue = TCO_LessThanEq;

else	//	not recognized the comp.operator so error
	return Error(KErrArgument, THA_KErrInvalidOptr, &opr);

//	now look at the final parameter and convert into our LValue
//	assuming that there is anything more.
TPtrC rvalue = TfrLex::Trim(parse.Remainder());
if (rvalue.Length() == 0) 
	return Error(KErrArgument, TFR_KFmtErrBadCmd, &aCommand);

rvalue.Set(TfrLex::TrimAndPeel(rvalue));
if (rvalue.Length() > 16)
	return Error(error, TFR_KFmtErrBadCmd, &Keyphrase());

// ParseOnly => not executed.
if (Family()->Switch(CCmdFamily::EParseOnly))
	return error;

//	determine if we're comparing numeric or data (or both!)
TBool iNumeric = ETrue;
TInt ilval;
TInt irval;
if (InetProtTextUtils::ConvertDescriptorToInt(lvalue,ilval) < 0)
	iNumeric = EFalse;

//	check we're not comparing apples with oranges...
iNumeric = ((InetProtTextUtils::ConvertDescriptorToInt(rvalue,irval) < 0) && iNumeric) ? EFalse : ETrue;

//	now determine the comparison result (also 
//	-1 => error or failure (i.e. < 0) 0 = false, 1 = true
TInt iResult = -2;
switch (eValue)
	{
	case TCO_Equals : 
		iResult = (iNumeric) ? ((TInt) (ilval == irval)) : ((lvalue.Match(rvalue) == 0) ? 1 : 0); break;
	case TCO_NotEqual : 
		iResult = (iNumeric) ? ((TInt) (ilval != irval)) : ((lvalue.Match(rvalue) != 0) ? 1 : 0); break;
	case TCO_GreaterThan : 
//.........这里部分代码省略.........
开发者ID:kuailexs,项目名称:symbiandump-mw2,代码行数:101,代码来源:CCmdStandard.cpp


注:本文中的TPtrC::Match方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。