csxhelp/HelpEngine/src/CsHelpCmdLineParser.cpp
branchRCL_3
changeset 17 12f60d9a73b3
parent 16 0d1adf67ec1b
child 18 cbffe13eac63
equal deleted inserted replaced
16:0d1adf67ec1b 17:12f60d9a73b3
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *     This is a utility class that provides functionality
       
    16 *     for parsing command line arguments passed into the
       
    17 *     Cshelp application when launched by another application.
       
    18 *
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 // INCLUDE FILES
       
    24 #include <hlplch.h>
       
    25 
       
    26 #include "CsHelpCmdLineParser.h"
       
    27 const TInt KArrSize = 2;
       
    28 // ================= MEMBER FUNCTIONS =======================
       
    29 
       
    30 // C++ constructor
       
    31 CCsHlpCmdLineParser::CCsHlpCmdLineParser()
       
    32 : CBase()
       
    33     {
       
    34     }
       
    35 
       
    36 
       
    37 // ---------------------------------------------------------
       
    38 // CCsHlpCmdLineParser::ConstructL(...)
       
    39 // (other items were commented in a header).
       
    40 // ---------------------------------------------------------
       
    41 void CCsHlpCmdLineParser::ConstructL(const TDesC8& aCmdLine)
       
    42     {
       
    43     iCmdLine = CBufFlat::NewL(aCmdLine.Size());
       
    44     iCmdLine->InsertL(0, aCmdLine.Ptr(), aCmdLine.Size());
       
    45     }
       
    46 
       
    47 
       
    48 // ---------------------------------------------------------
       
    49 // CCsHlpCmdLineParser::~CCsHlpCmdLineParser()
       
    50 // ---------------------------------------------------------
       
    51 CCsHlpCmdLineParser::~CCsHlpCmdLineParser()
       
    52     {
       
    53     delete iCmdLine;
       
    54     }
       
    55 
       
    56 // ---------------------------------------------------------
       
    57 // CCsHlpCmdLineParser::ContextListL()
       
    58 // (other items were commented in a header).
       
    59 // ---------------------------------------------------------
       
    60 CArrayFix<TCoeHelpContext>* CCsHlpCmdLineParser::ContextListL()
       
    61     {
       
    62     CArrayFixFlat<TCoeHelpContext>* array =
       
    63                                   new(ELeave)CArrayFixFlat<TCoeHelpContext>(KArrSize);
       
    64     CleanupStack::PushL(array);
       
    65     TInt count(0);
       
    66 
       
    67     iCmdLine->Read(0, &count, sizeof(TInt));
       
    68     iPos += sizeof(TInt);
       
    69     for (TInt i(0); i < count; i++)
       
    70         {
       
    71         TCoeHelpContext context;
       
    72         GetContext(context);
       
    73         array->AppendL(context);
       
    74         }
       
    75     CleanupStack::Pop(array); // array
       
    76     return array;
       
    77     }
       
    78 
       
    79 // ---------------------------------------------------------
       
    80 // CCsHlpCmdLineParser::GetContext(...)
       
    81 // (other items were commented in a header).
       
    82 // ---------------------------------------------------------
       
    83 void CCsHlpCmdLineParser::GetContext(TCoeHelpContext& aContext)
       
    84     {
       
    85     TInt length(0);
       
    86     iCmdLine->Read(iPos, &length, sizeof(TInt));
       
    87     iPos += sizeof(TInt);
       
    88     TPtr8 ptr((TText8*)aContext.iContext.Ptr(), length);
       
    89     iCmdLine->Read(iPos, ptr, length);
       
    90     aContext.iContext.SetLength(length/KArrSize);
       
    91     iPos += length;
       
    92 
       
    93     iCmdLine->Read(iPos, &aContext.iMajor, sizeof(TUid));
       
    94 
       
    95     iPos += sizeof(TUid);
       
    96     }
       
    97 
       
    98 // End of file