本文整理汇总了C++中TBuf16::Length方法的典型用法代码示例。如果您正苦于以下问题:C++ TBuf16::Length方法的具体用法?C++ TBuf16::Length怎么用?C++ TBuf16::Length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TBuf16
的用法示例。
在下文中一共展示了TBuf16::Length方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExecuteL
// From MTest:
void CTestCase::ExecuteL (TTestResult& aResult)
{
TInt error = ExecuteImplL();
aResult.iResult = error;
// add the possible failure or error to the result
if (error == KErrCppUnitAssertionFailed)
{
CAssertFailure* assertFailure = AssertFailureFromTlsL ();
CleanupStack::PushL(assertFailure);
TBuf16 <0x80> convertBuf;
TBuf16 <256> temporaryBuf;
convertBuf.Copy(assertFailure->What());
temporaryBuf.Append(convertBuf);
temporaryBuf.AppendFormat(_L(" at Line %i of "), assertFailure->LineNumber());
convertBuf.Copy(assertFailure->FileName());
if (convertBuf.Length() + temporaryBuf.Length() >= 0x80)
{
TBuf <0x80> printBuf;
printBuf = convertBuf.Right(0x80 - temporaryBuf.Length() - 1 -3 );
convertBuf = _L("...");
convertBuf.Append(printBuf);
}
temporaryBuf.Append(convertBuf);
aResult.iResultDes = temporaryBuf;
CleanupStack::PopAndDestroy(assertFailure);
}
}
示例2: QueryIPAddress
//*******************************************************************************
// Method : CTestAppConsole::QueryIPAddress()
// Purpose :
// Parameters :
// Return Value:
//*******************************************************************************
void CTestAppConsole::QueryIPAddress()
{
TBuf16<80> line;
// Query IP address and parse it
TUint32 address;
RArray<TUint32> values;
TInt inputErr( 0 );
iConsole->Printf( _L("\nINPUT IP (use dot as a separator): ") );
iConsole->Printf( _L("\nPress enter if IP not needed in tests\n\n") );
GetStringFromConsole( line );
if ( line.Length() != 0 )
{
TInt dotIndex( 0 );
TBool dotExist = ETrue;
while ( dotExist )
{
dotIndex = line.Locate( '.' );
// True if last attribute value
if( KErrNotFound == dotIndex )
{
dotExist = EFalse;
dotIndex = line.Length();
}
TUint8 number;
TLex16 lex = line.Mid( 0, dotIndex );
inputErr = lex.Val( number, EDecimal );
if ( !inputErr )
{
values.AppendL( number );
}
if( dotExist )
{
line.Delete( 0, dotIndex + 1 );
}
}
if ( !inputErr && values.Count() == 4 )
{
address = INET_ADDR( values[0], values[1], values[2], values[3] );
iNetsettings.iRemoteAddress.SetAddress( address );
}
}
}
示例3: ConvertUtfToUnicodeL
HBufC* CPluginUtils::ConvertUtfToUnicodeL( const TDesC8& aUtf7 )
{
RBuf output;
CleanupClosePushL( output );
TBuf16<20> outputBuffer;
TPtrC8 remainderOfUtf7( aUtf7 );
for(;;)
{
const TInt returnValue = CnvUtfConverter::ConvertToUnicodeFromUtf8(outputBuffer, remainderOfUtf7);
if (returnValue==CnvUtfConverter::EErrorIllFormedInput)
return NULL;
else if (returnValue<0)
return NULL;
output.ReAllocL( output.Length() + outputBuffer.Length() );
output.Append( outputBuffer );
if (returnValue == 0)
break;
remainderOfUtf7.Set(remainderOfUtf7.Right(returnValue));
}
HBufC* ret = output.AllocL();
CleanupStack::PopAndDestroy( &output );
return ret;
}
示例4: SetEmergencyNumber
void CAknEcsNote::SetEmergencyNumber( const TDesC& aMatchedNumber )
{
TRect screen(iAvkonAppUi->ApplicationRect());
TAknLayoutRect mainPane;
mainPane.LayoutRect(screen, AKN_LAYOUT_WINDOW_main_pane(screen, 0, 1, 1));
TAknLayoutRect popupNoteWindow;
AknLayoutUtils::TAknCbaLocation cbaLocation( AknLayoutUtils::CbaLocation() );
TInt variety( 0 );
if ( cbaLocation == AknLayoutUtils::EAknCbaLocationRight )
{
variety = 5;
}
else if ( cbaLocation == AknLayoutUtils::EAknCbaLocationLeft )
{
variety = 8;
}
else
{
variety = 2;
}
popupNoteWindow.LayoutRect(mainPane.Rect(), AknLayoutScalable_Avkon::popup_note_window( variety ));
TAknLayoutText textRect;
textRect.LayoutText(popupNoteWindow.Rect(), AKN_LAYOUT_TEXT_Note_pop_up_window_texts_Line_1(4));
// Size of a temporary buffer that contains new lines, spaces and
// emergency number for a note.
TBuf16<KAknEcsMaxMatchingLength+80> number;
number.Append('\n');
number.Append('\n');
TInt spaceCharWidthInPixels = textRect.Font()->CharWidthInPixels(' ');
if (spaceCharWidthInPixels < 1)
{
// Avoid divide by zero situation even the space char would have zero length.
spaceCharWidthInPixels = 1;
}
TInt length = (textRect.TextRect().Width() - textRect.Font()->TextWidthInPixels(aMatchedNumber))
/ spaceCharWidthInPixels;
const TInt matchedNumberLength = aMatchedNumber.Length();
const TInt numberLength = number.Length();
const TInt numberMaxLength = number.MaxLength();
if ( numberLength + length + matchedNumberLength > numberMaxLength)
{
// To make sure that buffer overflow does not happen.
length = numberMaxLength - numberLength - matchedNumberLength;
}
for (int i = 0; i < length ; i++)
{
number.Append(' ');
}
number.Append(aMatchedNumber);
TRAP_IGNORE(SetTextL(number));
}
示例5: wstring
/**
* Returns bluetooth friendly name
* Output: bluetooth friendly name
*/
std::wstring *S60BluetoothPlatformControl::getBluetoothName()
{
TBuf16<KMaxBluetoothNameLen> bluetoothName;
JELOG2(EJavaBluetooth);
TInt error = RProperty::Get(KPropertyUidBluetoothCategory,
KPropertyKeyBluetoothGetDeviceName, bluetoothName);
if (error != KErrNone || (0 == bluetoothName.Length()))
{
ELOG(EJavaBluetooth, "Bluetooth friendly name was not set");
return NULL;
}
std::wstring *deviceName =
new std::wstring((wchar_t*) bluetoothName.Ptr());
deviceName->resize(bluetoothName.Length());
return deviceName;
}
示例6: lex
GLDEF_C TInt E32Main()
{
TBuf16<512> cmd;
User::CommandLine(cmd);
if(cmd.Length() && TChar(cmd[0]).IsDigit())
{
TInt function = -1;
TInt arg1 = -1;
TInt arg2 = -1;
TLex lex(cmd);
lex.Val(function);
lex.SkipSpace();
lex.Val(arg1);
lex.SkipSpace();
lex.Val(arg2);
return DoTestProcess(function,arg1,arg2);
}
test.Title();
if((!PlatSec::ConfigSetting(PlatSec::EPlatSecProcessIsolation))||(!PlatSec::ConfigSetting(PlatSec::EPlatSecEnforcement)))
{
test.Start(_L("TESTS NOT RUN - PlatSecProcessIsolation is not enforced"));
test.End();
return 0;
}
test(SyncMutex.CreateGlobal(KSyncMutext)==KErrNone);
test.Start(_L("Test SetJustInTime"));
TestSetJustInTime();
test.Next(_L("Test Rename"));
TestRename();
test.Next(_L("Test Kill, Panic and Teminate"));
TestKill();
test.Next(_L("Test Resume"));
TestResume();
test.Next(_L("Test SetPriority"));
TestSetPriority();
SyncMutex.Close();
test.End();
return(0);
}
示例7: ptr
void CDebugLogPrint::WriteToLog8L(const TDesC8 &aDes, const TDesC8 &aDes2)
{
TBuf16<256> buf;
TInt pos=aDes.LocateReverse(' ');
if (pos<0)
pos=0;
buf.Copy(aDes.Mid(pos));
buf.Append(' ');
TInt bufLen=buf.Length();
TPtr16 ptr(&buf[bufLen],buf.MaxLength()-bufLen);
ptr.Copy(aDes2);
buf.SetLength(bufLen+aDes2.Length());
_LIT(KDebugFormatString, "%S");
RDebug::Print(KDebugFormatString, &buf);
}
示例8: QueryNetworkSettings
//*******************************************************************************
// Method : CTestAppConsole::QueryNetworkSettings()
// Purpose :
// Parameters :
// Return Value:
//*******************************************************************************
void CTestAppConsole::QueryNetworkSettings()
{
TBuf16<80> line;
iConsole->Printf( _L("\nQUERYING NETWORK SETTINGS") );
iConsole->Printf( _L("\nPress enter to use existing value") );
TUint iap( KTestIapId );
TInt inputErr( 0 );
do
{
iConsole->Printf( _L("\nINPUT IAPID: ") );
GetStringFromConsole( line );
if ( line.Length() != 0 )
{
TLex lex( line );
inputErr = lex.Val( iap );
}
} while ( inputErr );
iNetsettings.iIapId = iap;
}
示例9: main
int main()
{
__UHEAP_MARK;
int retval =ESuccess;
wchar_t* mywcharstring = L"Hello Widechar String";
int wchar_length= wcslen(mywcharstring);
TBuf16 <42> myBuffer;
retval = WcharToTbuf16 (mywcharstring, myBuffer);
int buf_len = myBuffer.Length();
if (retval ==ESuccess && wchar_length == buf_len && buf_len == 21 )
{
printf("wchartotbuf16 boundary2 Passed\n");
}
else
{
assert_failed = true;
printf("wchartotbuf16 boundary2 Failed\n");
}
__UHEAP_MARKEND;
testResultXml("test_wchartotbuf16_boundary2");
}
示例10: lex
GLDEF_C TInt E32Main()
{
TBuf16<512> cmd;
User::CommandLine(cmd);
if(cmd.Length() && TChar(cmd[0]).IsDigit())
{
TInt function = -1;
TInt arg1 = -1;
TInt arg2 = -1;
TLex lex(cmd);
lex.Val(function);
lex.SkipSpace();
lex.Val(arg1);
lex.SkipSpace();
lex.Val(arg2);
return DoTestProcess(function,arg1,arg2);
}
MemModelAttributes=UserSvr::HalFunction(EHalGroupKernel, EKernelHalMemModelInfo, NULL, NULL);
TUint mm=MemModelAttributes&EMemModelTypeMask;
PhysicalCommitSupported = mm!=EMemModelTypeDirect && mm!=EMemModelTypeEmul;
// Turn off lazy dll unloading
RLoader l;
test(l.Connect()==KErrNone);
test(l.CancelLazyDllUnload()==KErrNone);
l.Close();
test.Title();
#if defined(__FIXED__) || defined(__SECOND_FIXED__) || defined(__MOVING_FIXED__)
if(mm!=EMemModelTypeMoving)
{
test.Printf(_L("TESTS NOT RUN - Only applicable to moving memory model\r\n"));
return 0;
}
#endif
test.Start(_L("Loading test driver..."));
TInt r;
r=User::LoadLogicalDevice(KSharedIoTestLddName);
test(r==KErrNone || r==KErrAlreadyExists);
r=User::LoadLogicalDevice(KSharedIoTestLddName);
test(r==KErrAlreadyExists);
r=ldd.Open();
test(r==KErrNone);
TAny* buffer;
TUint32 size;
TUint32 key;
TInt testBufferSize=0;
for(; TestBufferSizes[testBufferSize]!=0; ++testBufferSize)
{
test.Printf(_L("Test buffer size = %08x\n"),TestBufferSizes[testBufferSize]);
test.Next(_L("Create buffer"));
r=ldd.CreateBuffer(TestBufferSizes[testBufferSize]);
if(r!=KErrNone)
test.Printf(_L("Creating buffer failed client r=%d"), r);
test(r==KErrNone);
test.Next(_L("Map In Buffer"));
r=ldd.MapInBuffer(&buffer,&size);
test.Next(_L("CheckBuffer"));
test(CheckBuffer(buffer,size));
test(r==KErrNone);
test.Next(_L("Fill and check shared buffer"));
key=Math::Random();
fillBuffer(buffer,size,key);
test(ldd.CheckBuffer(key)==KErrNone);
key=Math::Random();
test(ldd.FillBuffer(key)==KErrNone);
test(checkBuffer(buffer,size,key)==KErrNone);
test.Next(_L("Map Out Buffer"));
r=ldd.MapOutBuffer();
test(r==KErrNone);
test.Next(_L("Destroy Buffer"));
r=ldd.DestroyBuffer();
test(r==KErrNone);
test.Next(_L("Create a buffer under OOM conditions"));
CreateWithOOMCheck(TestBufferSizes[testBufferSize], EFalse);
if(PhysicalCommitSupported)
{
test.Next(_L("Create a buffer with a physical address under OOM conditions"));
CreateWithOOMCheck(TestBufferSizes[testBufferSize], ETrue);
test.Next(_L("Create a buffer with a physical address"));
r=ldd.CreateBufferPhysAddr(0x1000);
test(r==KErrNone);
test.Next(_L("Map In physical address Buffer"));
r=ldd.MapInBuffer(&buffer,&size);
//.........这里部分代码省略.........
示例11: GetAnEntry
EXPORT_C void CIpuTestHarness::GetAnEntry(const TDesC& ourPrompt, TDes& currentstring)
//
// Get an input string from the user, displaying a supplied prompt and default string value
{
// If we're scripting, try reading from script first
TInt readScriptErr = KErrNotFound;
if (iScriptRunning)
{
readScriptErr = ReadLineFromScript(currentstring);
}
if (!readScriptErr)
return;
// Either not scripting, or hit end of script - continue with user input
TBuf16<KMaxUserEntrySize> ourLine;
TBuf<KMaxUserEntrySize> tempstring; //tempstring is a unicode descriptor
//create a temporary buffer where the
//unicode strings are stored in order to
//be displayed
ourLine.Zero ();
tempstring.Copy(currentstring); //Copy current string to Unicode buffer
TKeyCode key = EKeyNull; //current string buffer is 8 bits wide.
//Unicode string bufffer (tempstring) is 16 bits wide.
for (;;)
{
if (ourLine.Length () == 0)
{
iTest.Console()->SetPos (0, iTest.Console()->WhereY ());
iTest.Console()->Printf (_L ("%S"), &ourPrompt);
if (tempstring.Length () != 0) //get tempstring's number of items
iTest.Console()->Printf (_L (" = %S"), &tempstring); //if not zero print them to iTest.Console()
iTest.Console()->Printf (_L (" : "));
iTest.Console()->ClearToEndOfLine ();
}
key = iTest.Getch();
if (key == EKeyBackspace)
{
if (ourLine.Length() !=0)
{
ourLine.SetLength(ourLine.Length()-1);
iTest.Console()->Printf (_L ("%c"), key);
iTest.Console()->SetPos(iTest.Console()->WhereX(),iTest.Console()->WhereY());
iTest.Console()->ClearToEndOfLine();
} // end if (ourLine.Length() !=0)
} // end if (key == KeyBackSpace)
if (key == EKeyDelete)
{
ourLine.Zero();
iTest.Console()->SetPos (0, iTest.Console()->WhereY ());
iTest.Console()->ClearToEndOfLine ();
tempstring.Copy(ourLine);
break;
}
if (key == EKeyEnter)
break;
if (key < 32)
{
continue;
}
ourLine.Append (key);
iTest.Console()->Printf (_L ("%c"), key);
iTest.Console()->SetPos(iTest.Console()->WhereX(),iTest.Console()->WhereY());
iTest.Console()->ClearToEndOfLine();
if (ourLine.Length () == ourLine.MaxLength ())
break;
} // end of for statement
if ((key == EKeyEnter) && (ourLine.Length () == 0))
tempstring.Copy (currentstring); //copy contents of 8 bit "ourLine" descriptor
iTest.Console()->SetPos (0, iTest.Console()->WhereY ());
iTest.Console()->ClearToEndOfLine ();
iTest.Console()->Printf (_L ("%S"), &ourPrompt);
if ((key == EKeyEnter) && (ourLine.Length() !=0))
tempstring.Copy(ourLine);
if (tempstring.Length () != 0) //if temstring length is not zero
{
iTest.Console()->Printf (_L (" = %S\n"), &tempstring); //print the contents to iTest.Console()
LogIt(_L ("%S = %S\n"), &ourPrompt, &tempstring);
}
else
//iTest.Console()->Printf (_L (" is empty"));
iTest.Console()->Printf (_L ("\n"));
currentstring.Copy(tempstring); //copy 16 bit tempstring descriptor back
}