www.pudn.com > symbianex.rar   To Read all the content


[file head]:
// TBufAndTBufC.cpp
//
// Copyright (c) 2005 CCNIIT. All rights reserved.

// author: hewei
// copyright 1.0
// Date: 2005-10-14

// Example shows attempt to use TBuf and TBufC
// NOTE: the structure of this example is different to standard E32 examples


#include <e32cons.h>

// All messages written to this
LOCAL_D CConsoleBase* console;
const TInt KMAXLENGTH=20;
// Function prototypes
void callExampleL();
void doExampleL();
void useTBuf();
void useTBufC();
//////////////////////////////////////////////////////////////////////////////
//
//use TBuf in useTBuf function
//
//////////////////////////////////////////////////////////////////////////////
void useTBuf()
{
_LIT(KNEWLINE,"\n");
_LIT(KFIRST,"hello");
_LIT(KSECOND," world!");
_LIT(KHEWEI,"hewei!");

TBuf<KMAXLENGTH> buf(KFIRST);//object of TBuf;

// print TBuf
console->Printf(buf);
console->Printf(KNEWLINE);
//Append another string to buf
buf.Append(KSECOND
... ...

[file tail]:
... ...
////////////////////////////////////////////////////////////////////
void doExampleL()
{
//Get Console;
_LIT(KMsgExampleCode,"Symbian OS Example Code");
console = Console::NewL(KMsgExampleCode,TSize(KConsFullScreen,KConsFullScreen));
// Put console onto the cleanup stack.
CleanupStack::PushL(console);

int error;
TRAP(error,callExampleL());
//TRAPD(error,callExampleL());
if(error)
{
_LIT(KERROR,"error occured!\n");
console->Printf(KERROR);

}
else{
_LIT(KNOLEAVE,"No Leave!\n");
console->Printf(KNOLEAVE);
}
console->Getch();
// Remove the console object from the cleanupstack
// and destroy it.
CleanupStack::PopAndDestroy();
}

void callExampleL()
{
useTBuf();
console->Getch();
useTBufC();
}


//////////////////////////////////////////////////////////////////////////////
//
// Do the example
//
//////////////////////////////////////////////////////////////////////////////