Bitstream Interpretation Library (BIL)  0.1
v5cfgmap_gen.cpp
Go to the documentation of this file.
1 
9 #include <cstdlib>
10 #include <cstring>
11 #include <fstream>
12 #include <iostream>
18 
19 
20 int main(int argc, char** argv)
21 {
22  using namespace bil;
23 
24  try
25  {
26  // process given command line
27  std::cout << SPLASH_MSG;
28  parseCommandLine(argc, argv);
29 
30  // load device file
31  std::cout << LOADING_DEVICE_FILE_MSG;
32  Device device;
33  std::ifstream deviceFileStream(deviceFileName.c_str(), std::ios::binary);
34  readBinary(device, deviceFileStream);
35 
36  // load address layout
37  std::string deviceName = removePackageAndSpeed((device.name()).c_str());
38  std::cout << LOADING_ADDRESS_LAYOUT1_MSG << deviceName << LOADING_ADDRESS_LAYOUT2_MSG;
39  V5AddressLayout addressLayout;
40  std::string calFileName = dataPathName + deviceName + CAL_FILE_EXT;
41  std::ifstream calInputStream(calFileName.c_str(), std::ios::binary);
42  readBinary(addressLayout, calInputStream);
43 
44  // create mapping
45  std::cout << CREATING_TILEMAP_MSG;
46  V5CfgTileMap map;
47  generateCfgTileMap(map, device, addressLayout);
48 
49  // write mapping
50  std::cout << WRITING_TILEMAP_FILE_MSG;
51  std::ofstream mapFileStream(mapFileName.c_str(), std::ios::binary);
52  writeBinary(map, mapFileStream);
53 
54  // finished
55  std::cout << FINISHED_MSG;
56  }
57  catch (const CommandLineException& e)
58  {
59  std::cout << ERROR_MSG << e.what() << INFO_MSG;
60  return EXIT_FAILURE;
61  }
62  catch (...)
63  {
64  std::cout << ERROR_UNKNOWN_MSG;
65  return EXIT_FAILURE;
66  }
67  return EXIT_SUCCESS;
68 }