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


C++ TBuf8::Locate方法代码示例

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


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

示例1: RunL

// -----------------------------------------------------------------------------
// CContactSubscriber::RunL()
// Assyncronous request handler , on completion of notification
// -----------------------------------------------------------------------------
//
void CContactSubscriber::RunL()
{
    __TRACE_CALLSTACK;
    SubscribeChangeNotiFication();
    // property updated, get new value 
    TBuf8 <KBufferSize> value; 
    TPtrC8  id; 
    TPtrC8  sourceType; 
    TPtrC8  addressCount; 
    
    if ( KErrNone == iProperty.Get( value ) )
    { 
        TInt pos =  value.Locate(TChar('-')); 
        id.Set( value.Left(pos) ); 
        
        TPtrC8 ptr = value.Right(3); 
        sourceType.Set(ptr.Left(1)); 
        addressCount.Set(ptr.Right(1)); 
        
        TInt appId = -1, addressType = -1, addressTypeCount = -1; 
        TLex8 lex(id); 
        lex.Val(appId); 
        
        TLex8 lex1(sourceType); 
        lex1.Val( addressType ); 
        
        TLex8 lex2(addressCount); 
        lex2.Val(addressTypeCount); 
        
        iNotifyChange.GetChangeNotificationL( appId, addressType,addressTypeCount ); 
    } 
}
开发者ID:cdaffara,项目名称:symbiandump-ossapps,代码行数:37,代码来源:contactsubscriber.cpp

示例2: OpenTestFileL

void CLinePaginatorTest::OpenTestFileL()
	{
	TBuf8<128> text;
	TInt err=ifsClient.Connect();
	err=iTestFile.Open(ifsClient,TEST_FILE,EFileStream|EFileRead|EFileShareReadersOnly);


	iTestFile.Read(0,text,128);
	TInt startNum=text.Locate('<')+1;
	text.Delete(0,startNum);
	TLex8 lex=text;
	TInt pageHeight;
	lex.Val(pageHeight);
	iPaginator.SetPageHeight(pageHeight);

	TBuf<254> buf;
	buf.AppendFormat(_L("DocPos\tHeight\tKeep\tStart\tHeight of Pages = <%d>\n"), pageHeight);
	TESTPRINT(buf);
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:19,代码来源:TLINEPAG.CPP

示例3: ConstructL

/**
ConstructL()
Parses a .txt file and creates Arrays of fields and there values

@param aFileName
Name of the file to be parsed.
*/
EXPORT_C void CT_MsgUtilsConfigFileParserUtility::ConstructL(const TDesC& aFileName)
	{
	RFs fileServerSession;

	fileServerSession.Connect();

	RFile file;
	User::LeaveIfError(file.Open(fileServerSession, aFileName, EFileRead));

	TInt eof = EFalse;
	TInt fileOffset = 0;
	TBuf8<KFileBufferSize> fileBuffer;

	while (!eof)
		{
		fileBuffer.SetLength(0);
		User::LeaveIfError(file.Read(fileOffset, fileBuffer, KFileBufferSize));
		TInt read = fileBuffer.Length();

		if (read < KFileBufferSize)
			{
			fileBuffer.Append('\n');
			eof = ETrue;
			}

		TInt lineOverflow = fileBuffer.Locate('\n');
		
		if ((lineOverflow == KErrNotFound) && (read == KFileBufferSize))
			{
			User::Leave(KErrOverflow);
			}

		TInt eol = EFalse;
		
		while (!eol)
			{
			TInt lineFeedLocation = fileBuffer.Locate('\n');
			
			if (lineFeedLocation == KErrNotFound)
				{
				eol = ETrue;
				}
			
			else
				{
				fileOffset += lineFeedLocation + 1;
				TInt lineLength;
				if ((lineFeedLocation != 0) && (fileBuffer[lineFeedLocation - 1] == '\r'))
					{
					lineLength = lineFeedLocation - 1;
					}
					
				else
					{
					lineLength = lineFeedLocation;
					}
					
				TPtrC8 line  = fileBuffer.Left(lineLength);
				TInt commentLocation = line.Match(KComment);
				
				if (commentLocation != KErrNotFound)
					{
					TPtrC8 skipComment = line.Left(commentLocation);
					line.Set(skipComment);
					}
					
				TInt seperatorLocation = line.Locate('=');
				
				if (seperatorLocation != KErrNotFound)
					{
					if ((seperatorLocation == 0) || (seperatorLocation == line.Length() - 1))
						{
						seperatorLocation = KErrNotFound;
						}
					}
					
				if (seperatorLocation != KErrNotFound)
					{
					TPtrC8 namePtr = line.Left(seperatorLocation);
					HBufC8* nameBuf8 = HBufC8::NewL(namePtr.Length());
					CleanupStack::PushL(nameBuf8);
					
					TPtr8 name8 = nameBuf8->Des();
					name8.Copy(namePtr);
					name8.Trim();
					HBufC* nameBuf16 = HBufC::NewL(namePtr.Length());
					TPtr name16 = nameBuf16->Des();
					name16.Copy(name8);
					iName.Append(nameBuf16);
					CleanupStack::PopAndDestroy(nameBuf8);

					TPtrC8 contentPtr = line.Mid(seperatorLocation + 1);
					HBufC8* contentBuf8 = HBufC8::NewL(contentPtr.Length());
//.........这里部分代码省略.........
开发者ID:cdaffara,项目名称:symbiandump-mw2,代码行数:101,代码来源:T_UtilsConfigFileParserUtility.cpp

示例4: ReadTestFile

TBool CLinePaginatorTest::ReadTestFile(TPageLine& aLine)
	{
	TLex8 lex;
	TBuf8<128> textBuffer;
	TBuf8<128> numBuffer;
	TInt startNum;

	iTestFile.Read(iFilePos,textBuffer,128);
	if (textBuffer.Locate('X') != KErrNotFound && textBuffer.Locate('X') < textBuffer.Locate('\r'))
		{
		startNum=textBuffer.Locate('\n')+1;
  		textBuffer.Delete(0,startNum);
		iFilePos+=startNum;
		lex=textBuffer;
		lex.Val(aLine.iDocPos);
		TBuf<254> buf;
		buf.AppendFormat(_L("%d\tX\n"), aLine.iDocPos);
		TESTPRINT(buf);
		return EFalse;
		}

	startNum=textBuffer.Locate('\n')+1;
	textBuffer.Delete(0,startNum);
	iFilePos+=startNum;
	lex=textBuffer;
	lex.Val(aLine.iDocPos);

	startNum=textBuffer.Locate('\t')+1;
	textBuffer.Delete(0,startNum);
	iFilePos+=startNum;
	lex=textBuffer;
	lex.Val(aLine.iLineHeight);

	startNum=textBuffer.Locate('\t')+1;
	textBuffer.Delete(0,startNum);
	iFilePos+=startNum;
	lex=textBuffer;
	lex.Val(aLine.iKeepWithNext);

	startNum=textBuffer.Locate('\t')+1;
	textBuffer.Delete(0,startNum);
	iFilePos+=startNum;
	lex=textBuffer;
	lex.Val(aLine.iStartNewPage);

	if (textBuffer.Locate('\t')<textBuffer.Locate('\r')
		&& textBuffer.Locate('B')!=KErrNotFound
		&& textBuffer.Locate('B')<textBuffer.Locate('\r'))
		iTestPageBreak=ETrue;
	else
		iTestPageBreak=EFalse;

	iFilePos+=textBuffer.Locate('\r')+1;
	return ETrue;
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:55,代码来源:TLINEPAG.CPP


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