wim/inc/WimBerSet.h
changeset 0 164170e6151a
equal deleted inserted replaced
-1:000000000000 0:164170e6151a
       
     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:  An implementation of a CWimBerSet, which holds CWimBer objects
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef WIMBERSET_H
       
    21 #define WIMBERSET_H
       
    22 
       
    23 
       
    24 //INCLUDES
       
    25 #include "WimBerConsts.h"
       
    26 #include <e32base.h>
       
    27 #include <bigint.h>
       
    28 
       
    29 
       
    30 
       
    31 //FORWARD DECLARATIONS
       
    32 class CWimBer;
       
    33 
       
    34 /*
       
    35 * Class CWimBerSet contains set of CWimBer objects
       
    36 * 
       
    37 *  @lib   WimBer
       
    38 *  @since Series60 2.6 
       
    39 */
       
    40 
       
    41 class CWimBerSet: public CArrayPtrSeg<CWimBer>
       
    42     {
       
    43                  
       
    44     public:
       
    45 
       
    46         /*
       
    47         * Two-phased constructor
       
    48         * @param aGranularity -Initial size of the created set
       
    49         * @return CWimBerSet* -initialized object which is inserted into 
       
    50         * cleanupstack
       
    51         */
       
    52         IMPORT_C static CWimBerSet* NewLC( const TInt aGranularity );
       
    53 
       
    54         /*
       
    55         * Two-phased constructor
       
    56         * @param aGranularity -Initial size of the created set
       
    57         * @return CWimBerSet* -initialized object
       
    58         */
       
    59         IMPORT_C static CWimBerSet* NewL( const TInt aGranularity );
       
    60         
       
    61         /* 
       
    62         * Destructor. Allocated memory is released
       
    63         */
       
    64         IMPORT_C  virtual ~CWimBerSet();
       
    65 
       
    66         /*   
       
    67         * Function creates CWimBer integer object.
       
    68         * @param aValue. -Integer for object creation
       
    69         * @return void
       
    70         */
       
    71         IMPORT_C void CreateIntL( const TInt aValue );
       
    72         
       
    73         /*
       
    74         * Funtion creates long CWimBer integer object.
       
    75         * @param aValue. -Integer for object creation.
       
    76         * @return void
       
    77         */
       
    78         IMPORT_C void CreateLongIntL( RInteger& aValue );
       
    79 
       
    80         /* 
       
    81         * Function creates CWimBer octet string object. The octet string is an 
       
    82         * arbitrarily long binary value.
       
    83         * @param aString -String for octet creation
       
    84         * @return void
       
    85         */
       
    86         IMPORT_C void CreateOctetL( TDesC8& aString );
       
    87         
       
    88         /* 
       
    89         * Function creates CWimBer NULL object ( 0x05 0x00 ).
       
    90         * @return void
       
    91         */
       
    92         IMPORT_C void CreateNullL();
       
    93 
       
    94         /* 
       
    95         * Function creates CWimBer object identifier object.
       
    96         * @param aString -object identifier content
       
    97         * @return void
       
    98         */
       
    99         IMPORT_C void CreateOidL( TDesC8& aString );
       
   100 
       
   101 
       
   102         /* 
       
   103         * Function creates CWimBer printable string object.
       
   104         * The printable string is defined to only contain
       
   105         * the characters A-Z, a-z, 0-9, space,
       
   106         * and the punctuation characters ()-+=:',./?.
       
   107         * @param aString -printable string
       
   108         * @return void
       
   109         */
       
   110         IMPORT_C void CreatePrintableL( TDesC8& aString );
       
   111 
       
   112         /* 
       
   113         * Function creates CWimBer IA5 string object.
       
   114         * IA5 ( International Alphabet 5 )
       
   115         * is equivalent to US-ASCII.
       
   116         * @param aString -IA5 string
       
   117         * @return void
       
   118         */
       
   119         IMPORT_C void CreateIA5L( TDesC8& aString );
       
   120 
       
   121         /*
       
   122         * Function creates CWimBer universal time object.
       
   123         * Note this value only represents years using two digits.
       
   124         * @param aString -universal time
       
   125         * @return void
       
   126         */
       
   127         IMPORT_C void CreateUTCL( TDesC8& aString );
       
   128 
       
   129         /* 
       
   130         * Append start of sequence ( 30 xx, xx = length )
       
   131         * @param aDefinite. -ETrue for definite length sequence, EFalse for 
       
   132         * indefinite length. 
       
   133         * @return void
       
   134         */
       
   135         IMPORT_C void CreateSeqStartL( TBool aDefinite );
       
   136 
       
   137         /*
       
   138         * Append start of set ( 31 xx, xx = length )
       
   139         * @param aDefinite. -ETrue for definite length sequence, EFalse for 
       
   140         * indefinite length. 
       
   141         * @return void
       
   142         */
       
   143         IMPORT_C void CreateSetStartL( TBool aDefinite );
       
   144 
       
   145         /*  
       
   146         * Append start of the constructed.
       
   147         * @param aTag -object type ( tag )
       
   148         * @param aDefinite -ETrue for definite length sequence, EFalse for 
       
   149         * indefinite length. 
       
   150         * @return void
       
   151         */
       
   152         IMPORT_C void CreateConstructedStartL( TBerTag aTag, TBool aDefinite );
       
   153 
       
   154         /*
       
   155         * Function closes last constructed object. 
       
   156         * @return void
       
   157         */
       
   158         IMPORT_C void CreateEndL();
       
   159 
       
   160         /*  
       
   161         * Used to create a CWimBer object
       
   162         * from buffer, which already contains a full CWimBer
       
   163         * encoded object.
       
   164         * @param aBuffer -contains full CWimBer encoded object.
       
   165         * @return void
       
   166         */
       
   167         IMPORT_C void CreateBEREncodedObjectL( TDesC8& aBuffer );
       
   168 
       
   169         /* 
       
   170         * Function writes all created CWimBer objects (which are 
       
   171         * Appended to set) to descriptor. Function also fixes all definite
       
   172         * lengths. 
       
   173         * @param aTarget -Descriptor where data is written. 
       
   174         * @return TInt -Error code(negative) or the number of WimBer objects
       
   175         *               (positive).
       
   176         */
       
   177         IMPORT_C TInt FlushL( HBufC8*& aTarget );
       
   178 
       
   179     public:
       
   180 
       
   181         /* 
       
   182         * Encode and write object identifier.
       
   183         * @param aString  -Object ID. e.g. _L8("1.2.3.4.5")
       
   184         * @param aOnlyLen - ETrue if You don't want to write object to iTarget
       
   185         * @return TInt    -Error code
       
   186         */
       
   187         TInt AppendObjectIdL( const TDesC8& aString, TBool aOnlyLen = EFalse );
       
   188 
       
   189 
       
   190     private:
       
   191 
       
   192         /* 
       
   193         * Write constructed type start.
       
   194         * @param aTag -type of constructed tag e.g. 04 for octetS.
       
   195         * @param aLength -Length or 0 for indefinite length
       
   196         * @return void
       
   197         */
       
   198         void AppendConstructedL( TBerTag aTag, TUint aLength = 0 );
       
   199         
       
   200         /* 
       
   201         * Close indefinite length. (= add 0x00 0x00) 
       
   202         * @return void
       
   203         */
       
   204         void CloseIndefinite(); 
       
   205         
       
   206         /* 
       
   207         * Encode and write boolean object. 
       
   208         * @param aBool -ETrue or EFalse
       
   209         * @return void
       
   210         */
       
   211         void AppendBoolL( TBool aBool );   
       
   212         
       
   213         /* 
       
   214         * Encode and write integer object.
       
   215         * @param aData -Integer to be written to data. 
       
   216         * @return void
       
   217         */
       
   218         void AppendIntL( TInt aData ); 
       
   219 
       
   220         /* 
       
   221         * Encode and write long integer object.
       
   222         * @param aData -Integer to be written to data. 
       
   223         * @return void
       
   224         */ 
       
   225         void AppendLongIntL( const RInteger* aData );
       
   226         
       
   227         /* 
       
   228         * Encode and write null object. (0x05 0x00)
       
   229         * @return void
       
   230         */
       
   231         void AppendNull();
       
   232         
       
   233         
       
   234         /* 
       
   235         * Encode and write string to iTarget
       
   236         * @param aTag - Object type ( tag )
       
   237         * @param aString - String to be written
       
   238         * @void
       
   239         */
       
   240         void AppendStringL( TBerTag aTag, const TDesC8& aString );
       
   241         
       
   242         /* 
       
   243         * Write CWimBer encoded object to iTarget.
       
   244         * Note that this function doesn't add any tags
       
   245         * etc. it trusts that the given object already
       
   246         * is a whole CWimBer encoded object.
       
   247         * @param aString -Buffer containing CWimBer encoded object
       
   248         * @return void
       
   249         */
       
   250         void AppendBerEncodedObject( const TDesC8& aString );
       
   251 
       
   252     private:
       
   253 
       
   254         /* 
       
   255         * Default constructor
       
   256         * @param aGranularity -Granularity for this array 
       
   257         */
       
   258         CWimBerSet( const TInt aGranularity ); 
       
   259         
       
   260     private:  
       
   261 
       
   262         // Descriptor for data. Not owned.
       
   263         HBufC8* iTarget;
       
   264         
       
   265         // Nesting level of object. ( encoding ).
       
   266         TInt iLevel;
       
   267         
       
   268         // Max level which is used in encoding.
       
   269         TInt iMaxLevel;
       
   270 
       
   271     };
       
   272 
       
   273 
       
   274 #endif //WIMBERSET_H