|
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 * As specified in SGL.GT0188.251 |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 @publishedPartner |
|
23 @released |
|
24 */ |
|
25 |
|
26 #ifndef __SISSTRING_H__ |
|
27 #define __SISSTRING_H__ |
|
28 |
|
29 |
|
30 #include "field.h" |
|
31 |
|
32 class CSISString : public CSISField <CSISFieldRoot::ESISString> |
|
33 { |
|
34 public: |
|
35 /** |
|
36 * Default constructor |
|
37 */ |
|
38 CSISString (); |
|
39 /** |
|
40 * Creates an instance of the class from wstring objec. |
|
41 */ |
|
42 CSISString (const std::wstring& aValue); |
|
43 /** |
|
44 * Creates an instance of this class. |
|
45 * @param aRequired false if the object is optional else true. |
|
46 */ |
|
47 CSISString (const bool aRequired); |
|
48 /** |
|
49 * Creates an instance of the class from wstring objec. |
|
50 * @param aRequired false if the object is optional else true. |
|
51 */ |
|
52 CSISString (const std::wstring initialValue, const bool aRequired); |
|
53 /** |
|
54 * Copy constructor. |
|
55 */ |
|
56 CSISString (const CSISString& aString); |
|
57 |
|
58 /** |
|
59 * Internalize the class. |
|
60 * @param aFile Stream from which the content should be read. |
|
61 * @param aContainerSize Size of the content to be read. |
|
62 * @param aArrayType type of the structure. |
|
63 */ |
|
64 virtual void Read (TSISStream& aFile, const TFieldSize& aContainerSize, const CSISFieldRoot::TFieldType aArrayType = CSISFieldRoot::ESISUndefined); |
|
65 /** |
|
66 * Externalize the class. |
|
67 * @param aFile stream to which the content needs to be written. |
|
68 * @param aIsArrayElement Whether the instance is part of an array or not. |
|
69 */ |
|
70 virtual void Write (TSISStream& aFile, const bool aIsArrayElement) const; |
|
71 /** |
|
72 * Actual size of the content in memory. |
|
73 * @param aInsideArray Whethere the instance is part of an array or not. |
|
74 */ |
|
75 virtual TFieldSize ByteCount (const bool aInsideArray) const; |
|
76 /** |
|
77 * Write the content into the stream. |
|
78 * @param aStream Stream to which the data needs to be written. |
|
79 * @param aLevel. |
|
80 */ |
|
81 virtual void Dump (std::ostream& aStream, const int aLevel) const; |
|
82 /** |
|
83 * Check whether the content needs to be written into the stream or |
|
84 * not. For string if it is empty there is no need in trying to write |
|
85 * this content. |
|
86 */ |
|
87 virtual bool WasteOfSpace () const; |
|
88 /** |
|
89 * Calculate CRC of the data. |
|
90 * @param aCRC CRC value of the string. |
|
91 * @param aIsArrayElement Whether the instance is part of an array or not. |
|
92 */ |
|
93 virtual void CalculateCrc (TCRC& aCRC, const bool aIsArrayElement) const; |
|
94 /** |
|
95 * Get a copy of the string. |
|
96 */ |
|
97 std::wstring GetString() const; |
|
98 |
|
99 /** |
|
100 * Number of characters in the string. |
|
101 */ |
|
102 TUint32 size () const; |
|
103 /** |
|
104 * Empty the string. |
|
105 */ |
|
106 bool empty () const; |
|
107 /** |
|
108 * Assignment operator. |
|
109 */ |
|
110 CSISString& operator = (const std::wstring& aString); |
|
111 /** |
|
112 * Assignment operator. |
|
113 */ |
|
114 CSISString& operator = (const wchar_t* aString); |
|
115 /** |
|
116 * Assignment operator. |
|
117 */ |
|
118 CSISString& operator = (const CSISString& aString); |
|
119 |
|
120 /** |
|
121 * == operator. Compare the content of the class and aString |
|
122 */ |
|
123 bool operator == (const std::wstring& aString) const; |
|
124 /** |
|
125 * == operator. Compare the content of the class and aString |
|
126 */ |
|
127 bool operator == (const wchar_t* aString) const; |
|
128 /** |
|
129 * == operator. Compare the content of the class and aString |
|
130 */ |
|
131 bool operator == (const CSISString& aString) const; |
|
132 |
|
133 /** |
|
134 * != operator. Compare the content of the class and aString |
|
135 */ |
|
136 bool operator != (const std::wstring& aString) const; |
|
137 /** |
|
138 * != operator. Compare the content of the class and aString |
|
139 */ |
|
140 bool operator != (const wchar_t* aString) const; |
|
141 /** |
|
142 * != operator. Compare the content of the class and aString |
|
143 */ |
|
144 bool operator != (const CSISString& aString) const; |
|
145 |
|
146 /** |
|
147 * Adds the write the package details into the stream. |
|
148 * @param aStream - Stream in which the package entries need to be written. |
|
149 * @param aVerbose - If this option is set then detail description of pkg |
|
150 * will be written into the stream. |
|
151 */ |
|
152 void AddPackageEntry(std::wostream& aStream, bool aVerbose) const; |
|
153 |
|
154 /** |
|
155 * Delete the temporary buffer used for reading the string. |
|
156 * Should be called after this class is not required anymore. |
|
157 */ |
|
158 static void ExitInstance (); |
|
159 |
|
160 private: |
|
161 std::wstring iData; |
|
162 |
|
163 }; |
|
164 |
|
165 |
|
166 |
|
167 |
|
168 inline CSISString::CSISString () |
|
169 { |
|
170 } |
|
171 |
|
172 |
|
173 inline CSISString::CSISString (const std::wstring& aValue) : |
|
174 iData (aValue) |
|
175 { |
|
176 } |
|
177 |
|
178 |
|
179 inline CSISString::CSISString (const bool aRequired) : |
|
180 CSISField<CSISFieldRoot::ESISString> (aRequired) |
|
181 { |
|
182 } |
|
183 |
|
184 |
|
185 inline CSISString::CSISString (const std::wstring initialValue, const bool aRequired) : |
|
186 CSISField<CSISFieldRoot::ESISString> (aRequired), |
|
187 iData (initialValue) |
|
188 { |
|
189 } |
|
190 |
|
191 |
|
192 inline CSISString::CSISString (const CSISString& aString) : |
|
193 CSISField<CSISFieldRoot::ESISString> (aString.Required ()), |
|
194 iData (aString.iData) |
|
195 { |
|
196 } |
|
197 |
|
198 |
|
199 inline TUint32 CSISString::size () const |
|
200 { |
|
201 return static_cast <TUint32> (iData.size ()); |
|
202 } |
|
203 |
|
204 |
|
205 inline CSISString& CSISString::operator = (const std::wstring& aString) |
|
206 { |
|
207 iData = aString; |
|
208 return *this; |
|
209 } |
|
210 |
|
211 |
|
212 inline CSISString& CSISString::operator = (const CSISString& aString) |
|
213 { |
|
214 iData = aString.iData; |
|
215 return *this; |
|
216 } |
|
217 |
|
218 inline CSISString& CSISString::operator = (const wchar_t* aString) |
|
219 { |
|
220 if (aString) |
|
221 { |
|
222 iData = aString; |
|
223 } |
|
224 return *this; |
|
225 } |
|
226 |
|
227 |
|
228 inline bool CSISString::operator == (const std::wstring& aString) const |
|
229 { |
|
230 return iData == aString; |
|
231 } |
|
232 |
|
233 inline bool CSISString::operator == (const CSISString& aString) const |
|
234 { |
|
235 return iData == aString.iData; |
|
236 } |
|
237 |
|
238 inline bool CSISString::operator == (const wchar_t* aString) const |
|
239 { |
|
240 if (aString == NULL) |
|
241 { |
|
242 return false; |
|
243 } |
|
244 return iData.compare (aString) == 0; |
|
245 } |
|
246 |
|
247 |
|
248 inline bool CSISString::operator != (const std::wstring& aString) const |
|
249 { |
|
250 return iData != aString; |
|
251 } |
|
252 |
|
253 inline bool CSISString::operator != (const CSISString& aString) const |
|
254 { |
|
255 return iData != aString.iData; |
|
256 } |
|
257 |
|
258 inline bool CSISString::operator != (const wchar_t* aString) const |
|
259 { |
|
260 if (aString == NULL) |
|
261 { |
|
262 return true; |
|
263 } |
|
264 return iData.compare (aString) != 0; |
|
265 } |
|
266 |
|
267 |
|
268 inline bool CSISString::empty () const |
|
269 { |
|
270 return iData.empty (); |
|
271 } |
|
272 |
|
273 inline std::wstring CSISString::GetString() const |
|
274 { |
|
275 return iData; |
|
276 } |
|
277 |
|
278 inline void CSISString::AddPackageEntry(std::wostream& aStream, bool aVerbose) const |
|
279 { |
|
280 (void)aVerbose; |
|
281 aStream << iData; |
|
282 } |
|
283 |
|
284 #endif // __SISSTRING_H__ |
|
285 |