MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / main

Function main

tools/code_generators/gamestate_serialize_gen/main.cpp:202–281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

200}
201
202int main(int argc, char **argv)
203{
204
205 po::options_description desc("Allowed options");
206 // These operator() really screw up clang-format
207 // clang-format off
208 desc.add_options()
209 ("help", "Show help message")
210 ("xml,x", po::value<std::string>(),"Input XML file")
211 ("output-header,h", po::value<std::string>(), "Path to output generated header file")
212 ("output-source,o", po::value<std::string>(), "Path to output generated source file")
213 ;
214 // clang-format on
215
216 po::variables_map vm;
217 po::store(po::parse_command_line(argc, argv, desc), vm);
218 po::notify(vm);
219
220 std::string inputXmlPath;
221 std::string outputHeaderPath;
222 std::string outputSourcePath;
223
224 if (vm.count("help"))
225 {
226 std::cout << desc << "\n";
227 return 1;
228 }
229 if (!vm.count("xml"))
230 {
231 std::cerr << "Must specify input XML file\n" << desc << "\n";
232 return 1;
233 }
234 if (!vm.count("output-header"))
235 {
236 std::cerr << "Must specify output header file\n" << desc << "\n";
237 return 1;
238 }
239 if (!vm.count("output-source"))
240 {
241 std::cerr << "Must specify output source file\n" << desc << "\n";
242 return 1;
243 }
244
245 inputXmlPath = vm["xml"].as<std::string>();
246 outputHeaderPath = vm["output-header"].as<std::string>();
247 outputSourcePath = vm["output-source"].as<std::string>();
248
249 std::ifstream inputXmlFile(inputXmlPath);
250 if (!inputXmlFile)
251 {
252 std::cerr << "Failed to open input XML file \"" << inputXmlPath << "\"\n";
253 return 1;
254 }
255
256 std::ofstream outputSourceFile(outputSourcePath);
257 if (!outputSourceFile)
258 {
259 std::cerr << "Failed to open output source file at \"" << outputSourcePath << "\"\n";

Callers

nothing calls this directly

Calls 4

readXmlFunction · 0.85
writeHeaderFunction · 0.70
writeSourceFunction · 0.70
countMethod · 0.45

Tested by

no test coverage detected