00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <e32base.h>
00020 #include <e32cons.h>
00021 #include <NumberStore.h>
00022
00023 _LIT(KHello,"Hello World!\r\n");
00024 _LIT(KTxtEPOC32EX,"EPOC32EX");
00025 _LIT(KTxtExampleCode,"Symbian platform Example Code");
00026 _LIT(KFormatFailed,"failed: leave code=%d");
00027 _LIT(KTxtOK,"ok");
00028 _LIT(KTxtPressAnyKey," [press any key]");
00029
00030 LOCAL_D CConsoleBase* console;
00031 LOCAL_C void callExampleL();
00032 LOCAL_C void doExampleL();
00033
00034 GLDEF_C TInt E32Main()
00035 {
00036 __UHEAP_MARK;
00037 CTrapCleanup* cleanup=CTrapCleanup::New();
00038 TRAPD(error,callExampleL());
00039 __ASSERT_ALWAYS(!error,User::Panic(KTxtEPOC32EX,error));
00040 delete cleanup;
00041 __UHEAP_MARKEND;
00042 return 0;
00043 }
00044
00045 LOCAL_C void callExampleL()
00046 {
00047 console=Console::NewL(KTxtExampleCode,TSize(KConsFullScreen,KConsFullScreen));
00048 CleanupStack::PushL(console);
00049 TRAPD(error,doExampleL());
00050 if (error)
00051 console->Printf(KFormatFailed, error);
00052 else
00053 console->Printf(KTxtOK);
00054 console->Printf(KTxtPressAnyKey);
00055 console->Getch();
00056 CleanupStack::PopAndDestroy();
00057 }
00058
00059 LOCAL_C void doExampleL()
00060 {
00061 console->Printf(KHello);
00062 TInt num1=3;
00063 TInt num2=7;
00064
00065
00066 CNumberStore* numberstore=new (ELeave) CNumberStore();
00067 numberstore->SetNumber1(num1);
00068 numberstore->SetNumber2(num2);
00069 console->Printf(_L("Created CNumberStore with values %d & %d\n"),num1,num2);
00070 num1=numberstore->Number1();
00071 num2=numberstore->Number2();
00072 console->Printf(_L("CNumberStore has values %d & %d\n"),num1,num2);
00073
00074 TInt total=-1;
00075 TInt product=-1;
00076
00077
00078
00079
00080 total=numberstore->AddNumbers();
00081
00082
00083
00084
00085
00086 product=numberstore->MultiplyNumbers();
00087
00088 console->Printf(_L("CNumberStore extension gives total %d\n"),total);
00089 console->Printf(_L("CNumberStore extension gives product with magic multiplyer %d\n"),product);
00090
00091
00092 delete numberstore;
00093 }