本文整理汇总了C++中TPtrC::Mid方法的典型用法代码示例。如果您正苦于以下问题:C++ TPtrC::Mid方法的具体用法?C++ TPtrC::Mid怎么用?C++ TPtrC::Mid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPtrC
的用法示例。
在下文中一共展示了TPtrC::Mid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetIniFileInfo
EXPORT_C TInt TEFparser::GetIniFileInfo(TDesC& aBuf,
TPtrC& aIniFileName,
TPtrC& aIniSectionName)
{
TInt pos =0;
TInt startPos = 0, endPos = 0;
TPtrC temp = aBuf.Mid(pos);
endPos = temp.Find(KIniExtension);
endPos += 4;
if (endPos != KErrNotFound)
{
TInt len = endPos - startPos;
TPtrC iniFileName = temp.Mid(startPos, len);
aIniFileName.Set(iniFileName);
TPtrC iniSectionName = temp.Mid(iniFileName.Length());
aIniSectionName.Set(Trim(iniSectionName));
return KErrNone;
}
else
{
return KErrNotFound;
}
}
示例2: EditableItemText
TPtrC CEikListBoxTextEditor::EditableItemText(TRect* aRect)
{
_AKNTRACE_FUNC_ENTER;
TPtrC itemtext = ItemText();
if (iItemPos==0) // not yet set (and even if set, cannot be zero)
{
iItemPos = itemtext.Locate('\n'); // loacte partly editable item start
if (iItemPos != KErrNotFound)
{
iItemPos++; // jump over mark character
iItemLen = itemtext.Mid( iItemPos ).Locate('\n'); // locate string end
if ( iItemLen == KErrNotFound )
Panic( ETUiklbedPanicEndMarkMissing );
if ( iItemLen==0 )
Panic( ETUiklbedPanicEmptyField );
TPtrC head = itemtext.Left( iItemPos );
TPtrC body = itemtext.Mid( iItemPos, iItemLen );
if ( aRect ) // adjust the rect if it is given
{
aRect->iTl.iX += iFont->TextWidthInPixels( head );
aRect->iBr.iX = aRect->iTl.iX + iFont->TextWidthInPixels( body ) + 4;
}
_AKNTRACE_FUNC_EXIT;
return body;
}
iItemPos = 0; // partly editable text not found
}
_AKNTRACE_FUNC_EXIT;
return itemtext;
}
示例3: IsAdaptiveFindMatchClassic
inline TBool IsAdaptiveFindMatchClassic( const TDesC& aItemString, const TDesC& aSearchText )
{
TPtrC itemptr = aItemString;
TPtrC searchptr = aSearchText;
TBool match = EFalse;
for(;;)
{
// Loop invariant: itemptr is next character from ' ' or '-'
// Loop invariant: seachptr is at beginning of searched item
TInt val = MyFindC(itemptr,searchptr);
if (val == 0)
{
match = ETrue;
break;
}
if (val != KErrNotFound && IsFindWordSeparator(itemptr[val-1]))
{
match = ETrue;
break;
}
// find the word separator characters from list item
TInt spacepos = itemptr.LocateF(TChar(' '));
TInt minuspos = itemptr.LocateF(TChar('-'));
TInt tabpos = itemptr.LocateF(TChar('\t'));
if (spacepos != KErrNotFound)
{
itemptr.Set(itemptr.Mid(spacepos+1));
}
else if (minuspos != KErrNotFound)
{
itemptr.Set(itemptr.Mid(minuspos+1));
}
else if (tabpos != KErrNotFound)
{
itemptr.Set(itemptr.Mid(tabpos+1));
}
else
{
match = EFalse;
break;
}
if (itemptr.Length() == 0)
{
match = EFalse;
break;
}
}
return match;
}
示例4: GetHexFromConfig
/**
* Reads the value present from the test steps ini file within the mentioned section name and key name
* Copies the value to the TInt reference passed in. The value can optionally be prefixed with 0x
* @param aSectName - Section within the test steps ini file
* @param aKeyName - Name of a key within a section
* @return aResult - The integer value of the Hex input
* @return TBool - ETrue for found, EFalse for not found
*/
TBool CDataWrapperBase::GetHexFromConfig(const TDesC& aSectName, const TDesC& aKeyName, TInt& aResult)
{
TPtrC result;
TBool ret=EFalse;
TRAPD(err, ret=GetCommandStringParameterL(aSectName, aKeyName, result));
if ( err != KErrNone )
{
ret=EFalse;
}
if ( ret )
{
TLex lex;
if( result.FindC(KPrefixHex)==KErrNone )
{
lex=result.Mid(KPrefixHex().Length());
}
else
{
lex=result;
}
ret=(lex.Val((TUint &)aResult, EHex)==KErrNone);
}
return ret;
}
示例5: GetRunTestStep
EXPORT_C TPtrC TEFparser::GetRunTestStep(TPtrC& aBuf,
const TDesC& aTag,
TInt& aPos,
TInt& aError)
{
TInt endPos = 0;
TInt startPos = 0;
TInt tempPos = 0;
TPtrC data = aBuf.Mid(aPos);
tempPos = data.Find(aTag);
if (tempPos != KErrNotFound)
{
tempPos += aTag.Length();
//
TPtrC temprunStepData = data.Mid(tempPos);
//
endPos = temprunStepData.Find(KNewline);
if (endPos == KErrNotFound)
{
endPos = temprunStepData.Find(KReturn);
}
if (endPos == KErrNotFound)
{
endPos = temprunStepData.Length();
}
//
TInt len = 0;
len = (endPos - startPos) + 1;
TPtrC runStepData = temprunStepData.Mid(startPos,len);
aPos += tempPos + runStepData.Length();
aError = KErrNone;
return Trim(runStepData);
}
else
{
aError = KErrNotFound;
return TPtrC();
}
}
示例6: ExtractServiceDescriptionL
void CTestRControlChannel::ExtractServiceDescriptionL (const TDesC& aConfigSection, CUPnPServiceRegisterParamSet& aServiceRegisterParamSet)
{
RFs fs;
RFile file;
RBuf8 buf;
User::LeaveIfError(fs.Connect());
CleanupClosePushL(fs);
TPtrC descriptionPath;
_LIT(KDescriptionPath, "Description_Path");
GetStringFromConfig(aConfigSection, KDescriptionPath, descriptionPath);
TInt err = file.Open(fs, descriptionPath, EFileShareReadersOnly);
// For Hardware system path is c:, so descriptionPath value present in '.ini' is referring 'c:'
if ( err == KErrPathNotFound )
{
RBuf fileName;
TDriveName aSystemDrive;
TDriveUnit driveunit(RFs::GetSystemDrive());
aSystemDrive.Zero();
aSystemDrive=driveunit.Name();
fileName.CreateL ( descriptionPath.Length () );
fileName.Zero();
fileName.Append(aSystemDrive);
fileName.Append ( descriptionPath.Mid ( aSystemDrive.Length () ) );
err = file.Open(fs, fileName, EFileShareReadersOnly);
}
if (err != KErrNone)
{
User::LeaveIfError(err);
}
CleanupClosePushL(file);
TInt fileSize = 0;
file.Size(fileSize);
buf.Create(fileSize);
err = file.Read(buf, fileSize);
aServiceRegisterParamSet.SetServiceDescriptionL ( buf );
CleanupStack::PopAndDestroy(2 );
buf.Close();
_LIT(KInfoLogFile, "CRControlChannelObserver::ExtractServiceDescriptionL End.... \n");
INFO_PRINTF1(KInfoLogFile);
}
示例7: ExtractNextToken
TInt CSwisExpressionEnvironment::ExtractNextToken(TPtrC& aTokenString, TPtrC& aParseString)
{
TInt separatorPosition = aParseString.LocateF(',');
// Check that a separator was located within the parse string
if(separatorPosition == KErrNotFound || separatorPosition > aParseString.Length()-1)
{
return KErrNotFound;
}
// Set the extracted token string and remove the token from the parse string
aTokenString.Set(aParseString.Left(separatorPosition));
aParseString.Set(aParseString.Mid(separatorPosition+1));
return KErrNone;
}
示例8: GetUintFromConfig
/**
* Reads the value present from the test steps ini file within the mentioned section name and key name
* Copies the value to the TUint reference passed in.
* If the value is prefixed with 0x the value is read as a hexadecimal value
* If the value is suffixed with b the value is read as a binary value
* If the value is prefixed with a 0 the value is read as an octal value
* If it does not match the above it is read in as an integer
* @param aSectName - Section within the test steps ini file
* @param aKeyName - Name of a key within a section
* @return aResult - The integer value of the Hex input
* @return TBool - ETrue for found, EFalse for not found
*/
TBool CDataWrapperBase::GetUintFromConfig(const TDesC& aSectName, const TDesC& aKeyName, TUint& aResult)
{
TPtrC result;
TBool ret=EFalse;
TRAPD(err, ret=GetCommandStringParameterL(aSectName, aKeyName, result));
if ( err != KErrNone )
{
ret=EFalse;
}
if ( ret )
{
TLex lex(result);
if( result.FindC(KPrefixHex)==KErrNone )
{
lex=result.Mid(KPrefixHex().Length());
ret=(lex.Val(aResult, EHex)==KErrNone);
}
else
{
TInt binarySuffixPosition=result.Length()-KSuffixBinary().Length();
if ( result.FindC(KSuffixBinary)==binarySuffixPosition )
{
lex=result.Left(binarySuffixPosition);
ret=(lex.Val(aResult, EBinary)==KErrNone);
}
else
{
if( result.FindC(KPrefixOctal)==KErrNone )
{
ret=(lex.Val(aResult, EOctal)==KErrNone);
}
else
{
TInt intResult;
ret=(lex.Val(intResult)==KErrNone);
if ( ret )
{
aResult=(TUint)intResult;
}
}
}
}
}
return ret;
}
示例9: DistinguishElement
LOCAL_C void DistinguishElement(const TPtrC& aElement, RArray<TRange>& aSelectiveCaseRange)
{
TInt colonOccurance = aElement.FindC(KTEFColon);
//we are expecting only a range or a test case ID over here...
if( colonOccurance!=KErrNotFound )
{
//then this is a range of testcases, split it at the colon
TRange newRange(aElement.Left(colonOccurance),aElement.Mid(colonOccurance+1));
aSelectiveCaseRange.Append(newRange);
}
else
{
TRange newRange(aElement,aElement);
aSelectiveCaseRange.Append(newRange);
}
}
示例10: StepToNextBlock
TInt CIniData::StepToNextBlock()
/**
Locates the next available block of data within a section
@return ETrue if successful or EFalse
*/
{
if (BlockState != E_UNKNOWN)
{
// get unscanned portion of the section
TPtrC temp = section.Mid(scanStart);
// find the start of the next block
if (BlockState == E_SET)
{
blockStart = temp.FindF(TPtrC(BEGIN_SET));
blockEnd = temp.FindF(TPtrC(END_SET));
}
else if (BlockState == E_TEMPLATE)
{
blockStart = temp.FindF(TPtrC(BEGIN_TEMPLATE));
blockEnd = temp.FindF(TPtrC(END_TEMPLATE));
}
else if (BlockState == E_ADD)
{
blockStart = temp.FindF(TPtrC(BEGIN_ADD));
blockEnd = temp.FindF(TPtrC(END_ADD));
}
if (blockStart != KErrNotFound && blockEnd != KErrNotFound)
{
// set the start point for the next block search
scanStart += blockEnd;
scanStart++;
// set the actual block to work with
blockEnd -= blockStart;
TPtrC tempBlock = temp.Mid(blockStart,blockEnd);
block.Set((unsigned short *)tempBlock.Ptr(), tempBlock.Length(), tempBlock.Size());
return ETrue;
}
}
return EFalse;
}
示例11: DoSearch
/**
Search for a node by directory path, start from children of aNodeToStart but do not include aNodeToStart.
@param aPath the path as the key to search in the tree
@param aNodeToStart the node whose children to start with
@param aNodeFound in return, the node found
@param aDirPos the location of the directory
@return KErrNone if a node found
KErrNotFound if no node is found
*/
TInt CLeafDirTree::DoSearch(const TDesC& aPath, CLeafDirTreeNode* aNodeToStart, CLeafDirTreeNode*& aNodeFound, TLeafDirData& aLeafDirData)
{
RPointerArray<CLeafDirTreeNode> currentLevel = aNodeToStart->Children();
TInt currentPos = currentLevel.Count() - 1;
// Current path in search
TPtrC currentPath;
currentPath.Set(aPath);
while (currentLevel.Count() > 0 && currentPos >= 0)
{
CLeafDirTreeNode* currentNode = currentLevel[currentPos];
TPtrC currentNodePath;
currentNodePath.Set(currentNode->Path());
TInt foundPos = currentPath.FindF(currentNodePath);
// If current child's path is part of the searching path,
// go to next level
// E.g.: current child's path = "1\2\3\", searching path = "1\2\3\5\".
if (foundPos == 0 && currentNodePath.Length() < currentPath.Length())
{
currentPath.Set(currentPath.Mid(currentNodePath.Length()));
currentLevel = currentNode->Children();
currentPos = currentLevel.Count() - 1;
continue;
}
// If current child's path matches current searching path,
// check the node type.
else if (foundPos == 0 && currentNodePath.Length() == currentPath.Length())
{
if (currentNode->IsPureIntermediary())
// If found is 'pure intermediary', it is not cached.
{
return KErrNotFound;
}
// Otherwise, we have got a cache hit!
MakeMostRecentlyUsed(currentNode);
aNodeFound = currentNode;
aLeafDirData = currentNode->LeafDirData();
return KErrNone;
}
// else, go through current level
currentPos--;
}
// If there is no child or we have not found any matching node,
// return KErrNotFound
return KErrNotFound;
}
示例12: ExtractSID
/**
The function parses thr database file name argument and extracts the SID from it (if the name contains SID).
The SID is expected to be found at position 0 of the file name and must have 8 hex digits.
@param aDbFileName Database file name
@return Database security UID or KNullUid if the database name does not contain SID.
@internalComponent
*/
static TUid ExtractSID(const TDesC& aDbFileName)
{
TParsePtrC parse(aDbFileName);//this call may panic if aDbFileName cannot be parsed, but SetL() already parsed it
TPtrC dbName = parse.Name();
TInt pos1 = dbName.Locate(TChar('['));
TInt pos2 = dbName.Locate(TChar(']'));
if(pos1 == 0 && pos2 == 9) //position 0 for '[', 8 digits SID, position 9 for ']'
{
TLex lex(dbName.Mid(pos1 + 1, pos2 - pos1 - 1));
TUid securityUid;
TInt err = lex.Val(*(TUint32*)&securityUid, EHex);
if(err == KErrNone)
{
return securityUid;
}
}
return KNullUid;
}
示例13: GetParameterL
// ---------------------------------------------------------
// CWtaiHandler::GetParameterL()
// ---------------------------------------------------------
//
TPtrC CWtaiHandler::GetParameterL(TInt aPos)
{
CLOG_ENTERFN( "CWtaiHandler::GetParameter()" );
// wtai://<library>/<function> (; <parameter>)*
TPtrC path = RemoveSchemeFromUrlL( KWtai );
// <library>/<function> (; <parameter>)*
TInt length = path.Length();
TInt start = 0; // starting position of the required parameter
TInt pos = 1; // current parameter
TInt i = 0; // character iterator
while( i < length )
{
if( ( path[i] == KSemiColon ) || ( path[i] == KExclamationMark ) )
{
// begining of a parameter is found
if( ( pos == aPos ) && ( path[i] != KExclamationMark ) )
{
// begining of the required parameter
start = i + 1; // skipping semicolon
}
else
{
if( start != 0 )
{
// end of the required parameter
break;
}
}
pos++;
}
i++;
}
start = ( start == 0 ) ? i : start; // there is n parameter but the (n+1). is required
CLOG_LEAVEFN( "CWtaiHandler::GetParameter()" );
return path.Mid( start, i-start ); // found parameter
}
示例14: ConstructL
void CUrl::ConstructL(const TDesC& aUrl)
//
// Non-trivial c'tor - can be used for all general urls
{
// Stripe any leading whitespace
TPtrC url = aUrl;
while( url.Locate(' ') == 0 )
{
// Remove the leading whitespace -> set pointer to second character
url.Set(url.Mid(1));
}
iUrlDes = url.AllocL();
// Check to see if there's ':' at start of aUrl
TInt colonPos = aUrl.Locate(':');
if (colonPos == 0)
User::Leave(EWapErrCorruptUrl);
TPtrC scheme(Component(EUrlScheme));
CheckSchemeValidL(scheme);
}
示例15: FromPtrC
// ---------------------------------------------------------------------------
// Unpackages TConnMonWLANNetwork from TPtrC descriptor
// ---------------------------------------------------------------------------
//
EXPORT_C TConnMonWLANNetwork TConnMonWLANNetwork::FromPtrC( const TPtrC& aPtrC )
{
TUint len( (TUint)aPtrC[ENameLength] );
TBuf<KMaxNameLength> name( aPtrC.Mid(EName, len) );
TUint connectionMode( aPtrC[len+EConnectionMode] );
TUint signalStrength( aPtrC[len+ESignalStrength] );
TUint securityMode( aPtrC[len+ESecurityMode] );
RArray<TInt> buf;
TUint count( aPtrC[len+EBufCounter] );
for ( TUint i = 1; i < count+1; ++i )
{
buf.Append( aPtrC[len+EBufBase+i] );
}
TConnMonWLANNetwork connMonWLANNetwork = TConnMonWLANNetwork( name,
connectionMode, signalStrength, securityMode, buf );
buf.Close();
return connMonWLANNetwork;
}