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