32 {
34
35 if ( argc != 3 )
36 {
37 std::cerr << "usage: " << argv[0] << " <v2.4 file> <v3.0 file>" << std::endl;
38 std::exit( 1 );
39 }
40
41
42 std::fstream in( argv[1], std::ios::in | std::ios::binary );
43 if ( !in )
44 {
45 std::cerr << "File `" << argv[1] << "' does not exist?!" << std::endl;
46 std::exit( 1 );
47 }
48
49 std::fstream out( argv[2], std::ios::out | std::ios::binary );
50 if ( !out )
51 {
52 std::cerr << "Cannot write to `" << argv[1] << "?!" << std::endl;
53 std::exit( 1 );
54 }
55
58
59 while ( true )
60 {
61
63 uint32_t l1id = 0;
64
66
67 try
69 {
70 std::cerr << " !! WARNING: found ROS fragment with format version = "
73 {
74 std::cerr << " -> I cannot cope with this format. Skipping..." << std::endl;
75 continue;
76 }
77 else { std::cout << " -> ROS fragment will be simply copied..." << std::endl; }
79 {
80 std::cerr <<
"Uncaught eformat issue: " << ex.
what() << std::endl;
81 std::cerr << " -> Trying to continue..." << std::endl;
82 continue;
83 } catch ( ... )
84 {
85 std::cerr << std::endl << "Uncaught unknown exception" << std::endl;
86 delete[] fragment;
87 delete[] nfragment;
88 std::exit( 1 );
89 }
90
91 try
92 {
93
94 std::cout <<
"ROS #" << ros.lvl1_id() <<
" [" <<
HEX( ros.version() ) <<
"] -> ["
95 <<
HEX( 0x03000000 ) <<
"]" << std::endl;
98 nros.check_tree();
99 l1id = nros.lvl1_id();
101 {
102 std::cerr <<
"Uncaught eformat issue: " << ex.
what() << std::endl;
103 std::cerr << " -> Trying to continue..." << std::endl;
104 continue;
105 std::exit( 1 );
107 {
108 std::cerr <<
"Uncaught ERS issue: " << ex.
what() << std::endl;
109 delete[] fragment;
110 delete[] nfragment;
111 std::exit( 1 );
112 } catch ( std::exception& ex )
113 {
114 std::cerr << "Uncaught std exception: " << ex.what() << std::endl;
115 delete[] fragment;
116 delete[] nfragment;
117 std::exit( 1 );
118 } catch ( ... )
119 {
120 std::cerr << std::endl << "Uncaught unknown exception" << std::endl;
121 delete[] fragment;
122 delete[] nfragment;
123 std::exit( 1 );
124 }
125 out.write( reinterpret_cast<char*>( nfragment ), sizeof( uint32_t ) * nfragment[1] );
126
127 std::cout << " -> (new) ROS fragment #" << l1id << " converted, checked and saved."
128 << std::endl;
129 }
130
131 delete[] fragment;
132 delete[] nfragment;
133 return 0;
134}
const char * what() const
Human description message.
const size_t MAX_ROS_SIZE