examples/Base/ArraysAndLists/linkedlist/dbllist/src/dbllist.cpp

Go to the documentation of this file.
00001 // Copyright (c) 2008-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 // Contains the E32Main() function, which executes the example.
00015 // The example demonstrates the use of the TDblQue class, which represents
00016 // a doubly linked list.
00017 // The user enters a string, which is stored as linked list of characters
00018 // of the string. The user can edit this string by adding characters to the
00019 // string.
00020 // The example displays the reverse of this string on the console.
00021 //
00022 
00023 
00024 
00029 #include "mystringreverse.h"
00030 
00031 LOCAL_D CConsoleBase* console;
00032 
00033 LOCAL_C void DoStartL();
00034 LOCAL_C void CallExampleL();
00035 
00036 LOCAL_C void DoStartL()
00037         {
00038         // Create and install the active scheduler.
00039         CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
00040         CleanupStack::PushL(scheduler);
00041         CActiveScheduler::Install(scheduler);
00042 
00043         _LIT(KTextDbllist,"Double Linked List Demo\nEnter the characters of the string\n");
00044         console->Printf(KTextDbllist);
00045         // Create an object of the CMyStringReverse class.
00046         CMyStringReverse* stringreverse = CMyStringReverse::NewL(console);
00047         CleanupStack::PushL(stringreverse);
00048 
00049         // Read the string from the user.
00050         // Generate an asynchronous read request.
00051         stringreverse->ReadOption();
00052 
00053         // Start the active scheduler.
00054         CActiveScheduler::Start();
00055 
00056         // Destroy the objects in the cleanup stack.
00057         CleanupStack::PopAndDestroy(2, scheduler); // stringreverse, scheduler.
00058         }
00059 
00060 GLDEF_C TInt E32Main() // main function called by E32
00061     {
00062         __UHEAP_MARK;
00063         CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack
00064         TRAPD(error, CallExampleL()); // more initialization, then do example
00065         delete cleanup; // destroy clean-up stack
00066         __ASSERT_ALWAYS(!error, User::Panic(KTxtEPOC32EX, error));
00067         __UHEAP_MARKEND;
00068         return 0; // and return
00069     }
00070 
00071 LOCAL_C void CallExampleL() // initialize and call example code under cleanup stack
00072     {
00073         console=Console::NewL(KTxtExampleCode, TSize(KConsFullScreen, KConsFullScreen));
00074         CleanupStack::PushL(console);
00075         TRAPD(error, DoStartL()); // perform example function
00076         if (error)
00077                 console->Printf(KFormatFailed, error);
00078         else
00079                 console->Printf(KTxtOK);
00080         console->Printf(KTextPressAnyKey);
00081         console->Getch(); // get and ignore character
00082         CleanupStack::PopAndDestroy(); // close console
00083     }

Generated by  doxygen 1.6.2