|
1 /* |
|
2 * Copyright (c) 2000, 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 "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: This file contains the headers of CCrBer and CCrBerSet classes. |
|
15 * These classes are used to encode and decode BER object(s). |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #ifndef CR_BER |
|
22 #define CR_BER |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32base.h> // CBase |
|
26 #include <asn1dec.h> // ASN1 (Symbian) |
|
27 #include "crdata.h" // CCrData |
|
28 #include "crdefs.h" // Definitions |
|
29 |
|
30 #include <bigint.h> |
|
31 |
|
32 // MACROS |
|
33 #define LEN_BYTES_MAX 4 // Max amount of length bytes in BER encoded |
|
34 // object. Probably this never changes, but |
|
35 // you'll never know. |
|
36 // DATA TYPES |
|
37 typedef TUint8 TBerTag; |
|
38 |
|
39 // CONSTANTS |
|
40 ////////////////////////////////////////////////////////////////////////// |
|
41 // BER types. |
|
42 const TBerTag KBerEndOfContent = 0x00; // End of contents tag |
|
43 const TBerTag KBerBoolean = 0x01; // Boolean tag |
|
44 const TBerTag KBerInteger = 0x02; // Integer tag |
|
45 const TBerTag KBerBitString = 0x03; // Bit string tag |
|
46 const TBerTag KBerOctetString = 0x04; // Octet string tag |
|
47 const TBerTag KBerNull = 0x05; // NULL tag |
|
48 const TBerTag KBerOid = 0x06; // Object identifier tag |
|
49 const TBerTag KBerNumS = 0x12; // Numeric string |
|
50 const TBerTag KBerPrS = 0x13; // Printable string tag |
|
51 const TBerTag KBerT61S = 0x14; // T61 string tag |
|
52 const TBerTag KBerVideoS = 0x15; // Video string tag |
|
53 const TBerTag KBerIA5S = 0x16; // IA5 string tag |
|
54 const TBerTag KBerUtc = 0x17; // UTC time tag |
|
55 const TBerTag KBerGenTime = 0x18; // Generalized Time tag |
|
56 const TBerTag KBerGraphS = 0x19; // Graphics string tag |
|
57 const TBerTag KBerVisibleS = 0x1A; // Visible string |
|
58 const TBerTag KBerGeneralS = 0x1B; // Generalised string |
|
59 const TBerTag KBerBmpS = 0x1E; // Bmp string |
|
60 const TBerTag KBerSeq = 0x30; // Sequence tag |
|
61 const TBerTag KBerSet = 0x31; // Set tag |
|
62 |
|
63 const TBerTag KBerUnknown = 0xff; // Unknown tag |
|
64 |
|
65 const TBerTag KBerEncodedObject = 0xfe; // Tag for ready-made |
|
66 // BER encoded objects |
|
67 |
|
68 const TBerTag KBerLongLengthBit = 0x80; // Long length bit |
|
69 const TBerTag KBerConstructedBit= 0x20; // Constructed bit |
|
70 const TBerTag KBerConstructed = 0x20; |
|
71 |
|
72 const TBerTag KBerImplicit = 0x80; // Implicit tag |
|
73 const TBerTag KBerExplicit = 0x80; // Explicit tag |
|
74 |
|
75 const TBerTag KBerImplicitConstructed = 0xA0; // Implicit constructed tag |
|
76 const TBerTag KBerExplicitConstructed = 0xA0; // Explicit constructed tag |
|
77 |
|
78 const TBerTag KBerBooleanTrue = 0xFF; // Boolean true value (DER) |
|
79 const TBerTag KBerBooleanFalse = 0x00; // Boolean false value (DER) |
|
80 const TBerTag KBerNullContent = 0x00; // Null objects content |
|
81 |
|
82 const TBerTag KBerBooleanLen = 0x03; // Boolean object length |
|
83 const TBerTag KBerNullLen = 0x02; // Null object length |
|
84 const TBerTag KBerShortLen = 0x02; // Tag + (short) length byte |
|
85 const TBerTag KBerIndefiniteLen = 0x04; // Indefinite length (xx 80 00 00) |
|
86 |
|
87 const TInt KReadBufMax = 256; // Length of buffer used |
|
88 // when reading from files. |
|
89 const TUint KOpenAllLevels = 255; // OpenL(....) function |
|
90 const TInt KOctetWidth = 8; |
|
91 const TInt KObjectIDDot = 1; // object id encoding |
|
92 const TInt KObjectIDFirstFactor = 4; // object id encoding |
|
93 const TInt KObjectIDSecondFactor = 10; // object id encoding |
|
94 |
|
95 const TInt KIntBufSize = 6; // Integer encoding buffer size |
|
96 |
|
97 // CLASS DECLARATION |
|
98 |
|
99 /** |
|
100 * Class CCrBer is able to contain a BER encoded object of any type. |
|
101 * |
|
102 * @lib crber.lib |
|
103 * @since Series 60 3.0 |
|
104 */ |
|
105 NONSHARABLE_CLASS( CCrBer ): public CBase |
|
106 { |
|
107 ///////////////////////////////////////////// |
|
108 // Constructors and destructors. |
|
109 private: |
|
110 CCrBer(TInt aLevel = 0); |
|
111 |
|
112 TAny ConstructL(); |
|
113 |
|
114 public: |
|
115 IMPORT_C static CCrBer* NewLC(TInt aLevel = 0); |
|
116 IMPORT_C static CCrBer* NewL(TInt aLevel = 0); |
|
117 IMPORT_C ~CCrBer(); |
|
118 |
|
119 |
|
120 ///////////////////////////////////////////// |
|
121 // Functions to open BER object. |
|
122 |
|
123 /** |
|
124 * Read next BER encoded object from the current position of |
|
125 * given CCrData to this object. Return the type of the BER |
|
126 * object, or KBerUnknown, if not of any known type. Only pointer |
|
127 * to aData is stored into this object, so Get* functions are |
|
128 * meaningful only if original data object is still existing, |
|
129 * when these functions are used. |
|
130 */ |
|
131 IMPORT_C TBerTag Read(CCrData* aData); |
|
132 |
|
133 /** |
|
134 * Read type tag from current position in given CCrData. |
|
135 * Returns type tag or KBerUnknown, if not of any known type. |
|
136 */ |
|
137 IMPORT_C static TBerTag ReadType(CCrData* aData); |
|
138 |
|
139 /** |
|
140 * Read length tags from current position in given CCrData. |
|
141 * Returns length. If length is indefinite, aIndefinite is set |
|
142 * to true, otherwise to false. In indefinite case length is 0. |
|
143 * Also sets amount of length bytes in aLenLen, if given. |
|
144 */ |
|
145 IMPORT_C TUint ReadLen( |
|
146 CCrData* aData, |
|
147 TBool& aIndefinite, |
|
148 TUint8* aLenLen = 0); |
|
149 |
|
150 /** |
|
151 * Returns true if given BER tag is identified one. |
|
152 */ |
|
153 IMPORT_C static TBool IsKnownType(TBerTag aTag); |
|
154 |
|
155 /** |
|
156 * Returns true if given BER tag is sequence, set, |
|
157 * implicit contructed, or explicit constructed tag. |
|
158 */ |
|
159 IMPORT_C static TBool IsSeqOrSet(TBerTag aTag); |
|
160 |
|
161 /** |
|
162 * Finds next end-of-content (00 00) tag from given data. |
|
163 * Returns the distance between current place and the tag, |
|
164 * or 0, if not found. Moves data pointer to the next byte |
|
165 * _after_ the tag, i.e. two bytes longer than you might |
|
166 * except from the return value. |
|
167 */ |
|
168 IMPORT_C TUint FindEndOfContent(CCrData* aData); |
|
169 |
|
170 /** |
|
171 * Open constructed encoding from this object. |
|
172 * Parameters: aTarget; target for contentbytes. |
|
173 * Return Values: Number of objects. |
|
174 */ |
|
175 IMPORT_C TInt OpenConstructedEncodingL(CCrData& aTarget); |
|
176 |
|
177 IMPORT_C TUint OpenConstructedEncodingWithTagL( |
|
178 CCrData* aData, |
|
179 CCrBer& parentObj, |
|
180 HBufC8* buf = 0); |
|
181 |
|
182 ///////////////////////////////////////////// |
|
183 // Functions to get info about this BER object. |
|
184 |
|
185 // Return type of the object. |
|
186 IMPORT_C TBerTag Type(); |
|
187 |
|
188 // Return value of the object (int or boolean object). |
|
189 // Only to encoding.. |
|
190 IMPORT_C TInt Value(); |
|
191 IMPORT_C RInteger GetBigInt(); |
|
192 IMPORT_C TDesC8* ValuePtr(); |
|
193 IMPORT_C TAny SetValue(TInt aInt); |
|
194 |
|
195 // Return amount of length bytes. |
|
196 IMPORT_C TInt LenLen(); |
|
197 |
|
198 // Return begin of the whole object. |
|
199 IMPORT_C TInt ObjectBegin(); |
|
200 |
|
201 // Return begin of the content. |
|
202 IMPORT_C TInt ContentBegin(); |
|
203 |
|
204 // Return length of the content. |
|
205 IMPORT_C TInt ContentLen(); |
|
206 |
|
207 // Return length of the whole object. |
|
208 IMPORT_C TInt ObjectLen(); |
|
209 |
|
210 // Return true if this object is indefinite length, else false. |
|
211 IMPORT_C TBool Indefinite(); |
|
212 |
|
213 // Return pointer to data object. |
|
214 IMPORT_C CCrData* Data(); |
|
215 |
|
216 // Return whole BER object with tag and stuff. For implementation |
|
217 // reasons ObjectL returns only max 255 bytes of data. |
|
218 |
|
219 IMPORT_C TInt Object(HBufC8* aBuf); |
|
220 IMPORT_C TInt ObjectL(HBufC* aBuf); |
|
221 |
|
222 // Return content of this object. For implementation reasons |
|
223 // ContentL returns only max 255 bytes of data. |
|
224 IMPORT_C TInt Content(HBufC8* aBuf); |
|
225 IMPORT_C TInt ContentL(HBufC* aBuf); |
|
226 |
|
227 // Read aAmount of data starting from begin to the buffer. |
|
228 // Return amount of data read. For implementation reasons |
|
229 // BufferL can be used only to read max 255 bytes of data. |
|
230 static IMPORT_C TInt BufferL( |
|
231 HBufC8* aBuf, |
|
232 CCrData* aData, |
|
233 TUint aBegin = 0, |
|
234 TUint aAmount = KReadBufMax); |
|
235 static IMPORT_C TInt BufferL( |
|
236 HBufC* aBuf, |
|
237 CCrData* aData, |
|
238 TUint aBegin = 0, |
|
239 TUint8 aAmount = 255); |
|
240 |
|
241 // Return nesting level of this object. |
|
242 IMPORT_C TUint Level(); |
|
243 |
|
244 // Set nesting level of this object. |
|
245 IMPORT_C TUint SetLevel(TUint aLevel); |
|
246 |
|
247 /////////////////////////////////////////// |
|
248 // Get content |
|
249 |
|
250 // Return value of integer object. |
|
251 // e.g. 21 |
|
252 IMPORT_C TInt GetIntegerL(); |
|
253 IMPORT_C RInteger GetLongIntegerL(); |
|
254 |
|
255 // Return value of boolean object. |
|
256 // e.g. ETrue |
|
257 IMPORT_C TBool GetBooleanL(); |
|
258 |
|
259 // Return content of object identifier object. |
|
260 // e.g. 1.2.3.4.5 |
|
261 IMPORT_C HBufC* GetOidL(); |
|
262 |
|
263 // Return content of octet string object. |
|
264 // e.g. 45 53 65 77 |
|
265 IMPORT_C HBufC8* GetOctetStringL(); |
|
266 IMPORT_C TAny GetOctetStringL(CCrData& Trg); |
|
267 |
|
268 // Return content of content string object. |
|
269 IMPORT_C HBufC8* GetContentStringLC(); |
|
270 |
|
271 // Return content of IA5 string object. |
|
272 // e.g. "hello" |
|
273 IMPORT_C HBufC* GetIA5StringL(); |
|
274 |
|
275 // Return content of UTC time object. |
|
276 IMPORT_C TTime GetUTCTimeL(); |
|
277 |
|
278 // Return content of printable string object. |
|
279 // e.g. "hello" |
|
280 IMPORT_C HBufC* GetPrintStringL(); |
|
281 |
|
282 // Return content of teletext string object. |
|
283 IMPORT_C HBufC* GetTeletextStringL(); |
|
284 |
|
285 // Return content of sequence object. |
|
286 // e.g. 02 01 01 01 01 FF |
|
287 IMPORT_C HBufC8* GetSequenceL(); |
|
288 |
|
289 // Return content of videotext string object. |
|
290 IMPORT_C HBufC* GetVideoStringL(); |
|
291 |
|
292 // Return content of generalised string object. |
|
293 IMPORT_C HBufC* GetGeneralStringL(); |
|
294 |
|
295 // Return content of visible characters string object. |
|
296 IMPORT_C HBufC* GetVisibleStringL(); |
|
297 |
|
298 // Return content of a generalised graphical string obj. |
|
299 IMPORT_C HBufC* GetGraphicsStringL(); |
|
300 |
|
301 // Basically, TIME+ century |
|
302 // Return content of a generalized time string obj. |
|
303 IMPORT_C TTime GetGeneralizedTimeL(); |
|
304 |
|
305 // Return content of numeric string object |
|
306 // only for numbers. |
|
307 IMPORT_C HBufC* GetNumericStringL(); |
|
308 |
|
309 |
|
310 ///////////////////////////////////////////// |
|
311 // Functions to modify info about this BER object. |
|
312 |
|
313 // Add given integer to content length of this object. |
|
314 IMPORT_C TAny AddToContentLen(TInt iLen); |
|
315 |
|
316 // Calculate object length from tag, length's length, and |
|
317 // content's length. Used to 'close' indefinite objects, meaning |
|
318 // that their end-of-contents tag is finally found, so their |
|
319 // length can be calculated. |
|
320 IMPORT_C TAny SetObjectLen(); |
|
321 |
|
322 // Set object length to object length - content length. = Length of tag |
|
323 // and lenbits (+lenlen). |
|
324 IMPORT_C TAny SetObjLenWithOutContent(TUint aContentLen); |
|
325 |
|
326 public: |
|
327 // Encoding |
|
328 // These functions are used by CCrBerSet::Create* |
|
329 // Save type,length and value. |
|
330 TAny CreateBool(TBool aBool); |
|
331 // Save type,length and value. |
|
332 TAny CreateInt(TInt aInt); |
|
333 TAny CreateLongInt(RInteger& aData); |
|
334 // Save type and value of object. |
|
335 TAny CreateNull(); |
|
336 // Save type, length and pointer to string |
|
337 TAny CreateOIdL(TDesC8* aString); |
|
338 TAny CreateString(TBerTag aTag, TDesC8* aString); |
|
339 TAny CreateString(TBerTag aTag, CCrData* aData); |
|
340 |
|
341 // Save tag and value of constructed type. |
|
342 TAny CreateStart(TBerTag aTag, TBool aDefinite); |
|
343 // Save type. |
|
344 TAny CreateEnd(); |
|
345 |
|
346 // This fuction can be used to create a BER object |
|
347 // from buffer, which already contains a full BER |
|
348 // encoded object. |
|
349 TAny CreateBEREncodedObject(TDesC8* aBuffer); |
|
350 |
|
351 |
|
352 public: // Data. |
|
353 // Maximum sixe of TUint. |
|
354 // static TUint iMaxUint; |
|
355 TUint iMaxUint; |
|
356 |
|
357 // Maximum sixe of TInt. |
|
358 //static TInt iMaxInt; |
|
359 TInt iMaxInt; |
|
360 |
|
361 private: // Data |
|
362 // Type. |
|
363 TBerTag iType; |
|
364 |
|
365 // iValue is used in encoding |
|
366 TInt iValue; |
|
367 // Pointer to value (encoding). |
|
368 TDesC8* iValuePtr; |
|
369 RInteger iInt; |
|
370 |
|
371 // Amount of length bytes. |
|
372 TUint8 iLenLen; |
|
373 |
|
374 // Indefinite length or not. |
|
375 TBool iIndefinite; |
|
376 |
|
377 // These indexes indicate places in the CCrData |
|
378 // object pointed by the member iData. |
|
379 TUint iObjectBegin; // Place where whole BER object begins. |
|
380 TUint iContentBegin; // Place where BER object's content begins. |
|
381 TUint iContentLen; // Length of the BER object's content. |
|
382 TUint iObjectLen; // Length of the whole BER object. |
|
383 |
|
384 // Pointer to the object containing the actual object. |
|
385 CCrData* iData; |
|
386 |
|
387 |
|
388 // Nesting level of this object. Not set in this object, |
|
389 // but given by caller. |
|
390 TInt iLevel; |
|
391 |
|
392 // End of content bytes. |
|
393 // static TUint8 iEOCBytes[2]; |
|
394 TUint8 iEOCBytes[2]; |
|
395 |
|
396 }; |
|
397 |
|
398 /** |
|
399 * Class CCrBerSet |
|
400 * CCrBerSet contains set of CCrBer objects. |
|
401 * |
|
402 * @lib crber.lib |
|
403 * @since Series 60 3.0 |
|
404 */ |
|
405 class CCrBerSet : public CArrayPtrSeg<CCrBer> |
|
406 { |
|
407 ///////////////////////////////////////////// |
|
408 // Constructors and destructors. |
|
409 private: |
|
410 CCrBerSet(TInt aGranularity); |
|
411 TAny ConstructL(); |
|
412 |
|
413 |
|
414 public: |
|
415 IMPORT_C static CCrBerSet* NewLC(TInt aGranularity); |
|
416 IMPORT_C static CCrBerSet* NewL(TInt aGranularity); |
|
417 IMPORT_C ~CCrBerSet(); |
|
418 |
|
419 |
|
420 ///////////////////////////////////////////// |
|
421 // Functions. |
|
422 |
|
423 // Opens next BER encoded object from the current position of |
|
424 // given CCrData to this object set. Opens also all nested BER |
|
425 // objects as deep as aRecursionLevel tells. If it is zero, one |
|
426 // object is read, if it is one, all objects at first level are |
|
427 // read, if it is 255, all objects at 255 first levels are |
|
428 // extracted, and if it is 256, all objects at any level are |
|
429 // extracted. Returns the amount of extracted objects. |
|
430 // The data pointer of CCrData points right after the |
|
431 // opened BER object after this function is finished. |
|
432 IMPORT_C TUint OpenL( |
|
433 CCrData* aData, |
|
434 TUint8 aRecursionLevel = 1); |
|
435 |
|
436 // Appends given new object into this set. Updates all previous |
|
437 // items in this set, which have indefinite length, with the |
|
438 // length of the new object. |
|
439 IMPORT_C TAny AppendAndUpdateL(CCrBer *aBerObject); |
|
440 |
|
441 // Updates all previous items in this set, which have |
|
442 // indefinite length, with the length of the new object. |
|
443 IMPORT_C TAny Update(CCrBer *aBerObject); |
|
444 |
|
445 // Finds last open indefinite length sequence |
|
446 // or set from this set at given level and closes it. |
|
447 IMPORT_C TAny CloseLastSeqOrSet(TUint aLevel); |
|
448 |
|
449 |
|
450 //////////////////////////////////////////// |
|
451 // Encoding functions |
|
452 |
|
453 // Function creates Ber boolean object (CCrBer object). |
|
454 // Write a object to CCrData (file) by Flush(..) |
|
455 // (ETrue or EFalse) (Tag 01) |
|
456 IMPORT_C TAny CreateBoolL(TBool aValue); |
|
457 |
|
458 // Function creates Ber integer object (CCrBer object). |
|
459 // Write a object to CCrData (file) by Flush(..) Parameter is either |
|
460 // a positive whole number, or a negative whole number, or zero. |
|
461 IMPORT_C TAny CreateIntL(TInt aValue); |
|
462 IMPORT_C TAny CreateLongIntL(RInteger& aValue); |
|
463 |
|
464 // Function creates Ber octet string object. |
|
465 // The OCTET STRING is an arbitrarily long binary value. |
|
466 IMPORT_C TAny CreateOctetL(TDesC8& aString); |
|
467 IMPORT_C TAny CreateOctetL(CCrData* aData); |
|
468 |
|
469 |
|
470 // Function creates Ber null object (CCrBer object). |
|
471 // (0x05 0x00). |
|
472 IMPORT_C TAny CreateNullL(); |
|
473 |
|
474 // Function creates Ber object identifier object. |
|
475 // type tag = (0x06) |
|
476 // e.g. berSet->AppendObjectId(_L8("1.2.3.4.5") |
|
477 IMPORT_C TAny CreateOIdL(TDesC8& aString); |
|
478 |
|
479 // Function creates Ber Numeric string object (CCrBer object). |
|
480 // The NumericString is defined to only contain the characters 0-9 |
|
481 // and space. |
|
482 IMPORT_C TAny CreateNumericL(TDesC8& aString); |
|
483 |
|
484 // Function creates Ber Printable string object (CCrBer object) |
|
485 // The PrintableString is defined to only contain |
|
486 // the characters A-Z, a-z, 0-9, space, |
|
487 // and the punctuation characters ()-+=:',./?. |
|
488 IMPORT_C TAny CreatePrintableL(TDesC8& aString); |
|
489 |
|
490 // Function creates Ber T61 string object (CCrBer object). |
|
491 // The TeletexString is a string, containing characters |
|
492 // according to the T.61 character set. |
|
493 IMPORT_C TAny CreateT61L(TDesC8& aString); |
|
494 |
|
495 // Function creates Ber Video text object (CCrBer object) |
|
496 // type tag = (0x15). |
|
497 IMPORT_C TAny CreateVideoTexL(TDesC8& aString); |
|
498 |
|
499 // Function creates Ber IA5 string object (CCrBer object). |
|
500 // IA5 (International Alphabet 5) |
|
501 // is equivalent to US-ASCII. |
|
502 IMPORT_C TAny CreateIA5L(TDesC8& aString); |
|
503 |
|
504 // Function creates Ber UTC time object (CCrBer object). |
|
505 // Note this value only represents years using two digits. |
|
506 // e.g. berSet->AppendUTCTime(_L8("980801000000Z")); |
|
507 IMPORT_C TAny CreateUTCL(TDesC8& aString); |
|
508 |
|
509 // Function creates Ber generalised time object |
|
510 // (CCrBer object). type = (0x18). Unlike UTCTime |
|
511 // it represents years using 4 digits. |
|
512 IMPORT_C TAny CreateGenTimeL(TDesC8& aString); |
|
513 |
|
514 // Function creates Ber graphical string object (CCrBer object) |
|
515 // type byte = (0x19). |
|
516 IMPORT_C TAny CreateGraphicalL(TDesC8& aString); |
|
517 |
|
518 // Function creates Ber visible string object (CCrBer object) |
|
519 // type = (0x1A). |
|
520 IMPORT_C TAny CreateVisibleL(TDesC8& aString); |
|
521 |
|
522 // Function creates Ber general string object (CCrBer object) |
|
523 // type = (0x1B). |
|
524 IMPORT_C TAny CreateGeneralL(TDesC8& aString); |
|
525 |
|
526 // Append start of sequence (30 xx, xx = length) |
|
527 // True --> DefiniteLen, False --> IndefiniteLength. |
|
528 IMPORT_C TAny CreateSeqStartL(TBool aDefinite); |
|
529 |
|
530 // Append start of set (31 xx, xx = length) |
|
531 // True --> DefiniteLen, False --> IndefiniteLength. |
|
532 IMPORT_C TAny CreateSetStartL(TBool aDefinite); |
|
533 |
|
534 // Append start of the constructed. |
|
535 IMPORT_C TAny CreateConstructedStartL(TBerTag aTag, TBool aDefinite); |
|
536 |
|
537 // Append end to last constructed (e.g. seq) |
|
538 // type (definite or indefinite). |
|
539 IMPORT_C TAny CreateEndL(); |
|
540 |
|
541 // This fuction can be used to create a BER object |
|
542 // from buffer, which already contains a full BER |
|
543 // encoded object. |
|
544 IMPORT_C TAny CreateBEREncodedObjectL(TDesC8& aBuffer); |
|
545 |
|
546 // Function writes all created crber objects (which are |
|
547 // AppendL to set) to file. Function also fix all definite |
|
548 // lengths. Call this function then crberSet is ready |
|
549 // (all berObjects are delived). |
|
550 IMPORT_C TInt FlushL(CCrData* aTarget); |
|
551 |
|
552 public: |
|
553 |
|
554 // Encode and write object identifier. |
|
555 TInt AppendObjectIdL(const TDesC8& aString,TBool aOnlyLen = EFalse); |
|
556 |
|
557 private: |
|
558 // These functions are used by CCrBerSet::Flush(...) |
|
559 |
|
560 // Write constructed type start. |
|
561 TInt AppendConstructedL(TBerTag aTag, TUint aLength = 0); |
|
562 |
|
563 // close indefinite length. (= add 0x00 0x00) |
|
564 TInt CloseIndefinite(); |
|
565 |
|
566 // Encode and write boolean object. |
|
567 TInt AppendBoolL(TBool aBool); |
|
568 |
|
569 // Encode and write integer object. |
|
570 TInt AppendIntL(TInt aData); |
|
571 TInt AppendLongIntL(RInteger& aData); |
|
572 |
|
573 // Encode and write null object. (0x05 0x00) |
|
574 TInt AppendNull(); |
|
575 |
|
576 // Encode and write string to CCrData (file). |
|
577 TInt AppendStringL(TBerTag aTag, const TDesC8& aString); |
|
578 TInt AppendStringL(TBerTag aTag, CCrData* const aData); |
|
579 |
|
580 // Write BER encoded object to CCrData (file). |
|
581 // Note that this function doesn't add any tags |
|
582 // etc. it trusts that the given object already |
|
583 // is a whole BER encoded object. |
|
584 TInt AppendBerEncodedObject(const TDesC8& aString); |
|
585 |
|
586 private: // Data |
|
587 |
|
588 // Target file for objects (encoding). |
|
589 CCrData* iTarget; |
|
590 |
|
591 // Nesting level of object. (encoding). |
|
592 TInt iLevel; |
|
593 |
|
594 // Max level which is used in encoding. (Flush(..)) |
|
595 TInt iMaxLevel; |
|
596 }; |
|
597 |
|
598 #endif CR_BER |