| 242 | } |
| 243 | |
| 244 | void Finalise(const StringData &data) override |
| 245 | { |
| 246 | /* Find the plural form with the most amount of cases. */ |
| 247 | size_t max_plural_forms = 0; |
| 248 | for (const auto &pf : _plural_forms) { |
| 249 | max_plural_forms = std::max(max_plural_forms, pf.plural_count); |
| 250 | } |
| 251 | |
| 252 | fmt::print(this->output_stream, |
| 253 | "\n" |
| 254 | "static const uint LANGUAGE_PACK_VERSION = 0x{:X};\n" |
| 255 | "static const uint LANGUAGE_MAX_PLURAL = {};\n" |
| 256 | "static const uint LANGUAGE_MAX_PLURAL_FORMS = {};\n" |
| 257 | "static const uint LANGUAGE_TOTAL_STRINGS = {};\n" |
| 258 | "\n", |
| 259 | data.Version(), std::size(_plural_forms), max_plural_forms, total_strings |
| 260 | ); |
| 261 | |
| 262 | this->output_stream << "#endif /* TABLE_STRINGS_H */\n"; |
| 263 | |
| 264 | this->FileWriter::Finalise(); |
| 265 | |
| 266 | std::error_code error_code; |
| 267 | if (CompareFiles(this->path, this->real_path)) { |
| 268 | /* files are equal. tmp.xxx is not needed */ |
| 269 | std::filesystem::remove(this->path, error_code); // Just ignore the error |
| 270 | } else { |
| 271 | /* else rename tmp.xxx into filename */ |
| 272 | std::filesystem::rename(this->path, this->real_path, error_code); |
| 273 | if (error_code) FatalError("rename({}, {}) failed: {}", this->path, this->real_path, error_code.message()); |
| 274 | } |
| 275 | } |
| 276 | }; |
| 277 | |
| 278 | /** Class for writing a language to disk. */ |
nothing calls this directly
no test coverage detected