本文整理汇总了C++中TPtrC::Left方法的典型用法代码示例。如果您正苦于以下问题:C++ TPtrC::Left方法的具体用法?C++ TPtrC::Left怎么用?C++ TPtrC::Left使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPtrC
的用法示例。
在下文中一共展示了TPtrC::Left方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OverrideFormatForParsersIfApplicable
void CRichText::OverrideFormatForParsersIfApplicable(TPtrC& aText, TCharFormatX& aFormat, TInt aStartPos) const
{
if (aFormat.iParserTag && iParserData->iActiveParserList && iParserData->iEditObserver)
{
// Replace format
TInt start = -1;
TInt length = 0;
TInt curPos = iParserData->iLastKnownCursor;
if (curPos > DocumentLength())
curPos = DocumentLength(); // This shouldn't be neccesary but it makes it more
// bulletproof if the calls from outside are made in
// the wrong order
if (curPos != -1)
{
TCharFormatX format;
TCharFormatXMask varies;
MParser* parser;
GetExtendedCharFormat(format, varies, curPos, 1);
// If char at curpos has a tag then cursor is over that tag, get extents of tag
if (CParserList::ReformatOnRollover(format.iParserTag))
DoCursorOverTag(curPos, parser, start, length);
else if (curPos)
{
GetExtendedCharFormat(format, varies, curPos - 1, 1);
// Try the char "before" curpos
if (CParserList::ReformatOnRollover(format.iParserTag))
DoCursorOverTag(curPos - 1, parser, start, length);
}
}
MParser* parser = iParserData->iActiveParserList->ParserWithThisTag(aFormat.iParserTag);
if (length && (aStartPos >= start) && (aStartPos < start + length))
{
if (start + length < aStartPos + aText.Length())
aText.Set(aText.Left(start + length - aStartPos));
if (parser != NULL)
{
// Only accept the rollover format if the parser agrees
// with the framework match of a tag
if (parser->ConfirmCursorOverTag(*this, start, length, curPos))
parser->GetRolloverFormat(aFormat.iCharFormat);
else
// Reset format to recognised format if parser disagrees
// with the framework match as the tag is still in view
// and must be formatted as in the else clause below.
parser->GetRecogniseFormat(aFormat.iCharFormat);
}
}
else
{
if (length && (start > aStartPos))
aText.Set(aText.Left(start - aStartPos));
if (parser != NULL)
parser->GetRecogniseFormat(aFormat.iCharFormat);
}
}
}
示例2: GetConfigL
void CAppConfig::GetConfigL(const TDesC &aKey, const TConfig &aConfig) {
RDbTable table;
TDbSeekKey seekKey(aKey);
User::LeaveIfError(table.Open(iDb, KConfigTable, table.EReadOnly));
CleanupClosePushL(table);
User::LeaveIfError(table.SetIndex(KConfigIndex));
CDbColSet* colSet = table.ColSetL();
CleanupStack::PushL(colSet);
TInt valueColNo = colSet->ColNo(KConfigValueCol);
if (table.SeekL(seekKey)) {
table.GetL();
TPtrC value = table.ColDes(valueColNo);
switch (aConfig.iType) {
case EConfigBool:
*aConfig.iValue.iBool = value.Compare(KBoolTrue) == 0 ? ETrue : EFalse;
break;
case EConfigInt: {
TLex lex(value);
TInt lvalue;
if (lex.Val(lvalue) == KErrNone) {
*aConfig.iValue.iInt = lvalue;
}
break;
}
case EConfigText:
if (aConfig.iValue.iText->MaxLength() > value.Length()) {
aConfig.iValue.iText->Copy(value.Left(aConfig.iValue.iText->MaxLength()));
} else {
aConfig.iValue.iText->Copy(value);
}
break;
case EConfigText8:
if (aConfig.iValue.iText8->MaxLength() > value.Length()) {
aConfig.iValue.iText8->Copy(value.Left(aConfig.iValue.iText8->MaxLength()));
} else {
aConfig.iValue.iText8->Copy(value);
}
break;
}
}
CleanupStack::PopAndDestroy(colSet);
CleanupStack::PopAndDestroy(&table);
}
示例3: 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;
}
示例4: ReadLine
TPtrC TLineBuffer::ReadLine()
{
// Class nvariant: iRemainder == iTail.Length()
ASSERT(iRemainder == iTail.Length());
TInt end = iTail.Locate('\n');
if (end < 0)
{
// Buffer ends without ending '\n', treat as line
end = iTail.Length();
iRemainder = 0;
}
else
{
// 0 <= end < iTail.Length() => iTail.Length() > iRemainder >= 0
// (remainder is always decreased at least by 1, skipping '\n',
// and will never become negative, because end < remainder)
iRemainder -= end + 1;
// Ignore CR before LF, if present
if (end > 0 && iTail[end-1] == '\r')
--end;
}
const TPtrC line(iTail.Left(end));
iTail.Set(iTail.Right(iRemainder));
return line;
}
示例5: WriteComment
EXPORT_C void TInuLogger::WriteComment(const TDesC& aComment)
//
// Writes aComment to test log file, logging file and test harness
{
TPtrC line;
line.Set(aComment);
while (line.Length() > KMaxLogLineLength)
{
iLogger.Write(line.Left(KMaxLogLineLength));
line.Set(line.Right(line.Length() - KMaxLogLineLength));
}
iLogger.Write(line.Left(line.Length()));
}
示例6: if
S60MediaRecognizer::MediaType S60MediaRecognizer::identifyMediaType(const QString& fileName)
{
S60MediaRecognizer::MediaType result = Video; // default to videoplayer
bool recognizerOpened = false;
TInt err = m_recognizer.Connect();
if (err == KErrNone) {
recognizerOpened = true;
}
err = m_fileServer.Connect();
if (err == KErrNone) {
recognizerOpened = true;
}
// This is needed for sharing file handles for the recognizer
err = m_fileServer.ShareProtected();
if (err == KErrNone) {
recognizerOpened = true;
}
if (recognizerOpened) {
m_file.Close();
err = m_file.Open(m_fileServer, QString2TPtrC(QDir::toNativeSeparators(fileName)), EFileRead |
EFileShareReadersOnly);
if (err == KErrNone) {
TDataRecognitionResult recognizerResult;
err = m_recognizer.RecognizeData(m_file, recognizerResult);
if (err == KErrNone) {
const TPtrC mimeType = recognizerResult.iDataType.Des();
if (mimeType.Left(KMimeTypePrefixLength).Compare(KMimeTypePrefixAudio) == 0) {
result = Audio;
} else if (mimeType.Left(KMimeTypePrefixLength).Compare(KMimeTypePrefixVideo) == 0) {
result = Video;
}
}
}
}
return result;
}
示例7: UpdateModelL
EXPORT_C TBool CEikListBoxTextEditor::UpdateModelL()
// virtual - needs to be rewritten if editing other than single column text list
{
_AKNTRACE_FUNC_ENTER;
if (!Editor())
{
_AKNTRACE_FUNC_EXIT;
return EFalse; // quit if editing is not currently on
}
const MDesCArray* matchableTextArray=ListBoxModel()->MatchableTextArray();
CDesCArray* textArray=(CDesCArray*)matchableTextArray;
TPtrC itemtext = ItemText();
if ( iItemPos ) // partly editable item?
{
HBufC* itemBuffer= HBufC::New(itemtext.Length());
CleanupStack::PushL( itemBuffer );
TPtr itemPointer = itemBuffer->Des();
itemPointer.Append( itemtext.Left( iItemPos ) );
HBufC* ptr=iEditor->GetTextInHBufL();
TPtrC newText;
if (ptr)
{
newText.Set(ptr->Des());
}
TInt addSpaces = iItemLen - newText.Length();
for (TInt index=0; ((addSpaces>0) && (index<addSpaces)); index++)
itemPointer.Append(_L(" "));
itemPointer.Append( newText );
itemPointer.Append( itemtext.Right( itemtext.Length()-iItemPos-iItemLen ) );
delete ptr;
textArray->InsertL( ItemIndex(), *itemBuffer );
CleanupStack::PopAndDestroy(); // itemBuffer
textArray->Delete( ItemIndex()+1 );
}
else // replace the whole list item
{
HBufC* newText = iEditor->GetTextInHBufL();
if (!newText) return ETrue; // if user tries to insert an empty text...
CleanupStack::PushL(newText);
textArray->InsertL(ItemIndex(),*newText);
CleanupStack::PopAndDestroy(); // newText
textArray->Delete( ItemIndex() + 1 );
}
_AKNTRACE_FUNC_EXIT;
return ETrue;
}
示例8: WriteComment
/**
Function to write a comment string to test log file, logging file and test harness.
@param aComment The descriptor containing the comment string
*/
EXPORT_C void THttpLogger::WriteComment(const TDesC& aComment)
//
// Writes aComment to test log file, logging file and test harness
{
if(iLogger)
{
// If connection to flogger was made
if(iLogger->Handle() != 0)
{
TPtrC line;
line.Set(aComment);
while (line.Length() > KMaxLogLineLength)
{
iLogger->Write(line.Left(KMaxLogLineLength));
line.Set(line.Right(line.Length() - KMaxLogLineLength));
}
iLogger->Write(line.Left(line.Length()));
}
}
}
示例9: FoundNewItemL
void CScriptFile::FoundNewItemL(const TDesC& aText, TLex& arInput, TInt& arCurrentItemStart, CScriptSection& aSection, CScriptSectionItem*& arCurrentItem)
{
TPtrC token = arInput.MarkedToken();
ParseAndSetItemValueL(aText, arInput, arCurrentItemStart, arCurrentItem);
arInput.SkipSpaceAndMark();
arCurrentItemStart = arInput.Offset();
TPtrC itemEnd(KScriptItemEnd);
const TInt length = token.Length() - itemEnd.Length();
arCurrentItem = &aSection.ReplaceItemL(token.Left(length), KNullDesC);
}
示例10: SubstractLine
/*
-------------------------------------------------------------------------------
Class: CStifSectionParser
Method: SubstractLine
Description: Substracts line from selected text
Parameters: TPtrC& aText: in: text.
Return Values: TPtrC: Substracted line.
Errors/Exceptions: None
Status: Proposal
-------------------------------------------------------------------------------
*/
TPtrC CStifSectionParser::SubstractLine( const TPtrC& aText )
{
TLex lex( aText );
while( !lex.Eos() )
{
if ( lex.Get() == 0x0A ) // "\n" character. Unix style
{
break;
}
}
return aText.Left( lex.Offset() );
}
示例11: CopyMinFieldText
/**
Copy a maximum of KTextFieldMinimalLength characters from aSrc to aDest.
@param aSrc Source text buffer.
@param aDest Destination text buffer.
@return ETrue if copy was successfull, EFalse otherwise.
*/
TBool TCntPersistenceUtility::CopyMinFieldText(TPtrC aSrc,TDes& aDest)
{
TBool ret(EFalse);
if(aSrc.Length() > 0)
{
TInt length = aSrc.Length();
if (length>KTextFieldMinimalLength)
{
length=KTextFieldMinimalLength;
}
aDest.Copy(aSrc.Left(length));
ret = ETrue;
}
return ret;
}
示例12: GetWtaiLibraryFunctionL
// ---------------------------------------------------------
// CWtaiHandler::GetWtaiLibraryFunctionL()
// ---------------------------------------------------------
//
TPtrC CWtaiHandler::GetWtaiLibraryFunctionL()
{
CLOG_ENTERFN( "CWtaiHandler::GetWtaiLibraryFunction()" );
// wtai://<library>/<function> (; <parameter>)*
TPtrC path = RemoveSchemeFromUrlL( KWtai );
// <library>/<function> (; <parameter>)*
TInt colonPos = VerifyWtaiSchemeL( path );
TPtrC library_function = path.Left( colonPos );
CLOG_LEAVEFN( "CWtaiHandler::GetWtaiLibraryFunction()" );
return library_function; // <library>/<function>
}
示例13: 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;
}
示例14: 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);
}
}
示例15: 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;
}