00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "fltInfo.h"
00016
00017 #include "fltHeader.h"
00018 #include "indent.h"
00019 #include "pystub.h"
00020
00021
00022
00023
00024
00025
00026 FltInfo::
00027 FltInfo() {
00028 set_program_description
00029 ("This program reads a MultiGen OpenFlight (.flt) file and reports "
00030 "some interesting things about its contents.");
00031
00032 clear_runlines();
00033 add_runline("[opts] input.flt");
00034
00035 add_option
00036 ("ls", "", 0,
00037 "List the hierarchy in the flt file.",
00038 &FltInfo::dispatch_none, &_list_hierarchy);
00039 }
00040
00041
00042
00043
00044
00045
00046
00047 void FltInfo::
00048 run() {
00049 PT(FltHeader) header = new FltHeader(_path_replace);
00050
00051 nout << "Reading " << _input_filename << "\n";
00052 FltError result = header->read_flt(_input_filename);
00053 if (result != FE_ok) {
00054 nout << "Unable to read: " << result << "\n";
00055 exit(1);
00056 }
00057
00058 if (header->check_version()) {
00059 nout << "Version is " << header->get_flt_version() / 100.0 << "\n";
00060 }
00061
00062 if (_list_hierarchy) {
00063 list_hierarchy(header, 0);
00064 }
00065 }
00066
00067
00068
00069
00070
00071
00072
00073 void FltInfo::
00074 list_hierarchy(FltRecord *record, int indent_level) {
00075
00076 record->write(cout, indent_level);
00077 }
00078
00079
00080
00081
00082
00083
00084
00085 bool FltInfo::
00086 handle_args(ProgramBase::Args &args) {
00087 if (args.empty()) {
00088 nout << "You must specify the .flt file to read on the command line.\n";
00089 return false;
00090
00091 } else if (args.size() != 1) {
00092 nout << "You must specify only one .flt file to read on the command line.\n";
00093 return false;
00094 }
00095
00096 _input_filename = args[0];
00097
00098 return true;
00099 }
00100
00101
00102 int main(int argc, char *argv[]) {
00103
00104 pystub();
00105
00106 FltInfo prog;
00107 prog.parse_command_line(argc, argv);
00108 prog.run();
00109 return 0;
00110 }