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