|
1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __EUSTD_H |
|
17 #define __EUSTD_H |
|
18 |
|
19 #include <e32cons.h> |
|
20 |
|
21 // public |
|
22 LOCAL_D CConsoleBase* console; // write all your messages to this |
|
23 LOCAL_C void doExampleL(); // code this function for the real example |
|
24 |
|
25 // private |
|
26 LOCAL_C void callExampleL(); // initialize with cleanup stack, then do example |
|
27 |
|
28 GLDEF_C TInt E32Main() // main function called by E32 |
|
29 { |
|
30 CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack |
|
31 TRAPD(error,callExampleL()); // more initialization, then do example |
|
32 __ASSERT_ALWAYS(!error,User::Panic(_L("EPOC32EX"),error)); |
|
33 delete cleanup; // destroy clean-up stack |
|
34 return 0; // and return |
|
35 } |
|
36 |
|
37 LOCAL_C void callExampleL() // initialize and call example code under cleanup stack |
|
38 { |
|
39 console=Console::NewL(_L("EPOC/32 SDK Example Code"), |
|
40 TSize(KDefaultConsWidth,KDefaultConsHeight)); |
|
41 console->Printf(_L("Created console\n")); |
|
42 CleanupStack::PushL(console); |
|
43 |
|
44 TRAPD(error,doExampleL()); // perform example function |
|
45 console->Printf(_L("Backf from doExample error %d\n"), error); |
|
46 if (error) console->Printf(_L("failed: leave code=%d"), error); |
|
47 else console->Printf(_L("ok")); |
|
48 console->Printf(_L(" [press any key]\n")); |
|
49 console->Getch(); // get and ignore character |
|
50 CleanupStack::Pop(); // close console |
|
51 } |
|
52 |
|
53 #endif |