|
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // DST TZ Database Compiler |
|
15 // |
|
16 // |
|
17 |
|
18 #include "TzGlobals.h" |
|
19 #include "TzTables.h" |
|
20 #include "TZNode.h" |
|
21 #include "TZDocument.h" |
|
22 #include "TzHelpers.h" |
|
23 #include <algorithm> // sort |
|
24 #include <iostream> |
|
25 #include <fstream> |
|
26 #include <cstdio> |
|
27 using namespace std; |
|
28 //============================================================================ |
|
29 // CTzCpLinksTable::CTzCpLinksTable |
|
30 //============================================================================ |
|
31 CTzCpLinksTable::CTzCpLinksTable(CTZDocument& aDocument) |
|
32 : CPersistedEntityWrapper(aDocument) |
|
33 { |
|
34 } |
|
35 //============================================================================ |
|
36 // CTzCpLinksTable::AssembleL |
|
37 // Adds a link node to the link table. At this stage a CTzCpLink consists of |
|
38 // two CTzCpString pointers. One is to the string for the link, the other is |
|
39 // the name of the linked zone. The actual zone to be linked will be resolved |
|
40 // during the linker stage of the compilation process. When the link table is |
|
41 // externalised the persisted class (TTzLink) will be populated with the |
|
42 // offsets to the string and linkedzone objects in the database |
|
43 //============================================================================ |
|
44 CTzCpLink& CTzCpLinksTable::AssembleL(CTZNode& aNode) |
|
45 { |
|
46 CTzCpLink* aNewLink = new CTzCpLink(iDocument); |
|
47 aNewLink->AssembleL(aNode); |
|
48 iVector.push_back(aNewLink); |
|
49 return *aNewLink; |
|
50 } |
|
51 //============================================================================ |
|
52 // CTzCpLinksTable::ExternaliseL |
|
53 // Write the links table to a file |
|
54 //============================================================================ |
|
55 void CTzCpLinksTable::ExternaliseL(ofstream& aFilestream) |
|
56 { |
|
57 iDocument.DbHeader()->iOffsetToLinksTable = aFilestream.tellp(); |
|
58 // write out the number of links |
|
59 TUint16 numLinks = iVector.size(); |
|
60 aFilestream.write((char*)&numLinks,sizeof(numLinks)); |
|
61 |
|
62 for (int x = 0; x < numLinks;x++) |
|
63 { |
|
64 iVector[x]->ExternaliseL(aFilestream); |
|
65 } |
|
66 } |
|
67 |
|
68 //============================================================================ |
|
69 // CTzCpLinksTable::FindZone |
|
70 // Given a link name, returns the "real" database zone it links to |
|
71 // (allowing for "cascade linking": link_1 -> link_2 -> ... -> link_n -> Zone) |
|
72 //============================================================================ |
|
73 CTzCpZone* CTzCpLinksTable::FindZone(std::string& aLinkName) |
|
74 { |
|
75 CTzCpZone* zone = NULL; |
|
76 std::string name = aLinkName; |
|
77 |
|
78 // iterate through the collection of links |
|
79 std::vector<CTzCpLink*>::iterator iter = iVector.begin(); |
|
80 CTzCpLink** lastElementPtr = iVector.end(); |
|
81 while(iter != lastElementPtr) |
|
82 { |
|
83 if ((*iter)->iLinkString->iString == name) |
|
84 { |
|
85 // name appears as the "old name" in one of the links |
|
86 // recursively search for the new name |
|
87 name = (*iter)->iRegionString->iString; |
|
88 if (name.length() > 0) |
|
89 {// new names are not guaranteed to be in the form Region/Zone |
|
90 name += '/'; |
|
91 } |
|
92 name += (*iter)->iZoneString->iString; |
|
93 return FindZone(name); |
|
94 } |
|
95 iter++; |
|
96 } |
|
97 |
|
98 // aLinkName was not found as the old name in any of the links |
|
99 // this means that aLinkName is not a link but the name of a real zone |
|
100 return iDocument.ZonesTable()->GetZone(name); |
|
101 } |
|
102 |
|
103 //============================================================================ |
|
104 // CTzCpRuleSetsTable::CTzCpRuleSetsTable |
|
105 //============================================================================ |
|
106 CTzCpRuleSetsTable::CTzCpRuleSetsTable(CTZDocument& aDocument) |
|
107 : CPersistedEntityWrapper(aDocument) |
|
108 { |
|
109 } |
|
110 //============================================================================ |
|
111 // CTzCpRuleSetsTable::AssembleL |
|
112 //============================================================================ |
|
113 CTzCpRuleSet& CTzCpRuleSetsTable::AssembleL(CTZNode& aNode) |
|
114 { |
|
115 //Get the current Ruleset name |
|
116 string currentRuleSetName = aNode.NodeList()[ERuleFormatName]->iValue; |
|
117 return *GetRuleSet(currentRuleSetName); |
|
118 } |
|
119 //============================================================================ |
|
120 // CTzCpRuleSetsTable::ExternaliseL |
|
121 // Write the rule set table to file |
|
122 //============================================================================ |
|
123 void CTzCpRuleSetsTable::ExternaliseL(ofstream& aFilestream) |
|
124 { |
|
125 iDocument.DbHeader()->iOffsetToRuleSetsTable = aFilestream.tellp(); |
|
126 //Write the number of rulesets |
|
127 TUint16 numRuleSets = iVector.size(); |
|
128 aFilestream.write((char*)&numRuleSets,sizeof(numRuleSets)); |
|
129 |
|
130 TUint16 ruleUseOffset = 0; |
|
131 for (int x = 0; x < numRuleSets;x++) |
|
132 { |
|
133 iVector[x]->ExternaliseL(aFilestream); |
|
134 } |
|
135 } |
|
136 //============================================================================ |
|
137 // CTzCpRuleSetsTable::GetRuleSet |
|
138 // Searches for a match with aRuleSetName in the iStrings vector. If a match |
|
139 // is found the ruleset pointer from the iRuleSets vector with the matching |
|
140 // index is returned. If no match is found, a new ruleset is created and |
|
141 // added to the rulesets, the name is added to the strings and a pointer to |
|
142 // the new ruleset is returned. |
|
143 //============================================================================ |
|
144 CTzCpRuleSet* CTzCpRuleSetsTable::GetRuleSet(string aRuleSetName) |
|
145 { |
|
146 int numRuleSets = iVector.size(); |
|
147 for (int index = 0; index < numRuleSets; index++) |
|
148 { |
|
149 if (iVector[index]->Name() == aRuleSetName) |
|
150 { |
|
151 return iVector[index]; |
|
152 } |
|
153 } |
|
154 //New RuleSet required |
|
155 CTzCpRuleSet* newRuleSet = new CTzCpRuleSet(iDocument,aRuleSetName); |
|
156 iVector.push_back(newRuleSet); |
|
157 return newRuleSet; |
|
158 } |
|
159 //============================================================================ |
|
160 // CTzCpRuleSetsTable::GetRuleSetIndex |
|
161 // Gets the index of the ruleset from the ruleset name |
|
162 //============================================================================ |
|
163 int CTzCpRuleSetsTable::GetRuleSetIndex(std::string aRuleSetName) |
|
164 { |
|
165 int size = iVector.size(); |
|
166 for (int index = 0; index < size; index++) |
|
167 { |
|
168 if (iVector[index]->Name() == aRuleSetName) |
|
169 { |
|
170 return index; |
|
171 } |
|
172 } |
|
173 GetRuleSet(aRuleSetName); |
|
174 return GetRuleSetIndex(aRuleSetName); |
|
175 } |
|
176 |
|
177 //============================================================================ |
|
178 // CTzCpRuleSetsTable::RemoveUnreferencedEntities |
|
179 // Iterate through the vector of entities, removing all entities with a reference count of 0 |
|
180 //============================================================================ |
|
181 void CTzCpRuleSetsTable::RemoveUnreferencedEntities() |
|
182 { |
|
183 iVector.erase(std::remove_if(iVector.begin(),iVector.end(),SEntityCheck()),iVector.end()); |
|
184 } |
|
185 |
|
186 //============================================================================ |
|
187 // CTzCpRuleDefinitionsTable::CTzCpRuleDefinitionsTable |
|
188 //============================================================================ |
|
189 CTzCpRuleDefinitionsTable::CTzCpRuleDefinitionsTable(CTZDocument& aDocument) |
|
190 : CPersistedEntityWrapper(aDocument) |
|
191 { |
|
192 } |
|
193 //============================================================================ |
|
194 // CTzCpRuleDefinitionsTable::AddRuleDefinition |
|
195 // Adds a CTzCpRuleDefinition to the collection of rule definitions |
|
196 // iRuleDefinitions takes ownership of aRuleDefinition. Checks that the |
|
197 // Rule definition does not already exist before adding it. If it does exist, |
|
198 // a reference to the duplicate is returned. If it does not exist then it is |
|
199 // added and the new reference is returned. |
|
200 //============================================================================ |
|
201 CTzCpRuleDefinition& CTzCpRuleDefinitionsTable::AddRuleDefinition(CTzCpRuleDefinition* aRuleDefinition) |
|
202 { |
|
203 //Checks for a match - quick and dirty - consider revising |
|
204 int size = iVector.size(); |
|
205 for (int x = 0; x < size; x++) |
|
206 { |
|
207 TTzRuleDefinition tmpRuleDef = iVector[x]->iPersistedEntity; |
|
208 if ((tmpRuleDef.iStdTimeOffset == aRuleDefinition->iPersistedEntity.iStdTimeOffset) && |
|
209 (tmpRuleDef.iMonth == aRuleDefinition->iPersistedEntity.iMonth) && |
|
210 (tmpRuleDef.iDayRule == aRuleDefinition->iPersistedEntity.iDayRule) && |
|
211 (tmpRuleDef.iDayOfMonth == aRuleDefinition->iPersistedEntity.iDayOfMonth) && |
|
212 (tmpRuleDef.iDayOfWeek == aRuleDefinition->iPersistedEntity.iStdTimeOffset) && |
|
213 (tmpRuleDef.iTimeReference == aRuleDefinition->iPersistedEntity.iTimeReference) && |
|
214 (tmpRuleDef.iTimeOfChange == aRuleDefinition->iPersistedEntity.iTimeOfChange)) |
|
215 { |
|
216 |
|
217 //If we don't add the ruledefinition to the vector we |
|
218 //are responsible for deleting it, as clients will |
|
219 //assume they have passed ownership to the table. |
|
220 delete aRuleDefinition; |
|
221 return *iVector[x]; |
|
222 } |
|
223 } |
|
224 iVector.push_back(aRuleDefinition); |
|
225 return *iVector[iVector.size() -1]; |
|
226 } |
|
227 //============================================================================ |
|
228 // CTzCpRuleDefinitionsTable::AssembleL |
|
229 //============================================================================ |
|
230 CTzCpRuleDefinition& CTzCpRuleDefinitionsTable::AssembleL(CTZNode& aNode) |
|
231 { |
|
232 CTzCpRuleDefinition* aRuleDefinition = new CTzCpRuleDefinition(iDocument); |
|
233 aRuleDefinition->AssembleL(aNode); |
|
234 return AddRuleDefinition(aRuleDefinition); |
|
235 } |
|
236 //============================================================================ |
|
237 // CTzCpRuleDefinitionsTable::ExternaliseL |
|
238 // Write the rule definition table to file |
|
239 //============================================================================ |
|
240 void CTzCpRuleDefinitionsTable::ExternaliseL(ofstream& aFilestream) |
|
241 { |
|
242 iDocument.DbHeader()->iOffsetToRuleDefinitionsTable = aFilestream.tellp(); |
|
243 //Write number of rule definitions |
|
244 TUint16 numRuleDefs = iVector.size(); |
|
245 aFilestream.write((char*)&numRuleDefs,sizeof(numRuleDefs)); |
|
246 |
|
247 for (int x = 0; x < numRuleDefs;x++) |
|
248 { |
|
249 iVector[x]->ExternaliseL(aFilestream); |
|
250 } |
|
251 } |
|
252 |
|
253 //============================================================================ |
|
254 // CTzCpRuleDefinitionsTable::RemoveUnreferencedEntities |
|
255 // Iterate through the vector of entities, removing all entities with a reference count of 0 |
|
256 //============================================================================ |
|
257 void CTzCpRuleDefinitionsTable::RemoveUnreferencedEntities() |
|
258 { |
|
259 iVector.erase(std::remove_if(iVector.begin(),iVector.end(),SEntityCheck()),iVector.end()); |
|
260 } |
|
261 |
|
262 //============================================================================ |
|
263 // CTzCpStringTable::CTzCpStringTable |
|
264 //============================================================================ |
|
265 CTzCpStringTable::CTzCpStringTable(CTZDocument& aDocument) |
|
266 : CPersistedEntityWrapper(aDocument) |
|
267 { |
|
268 } |
|
269 |
|
270 //============================================================================ |
|
271 // CTzCpStringTable::ExternaliseL |
|
272 // Write the string table to file |
|
273 //============================================================================ |
|
274 void CTzCpStringTable::ExternaliseL(ofstream& aFilestream) |
|
275 { |
|
276 iDocument.DbHeader()->iOffsetToStringTable = aFilestream.tellp(); |
|
277 //Write number of strings |
|
278 TUint16 numStrings = iVector.size(); |
|
279 aFilestream.write((char*)&numStrings,sizeof(numStrings)); |
|
280 |
|
281 for (int x = 0; x < numStrings;x++) |
|
282 { |
|
283 iVector[x]->ExternaliseL(aFilestream); |
|
284 } |
|
285 } |
|
286 //============================================================================ |
|
287 // CTzCpStringTable::AddString |
|
288 // Returns a reference to the added string, or if the string already exists |
|
289 // a reference to the existing string |
|
290 //============================================================================ |
|
291 CTzCpString& CTzCpStringTable::AddString(std::string aString) |
|
292 { |
|
293 int size = iVector.size(); |
|
294 for (int i = 0; i < size; i++) |
|
295 { |
|
296 if (aString == iVector[i]->iString) |
|
297 { |
|
298 return *iVector[i]; |
|
299 } |
|
300 } |
|
301 CTzCpString* aNewString = new CTzCpString(iDocument); |
|
302 aNewString->iString = aString; |
|
303 iVector.push_back(aNewString); |
|
304 return *iVector[iVector.size() -1]; |
|
305 } |
|
306 |
|
307 //============================================================================ |
|
308 // CTzCpStringsTable::RemoveUnreferencedEntities |
|
309 // Iterate through the vector of entities, removing all entities with a reference count of 0 |
|
310 //============================================================================ |
|
311 void CTzCpStringTable::RemoveUnreferencedEntities() |
|
312 { |
|
313 iVector.erase(std::remove_if(iVector.begin(),iVector.end(),SEntityCheck()),iVector.end()); |
|
314 } |
|
315 //============================================================================ |
|
316 // CTzCpRegionsTable::CTzCpRegionsTable |
|
317 //============================================================================ |
|
318 CTzCpRegionsTable::CTzCpRegionsTable(CTZDocument& aDocument) |
|
319 : CPersistedEntityWrapper(aDocument) |
|
320 { |
|
321 } |
|
322 |
|
323 //============================================================================ |
|
324 // CTzCpRegionsTable::ExternaliseL |
|
325 //============================================================================ |
|
326 void CTzCpRegionsTable::ExternaliseL(ofstream& aFilestream) |
|
327 { |
|
328 iDocument.DbHeader()->iOffsetToRegionalZonesTable = aFilestream.tellp(); |
|
329 //Loop through all the regions, externalising the regional zone index |
|
330 TUint16 numRegions = iVector.size(); |
|
331 aFilestream.write((char*)&numRegions,sizeof(numRegions)); |
|
332 |
|
333 TUint16 numberOfZones = 0; |
|
334 TUint16 zoneOffset = 0; |
|
335 |
|
336 for (int x = 0; x < numRegions;x++) |
|
337 { |
|
338 iVector[x]->iRegionalZonesIndex->ExternaliseL(aFilestream); |
|
339 } |
|
340 |
|
341 //Externalise the regions |
|
342 iDocument.DbHeader()->iOffsetToRegionsTable = aFilestream.tellp(); |
|
343 aFilestream.write((char*)&numRegions,sizeof(numRegions)); |
|
344 for (x = 0; x < numRegions;x++) |
|
345 { |
|
346 iVector[x]->ExternaliseL(aFilestream); |
|
347 } |
|
348 } |
|
349 //============================================================================ |
|
350 // CTzCpRegionsTable::GetRegion |
|
351 // Uses the region name index (from the strings table) to determine if we |
|
352 // already have an existing CTzCpRegion for this region. If we do, we return |
|
353 // this. If we don't, we create a new pointer, add to iRegions and return |
|
354 //============================================================================ |
|
355 CTzCpRegion& CTzCpRegionsTable::GetRegion(CTzCpString& aRegionNameRef) |
|
356 { |
|
357 int size = iVector.size(); |
|
358 for (int x = 0; x < size; x++) |
|
359 { |
|
360 if (iVector[x]->iRegionNameRef->iString == aRegionNameRef.iString) |
|
361 { |
|
362 return *iVector[x]; |
|
363 } |
|
364 } |
|
365 CTzCpRegion* aNewRegion = new CTzCpRegion(iDocument); |
|
366 aNewRegion->iRegionNameRef = &aRegionNameRef; |
|
367 iVector.push_back(aNewRegion); |
|
368 return *aNewRegion; |
|
369 } |
|
370 |
|
371 //============================================================================ |
|
372 // CTzCpRegionsTable::RemoveUnreferencedEntities |
|
373 // Iterate through the vector of entities, removing all entities with a reference count of 0 |
|
374 //============================================================================ |
|
375 void CTzCpRegionsTable::RemoveUnreferencedEntities() |
|
376 { |
|
377 iVector.erase(std::remove_if(iVector.begin(),iVector.end(),SEntityCheck()),iVector.end()); |
|
378 } |
|
379 |
|
380 //============================================================================ |
|
381 // CTzCpRuleUsesTable::CTzCpRuleUsesTable |
|
382 //============================================================================ |
|
383 CTzCpRuleUsesTable::CTzCpRuleUsesTable(CTZDocument& aDocument) |
|
384 : CPersistedEntityWrapper(aDocument) |
|
385 { |
|
386 } |
|
387 //============================================================================ |
|
388 // CTzCpRuleUsesTable::AssembleL |
|
389 //============================================================================ |
|
390 CTzCpRuleUse& CTzCpRuleUsesTable::AssembleL(CTZNode& aNode) |
|
391 { |
|
392 //Create the RuleUse |
|
393 CTzCpRuleUse* aRuleUse = new CTzCpRuleUse(iDocument); |
|
394 aRuleUse->AssembleL(aNode); |
|
395 //Add the Rule Use to the ruleuse collection |
|
396 return AddRuleUse(aRuleUse); |
|
397 } |
|
398 //============================================================================ |
|
399 // CTzCpRuleUsesTable::AddRuleUse |
|
400 // Adds a rule use to the rule use table and returns a reference to it |
|
401 //============================================================================ |
|
402 CTzCpRuleUse& CTzCpRuleUsesTable::AddRuleUse(CTzCpRuleUse* aRuleUse) |
|
403 { |
|
404 iVector.push_back(aRuleUse); |
|
405 return *iVector[iVector.size() - 1]; |
|
406 } |
|
407 //============================================================================ |
|
408 // CTzCpRuleUsesTable::ExternaliseL |
|
409 // Write the rule use table to a file |
|
410 //============================================================================ |
|
411 void CTzCpRuleUsesTable::ExternaliseL(ofstream& aFilestream) |
|
412 { |
|
413 iDocument.DbHeader()->iOffsetToRuleUsesTable = aFilestream.tellp(); |
|
414 //Write number of rule uses |
|
415 TUint16 numRuleUses = iVector.size(); |
|
416 aFilestream.write((char*)&numRuleUses,sizeof(numRuleUses)); |
|
417 |
|
418 for (int x = 0; x < numRuleUses; x++) |
|
419 { |
|
420 iVector[x]->ExternaliseL(aFilestream); |
|
421 } |
|
422 } |
|
423 |
|
424 //============================================================================ |
|
425 // CTzCpRuleUsesTable::RemoveUnreferencedEntities |
|
426 // Iterate through the vector of entities, removing all entities with a reference count of 0 |
|
427 //============================================================================ |
|
428 void CTzCpRuleUsesTable::RemoveUnreferencedEntities() |
|
429 { |
|
430 iVector.erase(std::remove_if(iVector.begin(),iVector.end(),SEntityCheck()),iVector.end()); |
|
431 } |
|
432 |
|
433 //============================================================================ |
|
434 // CTzCpZonesTable::CTzCpZonesTable |
|
435 //============================================================================ |
|
436 CTzCpZonesTable::CTzCpZonesTable(CTZDocument& aDocument) |
|
437 : CPersistedEntityWrapper(aDocument) |
|
438 { |
|
439 } |
|
440 |
|
441 //============================================================================ |
|
442 // CTzCpZonesTable::ExternaliseL |
|
443 //============================================================================ |
|
444 void CTzCpZonesTable::ExternaliseL(ofstream& aFilestream) |
|
445 { |
|
446 // sort zones by location ID |
|
447 sort(iVector.begin(), iVector.end(), CTzCpZone::SLocationIdSort()); |
|
448 |
|
449 TUint16 numZones = iVector.size(); |
|
450 // write out zones data to database |
|
451 iDocument.DbHeader()->iOffsetToZones = aFilestream.tellp(); |
|
452 for (int x = 0; x < numZones; x++) |
|
453 { |
|
454 iVector[x]->ExternaliseL(aFilestream); |
|
455 } |
|
456 |
|
457 // write out the zone table to database |
|
458 iDocument.DbHeader()->iOffsetToZonesTable = aFilestream.tellp(); |
|
459 aFilestream.write((char*)&numZones,sizeof(numZones)); |
|
460 TUint16 zoneOffset; |
|
461 for (x = 0; x < numZones; x++) |
|
462 { |
|
463 zoneOffset = iVector[x]->iOffset; |
|
464 aFilestream.write((char*)&zoneOffset,sizeof(zoneOffset)); |
|
465 } |
|
466 } |
|
467 //============================================================================ |
|
468 // CTzCpZonesTable::GetZone |
|
469 // Uses the id of the zone name in the string table to determine if we already |
|
470 // have created a CTzCpZone object for this zone. If it exists we return this |
|
471 // otherwise we create a new zone, add it to iZones and return |
|
472 // aIndex contains the index of the zone to use in the vector |
|
473 // If addZone is false we do not add a new zone, just set aIndex -1 |
|
474 //============================================================================ |
|
475 CTzCpZone* CTzCpZonesTable::GetZone(CTzCpString& aZoneRef, CTzCpString& aRegionRef,bool addZone) |
|
476 { |
|
477 int size = iVector.size(); |
|
478 for (int x = 0; x < size; x++) |
|
479 { |
|
480 string zoneTestString = iVector[x]->iZoneNameRef->iString; |
|
481 string regionTestString = iVector[x]->iRegionNameRef->iString; |
|
482 if ((iVector[x]->iZoneNameRef->iString == aZoneRef.iString) && (iVector[x]->iRegionNameRef->iString == aRegionRef.iString)) |
|
483 { |
|
484 CTzCpZone* zone = iVector[x]; |
|
485 return zone; |
|
486 } |
|
487 } |
|
488 if (addZone) |
|
489 { |
|
490 CTzCpZone* aNewZone = new CTzCpZone(iDocument); |
|
491 aNewZone->iZoneNameRef = &aZoneRef; |
|
492 aNewZone->iRegionNameRef = &aRegionRef; |
|
493 iVector.push_back(aNewZone); |
|
494 return aNewZone; |
|
495 } |
|
496 return NULL; |
|
497 |
|
498 } |
|
499 |
|
500 CTzCpZone* CTzCpZonesTable::GetZone(std::string& aZoneName) |
|
501 { |
|
502 int slashPos = aZoneName.find('/'); |
|
503 int length = aZoneName.length(); |
|
504 CTzCpString* regString = new CTzCpString(iDocument); |
|
505 CTzCpString* zoneString = new CTzCpString(iDocument); |
|
506 if (slashPos > 0) |
|
507 { |
|
508 regString->iString = aZoneName.substr(0,slashPos); |
|
509 zoneString->iString = aZoneName.substr(slashPos+1,length-1); |
|
510 } |
|
511 else |
|
512 { |
|
513 regString->iString = ""; |
|
514 zoneString->iString = aZoneName; |
|
515 } |
|
516 |
|
517 CTzCpZone* zone = GetZone(*zoneString,*regString,false); |
|
518 |
|
519 return zone; |
|
520 } |
|
521 |
|
522 //============================================================================ |
|
523 // CTzCpZonesTable::RemoveUnreferencedEntities |
|
524 // Iterate through the vector of entities, removing all entities with a reference count of 0 |
|
525 //============================================================================ |
|
526 void CTzCpZonesTable::RemoveUnreferencedEntities() |
|
527 { |
|
528 iVector.erase(std::remove_if(iVector.begin(),iVector.end(),SEntityCheck()),iVector.end()); |
|
529 } |
|
530 |
|
531 //============================================================================ |
|
532 // CTzCpStdTimeAlignmentsTable::CTzCpStdTimeAlignmentsTable |
|
533 //============================================================================ |
|
534 CTzCpStdTimeAlignmentsTable::CTzCpStdTimeAlignmentsTable(CTZDocument& aDocument) |
|
535 : CPersistedEntityWrapper(aDocument) |
|
536 { |
|
537 } |
|
538 //============================================================================ |
|
539 // CTzCpStdTimeAlignmentsTable::AddTimeAlignment |
|
540 //============================================================================ |
|
541 CTzCpStdTimeAlignment& CTzCpStdTimeAlignmentsTable::AddTimeAlignment(CTzCpString& aTimeZoneFormatName) |
|
542 { |
|
543 CTzCpStdTimeAlignment* aNewTimeAlignment = new CTzCpStdTimeAlignment(iDocument); |
|
544 iVector.push_back(aNewTimeAlignment); |
|
545 return *aNewTimeAlignment; |
|
546 } |
|
547 |
|
548 //============================================================================ |
|
549 // CTzCpStdTimeAlignmentsTable::ExternaliseL |
|
550 // Write the time alignments to file |
|
551 //============================================================================ |
|
552 void CTzCpStdTimeAlignmentsTable::ExternaliseL(ofstream& aFilestream) |
|
553 { |
|
554 iDocument.DbHeader()->iOffsetToStdTimeAlignmentsTable = aFilestream.tellp(); |
|
555 //Write number of time alignments |
|
556 TUint16 numTimeAlignments = iVector.size(); |
|
557 aFilestream.write((char*)&numTimeAlignments,sizeof(numTimeAlignments)); |
|
558 |
|
559 for (int x = 0; x < numTimeAlignments;x++) |
|
560 { |
|
561 iVector[x]->ExternaliseL(aFilestream); |
|
562 } |
|
563 } |
|
564 |
|
565 //============================================================================ |
|
566 // CTzCpStdTimeAlignmentsTable::RemoveUnreferencedEntities |
|
567 // Iterate through the vector of entities, removing all entities with a reference count of 0 |
|
568 //============================================================================ |
|
569 void CTzCpStdTimeAlignmentsTable::RemoveUnreferencedEntities() |
|
570 { |
|
571 iVector.erase(std::remove_if(iVector.begin(),iVector.end(),SEntityCheck()),iVector.end()); |
|
572 } |
|
573 //============================================================================ |
|
574 // End of file |
|
575 //============================================================================ |