Bitstream Interpretation Library (BIL)  0.1
v5data_gen.cpp
Go to the documentation of this file.
1 
9 #include <cstdlib>
10 #include <fstream>
11 #include <iostream>
17 
18 
19 int main(int argc, char** argv)
20 {
21  using namespace bil;
22 
23  try
24  {
25  // process given command line
26  std::cout << SPLASH_MSG;
27  parseCommandLine(argc, argv);
28 
29  // generate device registry
30  DeviceRegistry devices;
31  for (size_t i = 0; i < V5_DEVICE_COUNT; ++i)
32  devices.insert(V5_DEVICE_IDS[i], V5_DEVICE_NAMES[i]);
33  // write it to file
34  std::cout << WRITING_DEVICE_LIST_MSG;
35  std::string fileName = outputPath + DEVICE_REG_FILENAME;
36  std::ofstream outputFile(fileName.c_str(), std::ios::binary);
37  writeBinary(devices, outputFile);
38  outputFile.close();
39 
40  // write address layouts
41  std::cout << WRITING_CFG_LAYOUTS_MSG;
42  for (size_t i = 0; i < V5_DEVICE_COUNT; ++i)
43  {
44  fileName = outputPath + V5_DEVICE_NAMES[i] + CFG_LAYOUT_EXT;
45  outputFile.open(fileName.c_str(), std::ios::binary);
46  writeBinary(V5_ADDRESS_LAYOUTS[i], outputFile);
47  outputFile.close();
48  }
49 
50  // finished
51  std::cout << FINISHED_MSG;
52  }
53  catch (const CommandLineException& e)
54  {
55  std::cout << ERROR_MSG << e.what() << INFO_MSG;
56  return EXIT_FAILURE;
57  }
58  catch (...)
59  {
60  std::cout << ERROR_UNKNOWN_MSG;
61  return EXIT_FAILURE;
62  }
63  return EXIT_SUCCESS;
64 }