MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / run

Function run

extern/icu/tzdata/update-ids.cpp:56–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54
55
56int run(int argc, const char* argv[])
57{
58 if (argc != 4)
59 {
60 cerr << "Syntax: " << argv[0] << " <ids.dat file> <TimeZones.h file> <TimeZoneIds.h file>" << endl;
61 return 1;
62 }
63
64 const unsigned MAX_ID = 65535;
65 unordered_set<string> zonesSet;
66 vector<string> zonesVector;
67
68 for (unsigned i = 0; i < sizeof(BUILTIN_TIME_ZONE_LIST) / sizeof(BUILTIN_TIME_ZONE_LIST[0]); ++i)
69 {
70 zonesSet.insert(BUILTIN_TIME_ZONE_LIST[i]);
71 zonesVector.push_back(BUILTIN_TIME_ZONE_LIST[i]);
72 }
73
74 UErrorCode icuErrorCode = U_ZERO_ERROR;
75
76 const char* databaseVersion = ucal_getTZDataVersion(&icuErrorCode);
77 cout << "Database version: " << databaseVersion << endl;
78
79 UEnumeration* uenum = ucal_openTimeZones(&icuErrorCode);
80 assert(uenum);
81
82 int32_t length;
83 char buffer[512];
84
85 while (const UChar* str = uenum_unext(uenum, &length, &icuErrorCode))
86 {
87 for (unsigned i = 0; i <= length; ++i)
88 buffer[i] = (char) str[i];
89
90 if (zonesSet.find(buffer) == zonesSet.end())
91 {
92 cout << "New time zone included: " << buffer << "(" << (MAX_ID - zonesVector.size()) << ")." << endl;
93 zonesVector.push_back(buffer);
94 }
95 }
96
97 uenum_close(uenum);
98
99 ofstream datStream, headerStream, idsHeaderStream;
100
101 datStream.open(argv[1], std::fstream::out | std::fstream::trunc | std::fstream::binary);
102 headerStream.open(argv[2], std::fstream::out | std::fstream::trunc);
103 idsHeaderStream.open(argv[3], std::fstream::out | std::fstream::trunc);
104
105 uint8_t byte;
106
107 // file signature
108 writeString(datStream, "FBTZ", true);
109
110 // file format version
111 const unsigned fileVersion = 1;
112 byte = fileVersion & 0xFF;
113 datStream.write((char*) &byte, 1);

Callers 1

mainFunction · 0.70

Calls 14

assertClass · 0.85
writeStringFunction · 0.85
insertMethod · 0.45
push_backMethod · 0.45
findMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
openMethod · 0.45
writeMethod · 0.45
c_strMethod · 0.45
lengthMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected