codhandler/codeng/src/HeaderField.cpp
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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 the License "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:  ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "FileExt.h"
       
    22 #include "HeaderField.h"
       
    23 
       
    24 // EXTERNAL DATA STRUCTURES
       
    25 //extern  ?external_data;
       
    26 
       
    27 // EXTERNAL FUNCTION PROTOTYPES  
       
    28 //extern ?external_function( ?arg_type,?arg_type );
       
    29 
       
    30 // CONSTANTS
       
    31 //const ?type ?constant_var = ?constant;
       
    32 
       
    33 // MACROS
       
    34 //#define ?macro ?macro_def
       
    35 
       
    36 // LOCAL CONSTANTS AND MACROS
       
    37 //const ?type ?constant_var = ?constant;
       
    38 //#define ?macro_name ?macro_def
       
    39 
       
    40 // MODULE DATA STRUCTURES
       
    41 //enum ?declaration
       
    42 //typedef ?declaration
       
    43 
       
    44 // LOCAL FUNCTION PROTOTYPES
       
    45 //?type ?function_name( ?arg_type, ?arg_type );
       
    46 
       
    47 // FORWARD DECLARATIONS
       
    48 //class ?FORWARD_CLASSNAME;
       
    49 
       
    50 // ============================= LOCAL FUNCTIONS ===============================
       
    51 void Trim( TPtrC8& aTrim )
       
    52     {
       
    53     if( aTrim.Length() == 0 )
       
    54         {
       
    55         return;
       
    56         }
       
    57 
       
    58     TInt start = 0;
       
    59 
       
    60     for( ; start < aTrim.Length() && TChar(aTrim[start]).IsSpace(); ++start ){};
       
    61 
       
    62     TInt end = aTrim.Length()-1;
       
    63     for( ; end >= start && TChar(aTrim[end]).IsSpace(); --end ){};
       
    64 
       
    65     aTrim.Set( aTrim.Mid( start, (end+1)-start ) );
       
    66     }
       
    67 
       
    68 // ============================ MEMBER FUNCTIONS ===============================
       
    69 
       
    70 // -----------------------------------------------------------------------------
       
    71 // CHeaderField::CHeaderField
       
    72 // C++ default constructor can NOT contain any code, that
       
    73 // might leave.
       
    74 // -----------------------------------------------------------------------------
       
    75 //
       
    76 CHeaderField::CHeaderField( TInt aFieldIndex )
       
    77     :iFieldIndex( aFieldIndex )
       
    78     {
       
    79     }
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // CHeaderField::ConstructL
       
    83 // Symbian 2nd phase constructor can leave.
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 void CHeaderField::ConstructL( const TDesC8* aFieldname,
       
    87                                const TDesC8* aFieldRawData )
       
    88     {
       
    89     if( aFieldname && aFieldRawData )
       
    90         {
       
    91         TPtrC8 name( *aFieldname );
       
    92         TPtrC8 rawData( *aFieldRawData );
       
    93 
       
    94         Trim( name );
       
    95         Trim( rawData );
       
    96 
       
    97         ReallocateStringL( iFieldName, name );
       
    98         ReallocateStringL( iFieldRawData, rawData );
       
    99         }
       
   100     }
       
   101 
       
   102 // -----------------------------------------------------------------------------
       
   103 // CHeaderField::NewL
       
   104 // Two-phased constructor.
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 CHeaderField* CHeaderField::NewL( const TDesC8* aFieldname,
       
   108                                   const TDesC8* aFieldRawData,
       
   109                                   TInt aFieldIndex )
       
   110     {
       
   111     CHeaderField* self = new( ELeave ) CHeaderField( aFieldIndex );
       
   112     
       
   113     CleanupStack::PushL( self );
       
   114     self->ConstructL( aFieldname, aFieldRawData );
       
   115     CleanupStack::Pop();
       
   116 
       
   117     return self;
       
   118     }
       
   119 
       
   120     
       
   121 // Destructor
       
   122 CHeaderField::~CHeaderField()
       
   123     {
       
   124     delete iFieldName;
       
   125     delete iFieldRawData;
       
   126     }
       
   127 
       
   128 // -----------------------------------------------------------------------------
       
   129 // CHeaderField::LoadHeaderInfoL
       
   130 // ?implementation_description
       
   131 // (other items were commented in a header).
       
   132 // -----------------------------------------------------------------------------
       
   133 //
       
   134 void CHeaderField::LoadHeaderInfoL( RFile& aInFile )
       
   135     {
       
   136     ReadHBufCL( aInFile, iFieldName );
       
   137     ReadHBufCL( aInFile, iFieldRawData );
       
   138     }
       
   139 
       
   140 // -----------------------------------------------------------------------------
       
   141 // CHeaderField::Int
       
   142 // ?implementation_description
       
   143 // (other items were commented in a header).
       
   144 // -----------------------------------------------------------------------------
       
   145 //
       
   146 TInt CHeaderField::Int() const
       
   147     {
       
   148     TLex8 temp( *iFieldRawData );
       
   149     TInt value( 0 );
       
   150 
       
   151     temp.Val( value );
       
   152 
       
   153     return value;
       
   154     }
       
   155 
       
   156 //  End of File