|
1 /* |
|
2 * Copyright (c) 2004-2009 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 the License "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 * Note: This file may contain code to generate corrupt files for test purposes. |
|
16 * Such code is excluded from production builds by use of compiler defines; |
|
17 * it is recommended that such code should be removed if this code is ever published publicly. |
|
18 * As specified in SGL.GT0188.251 |
|
19 * |
|
20 */ |
|
21 |
|
22 |
|
23 /** |
|
24 @file |
|
25 @internalComponent |
|
26 @released |
|
27 */ |
|
28 |
|
29 #ifndef __SISEXPRESSION_H__ |
|
30 #define __SISEXPRESSION_H__ |
|
31 |
|
32 |
|
33 #include "structure.h" |
|
34 #include "sisstring.h" |
|
35 #include "sequence.h" |
|
36 #include "numeric.h" |
|
37 #include "sislanguage.h" |
|
38 |
|
39 const std::wstring KFuncVersionPrefix = L"\\sys\\install\\pkgversion\\?"; |
|
40 const std::wstring KFuncSupportedLanguagePrefix = L"\\sys\\install\\supportedlanguage\\?"; |
|
41 |
|
42 class CSISExpression : public CStructure <CSISFieldRoot::ESISExpression> |
|
43 |
|
44 { |
|
45 public: |
|
46 typedef enum { |
|
47 EOpNone = 0, |
|
48 EBinOpEqual, |
|
49 EBinOpNotEqual, |
|
50 EBinOpGreaterThan, |
|
51 EBinOpLessThan, |
|
52 EBinOpGreaterThanOrEqual, |
|
53 EBinOpLessThanOrEqual, |
|
54 ELogOpAnd, |
|
55 ELogOpOr, |
|
56 EUnaryOpNot, |
|
57 EFuncExists, |
|
58 EFuncAppProperties, |
|
59 EFuncDevProperties, |
|
60 EPrimTypeString, |
|
61 EPrimTypeOption, |
|
62 EPrimTypeVariable, |
|
63 EPrimTypeNumber, |
|
64 EOpUnknown |
|
65 } TOperator; |
|
66 |
|
67 void InsertMembers (); |
|
68 |
|
69 private: |
|
70 void AddLeaf (); |
|
71 void AddLeaf (const CSISExpression& aExpression); |
|
72 |
|
73 public: |
|
74 CSISExpression (); |
|
75 CSISExpression (const bool aRequired); |
|
76 CSISExpression (const TOperator aOperator); |
|
77 CSISExpression (const CSISExpression& aInitialiser); |
|
78 |
|
79 virtual void Verify (const TUint32 aLanguages) const; |
|
80 virtual std::string Name () const; |
|
81 #ifdef GENERATE_ERRORS |
|
82 virtual void CreateDefects (); |
|
83 #endif // GENERATE_ERRORS |
|
84 |
|
85 CSISExpression& operator = (const CSISExpression& aExpression); |
|
86 |
|
87 const CSISExpression& LHS () const; |
|
88 CSISExpression& LHS (); |
|
89 const CSISExpression& RHS () const; |
|
90 CSISExpression& RHS (); |
|
91 |
|
92 void SetValue (const CSISString& aValue); |
|
93 void SetValue (const TUint32 aValue); |
|
94 void SetAlwaysTrue (); |
|
95 void SetOperator (const TOperator aOperator); |
|
96 void SetOperator (const TOperator aOperator, const CSISExpression& aLHS); |
|
97 void SetLanguage (); |
|
98 void SetNumeric (const TInt32 aValue); |
|
99 void SetLanguageComparision (const TInt32 aValue); |
|
100 void SetVariable (const std::wstring& aIdentifier); |
|
101 void AddPackageEntry(std::wostream& aStream, bool aVerbose) const; |
|
102 inline CSISUInt32 Operator() const; |
|
103 inline const CSISString& String() const; |
|
104 inline TInt IntValue() const; |
|
105 |
|
106 void WriteVersionCondition (std::wostream& aStream, bool aVerbose) const; |
|
107 void WriteSupportedLanguageCondition (std::wostream& aStream, bool aVerbose) const; |
|
108 static bool ExtractNextToken(std::wstring& aParseString, std::wstring& aTokenString); |
|
109 static bool IsHexadecimal(const std::wstring& aString); |
|
110 static bool IsHexadecimal(const std::wstring& aString, TUint32& aHexValue); |
|
111 static bool IsDecimal(const std::wstring& aString, TInt& aDecimalValue); |
|
112 |
|
113 private: |
|
114 CSISUInt32 iOperator; |
|
115 CSISInt32 iInteger; |
|
116 CSISString iString; |
|
117 CSequence <CSISExpression, CSISFieldRoot::ESISExpression> iLeaf; |
|
118 }; |
|
119 |
|
120 |
|
121 |
|
122 inline CSISExpression::CSISExpression () : |
|
123 iString (false) |
|
124 { |
|
125 InsertMembers (); |
|
126 } |
|
127 |
|
128 |
|
129 inline CSISExpression::CSISExpression (const bool aRequired) : |
|
130 CStructure <CSISFieldRoot::ESISExpression> (aRequired), |
|
131 iString (false) |
|
132 { |
|
133 InsertMembers (); |
|
134 } |
|
135 |
|
136 |
|
137 inline CSISExpression::CSISExpression (const TOperator aOperator) : |
|
138 iOperator (aOperator), |
|
139 iString (false) |
|
140 { |
|
141 InsertMembers (); |
|
142 } |
|
143 |
|
144 |
|
145 inline void CSISExpression::AddLeaf () |
|
146 { |
|
147 assert (iLeaf.size () < 2); |
|
148 iLeaf.Push (CSISExpression ()); |
|
149 } |
|
150 |
|
151 |
|
152 inline void CSISExpression::AddLeaf (const CSISExpression& aExpression) |
|
153 { |
|
154 assert (iLeaf.size () < 2); |
|
155 iLeaf.Push (aExpression); |
|
156 } |
|
157 |
|
158 |
|
159 inline const CSISExpression& CSISExpression::LHS () const |
|
160 { |
|
161 assert (iLeaf.size () > 0); |
|
162 return iLeaf [0]; |
|
163 } |
|
164 |
|
165 |
|
166 inline CSISExpression& CSISExpression::LHS () |
|
167 { |
|
168 assert (iLeaf.size () > 0); |
|
169 return iLeaf [0]; |
|
170 } |
|
171 |
|
172 |
|
173 inline const CSISExpression& CSISExpression::RHS () const |
|
174 { |
|
175 return iLeaf.Last (); |
|
176 } |
|
177 |
|
178 |
|
179 inline CSISExpression& CSISExpression::RHS () |
|
180 { |
|
181 return iLeaf.Last (); |
|
182 } |
|
183 |
|
184 |
|
185 inline void CSISExpression::SetValue (const CSISString& aValue) |
|
186 { |
|
187 iString = aValue; |
|
188 } |
|
189 |
|
190 |
|
191 inline void CSISExpression::SetValue (const TUint32 aValue) |
|
192 { |
|
193 iInteger = aValue; |
|
194 } |
|
195 |
|
196 |
|
197 inline void CSISExpression::SetAlwaysTrue () |
|
198 { |
|
199 SetOperator (EUnaryOpNot); |
|
200 RHS ().SetOperator (EPrimTypeNumber); |
|
201 RHS ().SetValue (0); |
|
202 } |
|
203 |
|
204 inline void CSISExpression::SetOperator (const TOperator aOperator) |
|
205 { |
|
206 SetOperator (aOperator, CSISExpression ()); |
|
207 } |
|
208 |
|
209 #ifdef GENERATE_ERRORS |
|
210 inline void CSISExpression::CreateDefects () |
|
211 { |
|
212 if (CSISFieldRoot::IsBugToBeCreated (CSISFieldRoot::EBugInvalidValues)) |
|
213 { |
|
214 iOperator = rand (); |
|
215 } |
|
216 } |
|
217 #endif // GENERATE_ERRORS |
|
218 |
|
219 inline void CSISExpression::SetNumeric (const TInt32 aValue) |
|
220 { |
|
221 iOperator = EPrimTypeNumber; |
|
222 iInteger = aValue; |
|
223 } |
|
224 |
|
225 inline std::string CSISExpression::Name () const |
|
226 { |
|
227 return "Expression"; |
|
228 } |
|
229 |
|
230 inline CSISUInt32 CSISExpression::Operator() const |
|
231 { |
|
232 return iOperator; |
|
233 } |
|
234 |
|
235 inline const CSISString& CSISExpression::String() const |
|
236 { |
|
237 return iString; |
|
238 } |
|
239 |
|
240 |
|
241 inline TInt CSISExpression::IntValue() const |
|
242 { |
|
243 return iInteger; |
|
244 } |
|
245 |
|
246 #endif // __SISEXPRESSION_H__ |
|
247 |