telephonyserverplugins/simatktsy/utility/src/ttlv.cpp
branchRCL_3
changeset 66 07a122eea281
parent 65 630d2f34d719
equal deleted inserted replaced
65:630d2f34d719 66:07a122eea281
     1 // Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    19 //
    19 //
    20 
    20 
    21 
    21 
    22 
    22 
    23 //  Include Files  
    23 //  Include Files  
    24 
       
    25 #include "OstTraceDefinitions.h"
       
    26 #ifdef OST_TRACE_COMPILER_IN_USE
       
    27 #include "ttlvTraces.h"
       
    28 #endif
       
    29 
       
    30 #include "TTlv.h"				    // Header of this class
    24 #include "TTlv.h"				    // Header of this class
       
    25 #include "tflogger.h"				// For logging
    31 
    26 
    32 //  External Data Structures  
    27 //  External Data Structures  
    33 //    none
    28 //    none
    34 
    29 
    35 //  External Function Prototypes  
    30 //  External Function Prototypes  
    78 EXPORT_C void TTlvBase::Begin
    73 EXPORT_C void TTlvBase::Begin
    79         ( 
    74         ( 
    80         TUint8 aTag 
    75         TUint8 aTag 
    81         )
    76         )
    82     {
    77     {
    83     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, TTLVBASE_BEGIN_1, "UTILITY: TTlvBase::Begin");
    78     TFLOGSTRING("UTILITY: TTlvBase::Begin"); 
    84     iData.Zero();
    79     iData.Zero();
    85     iData.Append( aTag );
    80     iData.Append( aTag );
    86     iData.Append( 0 );
    81     iData.Append( 0 );
    87     }
    82     }
    88 
    83 
    94 EXPORT_C void TTlvBase::AddTag
    89 EXPORT_C void TTlvBase::AddTag
    95         ( 
    90         ( 
    96         TUint8 aTag 
    91         TUint8 aTag 
    97         )
    92         )
    98     {
    93     {
    99     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, TTLVBASE_ADDTAG_1, "UTILITY: TTlvBase::AddTag");
    94     TFLOGSTRING("UTILITY: TTlvBase::AddTag");
   100     iData.Append( aTag );           // tag
    95     iData.Append( aTag );           // tag
   101     iData.Append( 0 );              // length
    96     iData.Append( 0 );              // length
   102     iLenIndex = iData.Length() - 1; // index to tag length
    97     iLenIndex = iData.Length() - 1; // index to tag length
   103     }
    98     }
   104 
    99 
   110 EXPORT_C void TTlvBase::AddByte
   105 EXPORT_C void TTlvBase::AddByte
   111         ( 
   106         ( 
   112         TUint8 aValue  
   107         TUint8 aValue  
   113         )
   108         )
   114     {
   109     {
   115     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, TTLVBASE_ADDBYTE_1, "UTILITY: TTlvBase::AddByte");
   110     TFLOGSTRING("UTILITY: TTlvBase::AddByte");
   116     iData.Append( aValue );
   111     iData.Append( aValue );
   117     iData[iLenIndex]++;
   112     iData[iLenIndex]++;
   118     }
   113     }
   119 
   114 
   120 // -----------------------------------------------------------------------------
   115 // -----------------------------------------------------------------------------
   125 EXPORT_C void TTlvBase::AddData
   120 EXPORT_C void TTlvBase::AddData
   126         ( 
   121         ( 
   127         const TDesC8& aValue 
   122         const TDesC8& aValue 
   128         )
   123         )
   129     {
   124     {
   130     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, TTLVBASE_ADDDATA_1, "UTILITY: TTlvBase::AddData");
   125     TFLOGSTRING("UTILITY: TTlvBase::AddData");
   131     iData.Append( aValue );
   126     iData.Append( aValue );
   132     iData[ iLenIndex ] = static_cast<TUint8>( iData[ iLenIndex ] + 
   127     iData[ iLenIndex ] = static_cast<TUint8>( iData[ iLenIndex ] + 
   133         aValue.Length() );
   128         aValue.Length() );
   134     }
   129     }
   135 
   130 
   143 EXPORT_C const TDesC8& TTlvBase::End
   138 EXPORT_C const TDesC8& TTlvBase::End
   144         (
   139         (
   145         // None
   140         // None
   146         )
   141         )
   147     {
   142     {
   148     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, TTLVBASE_END_1, "UTILITY: TTlvBase::End");
   143     TFLOGSTRING("UTILITY: TTlvBase::End");
   149     _LIT8( KLenTag, "\x81" );
   144     _LIT8( KLenTag, "\x81" );
   150 
   145 
   151     TInt i( 3 ); // Index to tag length
   146     TInt i( 3 ); // Index to tag length
   152 
   147 
   153     // Scan through all lenghts and insert 'length tag'
   148     // Scan through all lenghts and insert 'length tag'
   184 EXPORT_C const TDesC8& TTlvBase::GetDataWithoutTopLevelTag
   179 EXPORT_C const TDesC8& TTlvBase::GetDataWithoutTopLevelTag
   185         (
   180         (
   186         // None
   181         // None
   187         )
   182         )
   188     {
   183     {
   189     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, TTLVBASE_GETDATAWITHOUTTOPLEVELTAG_1, "UTILITY: TTlvBase::GetDataWithoutTopLevelTag");
   184     TFLOGSTRING("UTILITY: TTlvBase::GetDataWithoutTopLevelTag");
   190     _LIT8( KLenTag, "\x81" );
   185     _LIT8( KLenTag, "\x81" );
   191 
   186 
   192     TInt i( 1 ); // Index to tag length
   187     TInt i( 1 ); // Index to tag length
   193 
   188 
   194     // Scan through all lenghts and insert 'length tag'
   189     // Scan through all lenghts and insert 'length tag'