examples/SysLibs/CommonFramework/CommonToDBMSEx.h

00001 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
00002 // All rights reserved.
00003 // This component and the accompanying materials are made available
00004 // under the terms of "Eclipse Public License v1.0"
00005 // which accompanies this distribution, and is available
00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
00007 //
00008 // Initial Contributors:
00009 // Nokia Corporation - initial contribution.
00010 //
00011 // Contributors:
00012 //
00013 // Description:
00014 // DBSTD.H
00015 //
00016 
00017 #ifndef __DBSTD_H
00018 #define __DBSTD_H
00019 
00020 #include <e32cons.h>
00021 #include <s32file.h>
00022 #include <d32dbms.h>
00023 
00024 // public
00025 LOCAL_D CConsoleBase* console; // write all your messages to this
00026 LOCAL_C void doExampleL(); // code this function for the real example
00027 LOCAL_D RFs fsSession;
00028 
00029 // private
00030 LOCAL_C void callExampleL(); // initialize with cleanup stack, then do example
00031 
00032 GLDEF_C TInt E32Main() // main function called by E32
00033     {
00034         _LIT(KDbmsExample,"DBMS-Example");
00035         CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack
00036         TRAPD(error,callExampleL()); // more initialization, then do example
00037         __ASSERT_ALWAYS(!error,User::Panic(KDbmsExample,error));
00038         delete cleanup; // destroy clean-up stack
00039         return 0; // and return
00040     }
00041 
00042 LOCAL_C void callExampleL() // initialize and call example code under cleanup stack
00043     {
00044         _LIT(KDbmsSdkExampleCode,"DBMS SDK Example Code");
00045         _LIT(KFileSessionConnectFailed,"file session connect failed: return code=%d");
00046         _LIT(KFailed,"failed: leave code=%d");
00047         _LIT(KOk,"ok");
00048         _LIT(KPressAnyKey," [press any key]");
00049 
00050         console=Console::NewL(KDbmsSdkExampleCode,
00051                 TSize(KConsFullScreen,KConsFullScreen));
00052         CleanupStack::PushL(console);
00053         TInt fsret = fsSession.Connect(); // start a file session
00054         if (fsret != KErrNone)
00055                 {
00056                 console->Printf(KFileSessionConnectFailed,fsret);
00057                 User::Leave(fsret);
00058                 }
00059         TRAPD(error,doExampleL()); // perform example function
00060         if (error) console->Printf(KFailed, error);
00061         else console->Printf(KOk);
00062         console->Printf(KPressAnyKey);
00063         console->Getch(); // get and ignore character
00064         fsSession.Close(); // close the file session
00065         CleanupStack::Pop(); // close console
00066     }
00067 
00068 #endif

Generated by  doxygen 1.6.2