本文整理汇总了C++中TPtrC::Length方法的典型用法代码示例。如果您正苦于以下问题:C++ TPtrC::Length方法的具体用法?C++ TPtrC::Length怎么用?C++ TPtrC::Length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPtrC
的用法示例。
在下文中一共展示了TPtrC::Length方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BuildUnknownL
/**
Test MSdpElementBuilder::BuildUnknownL()
*/
void CT_DataSdpElementBuilder::DoCmdBuildUnknownL(MSdpElementBuilder& aElementBuilder, const TDesC& aSection)
{
TInt theValue;
if( iDataWrapper.GetIntFromConfig(aSection, KType(), theValue) )
{
TUint8 type = theValue;
if( iDataWrapper.GetIntFromConfig(aSection, KSizeDesc(), theValue) )
{
TUint8 sizeDesc = theValue;
TPtrC theString;
if( iDataWrapper.GetStringFromConfig(aSection, KData(), theString) )
{
HBufC8* theString8 = HBufC8::NewLC(theString.Length());
theString8->Des().Copy(theString);
TPtrC8 stringPtr=theString8->Des();
TRAPD(err, aElementBuilder.BuildUnknownL(type, sizeDesc, stringPtr));
if(err != KErrNone)
{
iDataWrapper.ERR_PRINTF2(_L("MSdpElementBuilder BuildUnknownL failed with error %d"), err);
iDataWrapper.SetError(err);
}
CleanupStack::PopAndDestroy(theString8);
}
else
{
iDataWrapper.ERR_PRINTF2(_L("Missing parameter %S"), &KData());
iDataWrapper.SetBlockResult(EFail);
}
}
else
{
iDataWrapper.ERR_PRINTF2(_L("Missing parameter %S"), &KData());
iDataWrapper.SetBlockResult(EFail);
}
}
else
{
iDataWrapper.ERR_PRINTF2(_L("Missing parameter %S"), &KData());
iDataWrapper.SetBlockResult(EFail);
}
}
示例2: i
HBufC8 *CemailTest::GetNextStringLC ( CStifItemParser& aItem, const TDesC &aName )
{
TPtrC nodename;
nodename.Set( KNullDesC );
TInt i( aItem.GetNextString ( nodename ) );
if ( i != KErrNone )
{
iLog->Log( _L( "ERROR Reading '%S' argument: 0x%X" ), &aName, i );
}
else
{
iLog->Log( _L("%S: %S"), &aName, &nodename);
}
HBufC8 *buf = HBufC8::NewLC( nodename.Length() ) ;
buf->Des().Copy( nodename );
return buf;
}
示例3: ReadStringParam
//Util function
void CTestIfioctls::ReadStringParam(char* aString)
{
_LIT( KSl, "Param%d" );
TBuf<8> pNameBuf;
TPtrC string;
pNameBuf.Format(KSl,++iParamCount);
TBool res = GetStringFromConfig(ConfigSection(), pNameBuf, string);
if(!res)
{
_LIT(Kerr , "Unable to retrieve string parameter") ;
INFO_PRINTF1(Kerr);
}
TBuf8<256> bufstring;
bufstring.Copy(string);
TInt paramLength=string.Length();
char* text=(char *)(bufstring.Ptr());
*(text+paramLength)='\0';
strcpy(aString,text);
return;
}
示例4: SetTextL
void CPreviewPopUpContent::SetTextL(const TDesC& aFirstText,
const TDesC& aSecondText,
const TDesC& aThirdText)
{
TBuf<256> wrappedText;
AknTextUtils::WrapToStringL(aSecondText, *iStringLengths,
*iLabelContainer[1].iLabel->Font(),
wrappedText);
iLabelContainer[0].iLabel->SetTextL(aFirstText);
iLabelContainer[0].iLabel->CropText();
_LIT(KNewLine, "\n");
TInt pos = wrappedText.Find(KNewLine);
if (pos != KErrNotFound) {
TPtrC leftText = wrappedText.Left(pos);
iLabelContainer[1].iLabel->SetTextL(leftText);
TPtrC rightText = wrappedText.Mid(pos + 1);
if (rightText.Length() < 1) {
// WrapToStringL always seems to add a newline so we need to
// check for length as well.
iLabelContainer[2].iLabel->SetTextL(aThirdText);
iLabelContainer[2].iLabel->CropText();
iLabelContainer[3].iLabel->SetTextL(KDefaultText);
} else {
iLabelContainer[2].iLabel->SetTextL(rightText);
iLabelContainer[2].iLabel->CropText();
iLabelContainer[3].iLabel->SetTextL(aThirdText);
iLabelContainer[3].iLabel->CropText();
}
} else {
// WrapToStringL didnt add a newline (we dont need to wrap) but it
// seems WrapToStringL always adds newline (see above comment).
iLabelContainer[1].iLabel->SetTextL(aSecondText);
iLabelContainer[2].iLabel->SetTextL(aThirdText);
iLabelContainer[2].iLabel->CropText();
iLabelContainer[3].iLabel->SetTextL(KDefaultText);
}
//iLabel->SetRect(iLabelRect);
//iLabel->DrawDeferred();
}
示例5: ParagraphEnd
/**
Return the end of the paragraph - after the paragraph separator if any.
*/
EXPORT_C TInt MTmSource::ParagraphEnd(TInt aPos) const
{
TInt doc_end = DocumentLength();
TPtrC text;
TTmCharFormat format;
while (aPos < doc_end)
{
GetText(aPos,text,format);
const TText *p = text.Ptr();
const TText *q = p + text.Length();
while (p < q)
if (*p == CEditableText::EParagraphDelimiter)
return aPos + 1;
else
{
p++;
aPos++;
}
}
return doc_end + 1;
}
示例6: ColumnText
/**
Copies the content of a text column, identified by aColumnIndex, to the place refered by aDest parameter.
If the destination buffer is not big enough, the function will copy as much data as possible and will
return KErrOverflow.
@param aColumnIndex Column index
@param aDest Refers to the place where the column data will be copied.
@return KErrNone, if the function completes successfully,
otherwise one of the other system-wide error codes.
@panic SqlDb 5 Column index out of bounds.
@panic SqlDb 11 Statement cursor not positioned on a row
*/
TInt CSqlStatementImpl::ColumnText(TInt aColumnIndex, TDes& aDest)
{
__ASSERT_ALWAYS((TUint)aColumnIndex < (TUint)iColumnCnt, __SQLPANIC(ESqlPanicBadColumnIndex));
__ASSERT_ALWAYS(iState == CSqlStatementImpl::EAtRow, __SQLPANIC(ESqlPanicInvalidRow));
iColumnValBufIt.MoveTo(aColumnIndex);
TInt err = KErrNone;
//The text column value has not been transferred to the client side if its length is >= KSqlMaxDesLen characters.
//In this case an additional call to the server is made to get the column value.
if(!iColumnValBufIt.IsPresent())
{
if(iColumnValBufIt.Type() != ESqlText)
{
aDest.Zero();
return err;
}
TPtr8 ptr(reinterpret_cast <TUint8*> (const_cast <TUint16*> (aDest.Ptr())), aDest.MaxLength() * sizeof(TUint16));
err = iSqlStmtSession.ReadColumnValue(aColumnIndex, ptr);
switch(err)
{
case KErrNone:
case KErrOverflow:
aDest.SetLength(ptr.Length() / sizeof(TUint16));
break;
default:
break;
}
}
else
{
TPtrC src = iColumnValBufIt.Text();
TInt len = src.Length();
if(len > aDest.MaxLength())
{
len = aDest.MaxLength();
err = KErrOverflow;
}
aDest.Copy(src.Ptr(), len);
}
return err;
}
示例7: FieldEnd
// ---------------------------------------------------------
// CMailToHandler::FieldEnd()
// ---------------------------------------------------------
//
TInt CMailToHandler::FieldEnd(const TDesC& aHeader)
{
CLOG_ENTERFN( "CMailToHandler::FieldEnd()" );
TPtrC path = iParsedUrl->Des();
TInt length = path.Length(); // length of the scheme
TInt retVal = length;
TInt startPos = FieldStart( aHeader );
if( IsHeader( aHeader ) )
{
TInt temp = GetNextField( startPos );
/* we need to subtract 1 if the result is
not equal to length because of the & or ? */
retVal = ( temp == length ) ? length : ( temp - 1);
}
CLOG_LEAVEFN( "CMailToHandler::FieldEnd()" );
return retVal;
}
示例8: ProcessL
TInt CCmdExit::ProcessL(const TDesC &aCommand)
{
// Complete the test machine - will then get the next cmd
Machine()->CompleteRequest();
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());
// Print out param if any and stop.
param.Set( TfrLex::Peel(param));
if (param.Length() > 0)
Print(param);
Machine()->StopEngine();
return error;
}
示例9: ComparisonForVariousCharsetsL
/** Compare the various character sets
@test
*/
void CTestHtmlToCrtConverterBufferStep::ComparisonForVariousCharsetsL()
{
// Get different character sets from the ini file
TPtrC sourceData;
GetStringFromConfig(ConfigSection(), KSourceText, sourceData);
HBufC8* tempSource = HBufC8::NewLC(sourceData.Length());
tempSource->Des().Copy(sourceData);
TPtr8 source(tempSource->Des());
// Compare the source text with the text converted by the characterset converter
if ( DoComparisonL(source) == 0 )
{
INFO_PRINTF1(KInfoComparisionSuccessful);
}
else
{
ERR_PRINTF1(KErrInComparison);
SetTestStepResult(EFail);
}
CleanupStack::PopAndDestroy(tempSource);
}
示例10: FormatListItemLC
// -----------------------------------------------------------------------------
// CLandmarksModel::FormatListItemLC
// Formats a list item to the following format "X\tlandmarkName\t"
// where X = icon index
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
HBufC* CLandmarksModel::FormatListItemLC(CPosLandmark& aLandmark)
{
// Extract name
TPtrC name;
aLandmark.GetLandmarkName(name);
// 10 extra chars for icon index and column separator
const TInt KExtraChars = 10;
HBufC* formattedNameBuf = HBufC::NewLC(name.Length() + KExtraChars);
TPtr formattedNamePtr = formattedNameBuf->Des();
// Extract icon info
TPtrC mbmIconFile;
TInt iconIndex, maskIndex;
TInt res = aLandmark.GetIcon(mbmIconFile, iconIndex, maskIndex);
// Format list item
if (res == KErrNone)
{
// Create icon and append it to icon array.
TRAPD(err, AppendIconL(mbmIconFile, iconIndex, maskIndex));
if (err == KErrNone)
{
// Append the array index where the icon is appended
formattedNamePtr.AppendNum(iIconList->Count() - 1);
}
else
{
formattedNamePtr.AppendNum(KDefaultIconIndex);
}
}
else // res == KErrNotFound
{
formattedNamePtr.AppendNum(KDefaultIconIndex);
}
formattedNamePtr.Append(KTab);
formattedNamePtr.Append(name);
return formattedNameBuf;
}
示例11: GetParameterCountL
// ---------------------------------------------------------
// CWtaiHandler::GetParameterCountL()
// ---------------------------------------------------------
//
TInt CWtaiHandler::GetParameterCountL()
{
CLOG_ENTERFN( "CWtaiHandler::GetParameterCount()" );
// wtai://<library>/<function> (; <parameter>)*
TInt retVal = 0;
TPtrC path = RemoveSchemeFromUrlL( KWtai );
TInt length = path.Length();
/* Count for the amount of parameter */
for( TInt i = 0; i < length; i++ )
{
if( path[i] == KSemiColon )
{
retVal++;
}
}
CLOG_LEAVEFN( "CWtaiHandler::GetParameterCount()" );
return retVal;
}
示例12: main
int main()
{
int retval =ESuccess;
wchar_t* mywcharstring = L"Hello Widechar String";
int wchar_length= wcslen(mywcharstring);
TPtrC myTptrc;
retval = WcharpToTptrc16(mywcharstring, myTptrc);
int buf_len = myTptrc.Length();
if (retval ==ESuccess &&\
wchar_length == buf_len )
{
printf("wcharptotptrc16 boundary1 Passed\n");
}
else
{
assert_failed = true;
printf("wcharptotptrc16 boundary1 Failed\n");
}
testResultXml("test_wcharptotptrc16_boundary1");
return 0;
}
示例13: GetDeviceUiNameL
// ---------------------------------------------------------------------------
// If aDevExt contains a valid friendly name, the friendly name will be displayed;
// Otherwise, if the given name from the parameter of a notifier request is valid,
// the given name will be displayed;
// Otherwise, If aDevExt contains a valid device name, the name will be displayed;
// Otherwise, the a name will be created by this function.
// ---------------------------------------------------------------------------
//
void TBTNotifUtil::GetDeviceUiNameL( TDes& aNameBuf,
const CBtDevExtension* aDevExt,
const TDesC& aNameInParam,
const TBTDevAddr& aAddr)
{
CBtDevExtension* tempDev( NULL );
TPtrC namePtr;
if ( aDevExt &&
aDevExt->Device().IsValidFriendlyName() &&
aDevExt->Device().FriendlyName().Length() != 0 )
{
// We always use the friendly name regardless of
// the device-name of the device is available or not.
namePtr.Set( aDevExt->Device().FriendlyName() );
}
else
{
// this will take care of name formating. Either the
// name from iNameInParam or the address will be
// the alias:
tempDev = CBtDevExtension::NewLC( aAddr, aNameInParam );
namePtr.Set( tempDev->Alias() );
}
// Make sure no overflow:
if ( aNameBuf.MaxLength() < namePtr.Length() )
{
aNameBuf.Copy( namePtr.Left( aNameBuf.MaxLength() ) );
}
else
{
aNameBuf.Copy( namePtr );
}
if ( tempDev )
{
CleanupStack::PopAndDestroy( tempDev );
}
}
示例14: SetItemsL
// Set grid items from a resource
void CSendGrid::SetItemsL(TInt aResourceId) {
// Clear previous items if we already have an item array, otherwise create
// it
if ( iItemArray ) {
iGrid->SetCurrentItemIndex(0);
iItemArray->Reset();
iGrid->HandleItemRemovalL();
} else {
iItemArray = new (ELeave) CDesCArrayFlat(12);
iGrid->Model()->SetItemTextArray(iItemArray);
}
// Read items from the resource file
TResourceReader reader;
CCoeEnv::Static()->CreateResourceReaderLC(reader, aResourceId);
TInt count = reader.ReadInt16();
__ASSERT_ALWAYS(count == KSendGridNumItems,
User::Panic(KPanic, KPanicBadResource));
for ( TInt i = 0; i < count; i++ ) {
iCommands[i] = reader.ReadInt32();
iSubGrids[i] = reader.ReadInt32();
TBuf<32> buf;
buf.Append('\t');
buf.Append(KGridItemLabels[i]);
buf.Append('\t');
TPtrC ptr = reader.ReadTPtrC();
__ASSERT_ALWAYS(ptr.Length() <= 30,
User::Panic(KPanic, KPanicBadResource));
buf.Append(ptr);
iItemArray->AppendL(buf);
}
CleanupStack::PopAndDestroy(); // reader
iGrid->HandleItemAdditionL();
iGrid->SetCurrentItemIndex(0);
iCurrentGrid = aResourceId;
}
示例15: CloseL
/**
* See JNI method __1close.
* This is an internal wrapper method for handling Leaves.
*/
jint CloseL(JNIEnv *aEnv, jclass aClass, jint aHandle, jobject aOutputFilename)
{
// Convert handle to pointer.
CImportFile *file = reinterpret_cast<CImportFile*>(aHandle<<2);
// Complete writing and get output filename from the agent.
TInt err = file->WriteDataComplete();
// Initialize output filename to aOutputFilename parameter.
if (KErrNone == err)
{
// Get class handle to StringBuffer
aClass = aEnv->GetObjectClass(aOutputFilename);
// Get method ID to StringBuffer StringBuffer.append(String)
jmethodID methodID = aEnv->GetMethodID(
aClass, "append", "(Ljava/lang/String;)Ljava/lang/StringBuffer;");
if (0 == methodID)
{
ELOG(EJavaInstaller,
"FileWriter__1close: StringBuffer.append not found");
err = KErrGeneral;
}
else
{
CSupplierOutputFile &output = file->OutputFileL(0);
TPtrC outputFilename = output.FileName();
// Create new Java String.
jstring jOutputFilename =
aEnv->NewString(outputFilename.Ptr(), outputFilename.Length());
aEnv->CallObjectMethod(aOutputFilename, methodID, jOutputFilename);
}
}
// Delete the CImportFile instance which is no longer used.
delete file;
return err;
}