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