|
1 /* |
|
2 * Copyright (c) 2006-2007 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 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include "natfwunsaftextattribute.h" |
|
22 |
|
23 // ----------------------------------------------------------------------------- |
|
24 // CNATFWUNSAFTextAttribute::CNATFWUNSAFTextAttribute |
|
25 // ----------------------------------------------------------------------------- |
|
26 // |
|
27 CNATFWUNSAFTextAttribute::CNATFWUNSAFTextAttribute() |
|
28 { |
|
29 } |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // CNATFWUNSAFTextAttribute::ConstructL |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 void CNATFWUNSAFTextAttribute::ConstructL(const TDesC8& aValue) |
|
36 { |
|
37 iValue = aValue.AllocL(); |
|
38 } |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CNATFWUNSAFTextAttribute::~CNATFWUNSAFTextAttribute |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 CNATFWUNSAFTextAttribute::~CNATFWUNSAFTextAttribute() |
|
45 { |
|
46 delete iValue; |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CNATFWUNSAFTextAttribute::EncodeValueL |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 HBufC8* CNATFWUNSAFTextAttribute::EncodeValueL() const |
|
54 { |
|
55 __TEST_INVARIANT; |
|
56 |
|
57 return iValue->AllocL(); |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CNATFWUNSAFTextAttribute::Value |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 EXPORT_C const TDesC8& CNATFWUNSAFTextAttribute::Value() const |
|
65 { |
|
66 __TEST_INVARIANT; |
|
67 |
|
68 return *iValue; |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CNATFWUNSAFTextAttribute::DecodeL |
|
73 // ConstructL will check the value part's length is valid |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 void CNATFWUNSAFTextAttribute::DecodeL(const TDesC8& aByteStream) |
|
77 { |
|
78 TUint16 valueLength = ParseLengthL(aByteStream); |
|
79 |
|
80 //Stream has to have enough data for the whole value element |
|
81 __ASSERT_ALWAYS(aByteStream.Length() >= EValueOffset + valueLength, |
|
82 User::Leave(KErrArgument)); |
|
83 ConstructL(aByteStream.Mid(EValueOffset, valueLength)); |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CNATFWUNSAFTextAttribute::__DbgTestInvariant |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 void CNATFWUNSAFTextAttribute::__DbgTestInvariant() const |
|
91 { |
|
92 #if defined(_DEBUG) |
|
93 if (!iValue) |
|
94 { |
|
95 User::Invariant(); |
|
96 } |
|
97 #endif |
|
98 } |