|
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 "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: CGI parser and generator |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "nsmlcgiscriptparser.h" |
|
22 |
|
23 |
|
24 // CONSTANTS |
|
25 const TInt KNSmlGranularity = 4; |
|
26 |
|
27 |
|
28 // ============================ MEMBER FUNCTIONS =============================== |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CNSmlCGIScript::CNSmlCGIScript |
|
32 // C++ default constructor. |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 CNSmlCGIScript::CNSmlCGIScript() |
|
36 { |
|
37 } |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CNSmlCGIScript::NewL |
|
41 // Two-phased constructor. |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 EXPORT_C CNSmlCGIScript* CNSmlCGIScript::NewL() |
|
45 { |
|
46 CNSmlCGIScript* self = NewLC(); |
|
47 CleanupStack::Pop(); // self |
|
48 return self; |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CNSmlCGIScript::NewLC |
|
53 // Two-phased constructor. |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 EXPORT_C CNSmlCGIScript* CNSmlCGIScript::NewLC() |
|
57 { |
|
58 CNSmlCGIScript* self = new ( ELeave ) CNSmlCGIScript(); |
|
59 CleanupStack::PushL( self ); |
|
60 self->ConstructL(); |
|
61 return self; |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CNSmlCGIScript::~CNSmlCGIScript |
|
66 // Destructor. |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 CNSmlCGIScript::~CNSmlCGIScript() |
|
70 { |
|
71 delete iCGIScript; |
|
72 Clear(); |
|
73 delete iScriptParts; |
|
74 } |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // CNSmlCGIScript::ConstructL |
|
78 // Symbian 2nd phase constructor. |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 void CNSmlCGIScript::ConstructL() |
|
82 { |
|
83 iSeparator = ENSmlCGIScriptLogicalOperatorAnd; |
|
84 iScriptParts = new (ELeave) CArrayPtrFlat<TNSmlCGIScriptPart>( KNSmlGranularity ); |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CNSmlCGIScript::LogicalOperator |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 EXPORT_C TNSmlCGIScriptLogicalOperator CNSmlCGIScript::LogicalOperator() const |
|
92 { |
|
93 return iSeparator; |
|
94 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CNSmlCGIScript::SetLogicalOperator |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 EXPORT_C void CNSmlCGIScript::SetLogicalOperator( const TNSmlCGIScriptLogicalOperator aSeparator ) |
|
101 { |
|
102 iSeparator = aSeparator; |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CNSmlCGIScript::CGIScript |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 EXPORT_C HBufC* CNSmlCGIScript::CGIScript() const |
|
110 { |
|
111 return iCGIScript; |
|
112 } |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CNSmlCGIScript::SetCGIScriptL |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 EXPORT_C void CNSmlCGIScript::SetCGIScriptL( const TDesC& aCGIScript ) |
|
119 { |
|
120 if ( iCGIScript ) |
|
121 { |
|
122 delete iCGIScript; |
|
123 iCGIScript = NULL; |
|
124 } |
|
125 iCGIScript = HBufC::NewL( aCGIScript.Length() ); |
|
126 *iCGIScript = aCGIScript; |
|
127 } |
|
128 |
|
129 // ----------------------------------------------------------------------------- |
|
130 // CNSmlCGIScript::Count |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 EXPORT_C TInt CNSmlCGIScript::Count() const |
|
134 { |
|
135 return iScriptParts->Count(); |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CNSmlCGIScript::Get |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 EXPORT_C const TNSmlCGIScriptPart* CNSmlCGIScript::Get( TInt aIndex ) const |
|
143 { |
|
144 return iScriptParts->At( aIndex ); |
|
145 } |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // CNSmlCGIScript::AddL |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 EXPORT_C void CNSmlCGIScript::AddL( TNSmlCGIScriptPart* aRecordPart ) |
|
152 { |
|
153 iScriptParts->AppendL( aRecordPart ); |
|
154 } |
|
155 |
|
156 // ----------------------------------------------------------------------------- |
|
157 // CNSmlCGIScript::Remove |
|
158 // ----------------------------------------------------------------------------- |
|
159 // |
|
160 EXPORT_C TNSmlCGIScriptPart* CNSmlCGIScript::Remove( TInt aIndex ) |
|
161 { |
|
162 TNSmlCGIScriptPart* temp = iScriptParts->At( aIndex ); |
|
163 iScriptParts->Delete( aIndex ); |
|
164 return temp; |
|
165 } |
|
166 |
|
167 // ----------------------------------------------------------------------------- |
|
168 // CNSmlCGIScript::Clear |
|
169 // ----------------------------------------------------------------------------- |
|
170 // |
|
171 EXPORT_C void CNSmlCGIScript::Clear() |
|
172 { |
|
173 for ( TInt i = 0; i < iScriptParts->Count(); i++ ) |
|
174 { |
|
175 TNSmlCGIScriptPart* temp = iScriptParts->At( i ); |
|
176 delete temp->iName; |
|
177 temp->iName = NULL; |
|
178 delete temp->iData; |
|
179 temp->iData = NULL; |
|
180 } |
|
181 iScriptParts->ResetAndDestroy(); |
|
182 } |
|
183 |
|
184 |
|
185 // End of File |