// file: $(NEDC_NFC)/class/cpp/Cmdl/cmdl_02.cc // // This file contains methods that support parsing and which interact // with the Boost software. // // local include files // #include "Cmdl.h" // method: parse_args // // arguments: // int argc: number of arguments (input) // char** argv: arguments (input) // // return: a boolean value indicating status // // This method invokes boost's parse function and does a little housekeeping. // bool Cmdl::parse_args(int argc, const char** argv) { // display debugging information // if (dbgl_d == Dbgl::FULL) { fprintf(stdout, "%s (line: %d) %s: parsing the command line...\n", __FILE__, __LINE__, __PRETTY_FUNCTION__); } // parse the arguments: // note that we trap for errors try { bpo::store(bpo::command_line_parser(argc, argv).options(*bst_desc_d). positional(*bst_pos_d).run(), bst_vm_d); } catch(...) { fprintf(stdout, "Error: %s (line: %d) %s: unknown argument name or value\n", __FILE__, __LINE__, __PRETTY_FUNCTION__); return display_usage(stdout); } // run notify: // what this does is unclear to me, but we have been told to call it // after we parse the arguments. it doesn't seem to do anything useful. // bpo::notify(bst_vm_d); // check for help or usage arguments // if (bst_vm_d.count(ARG_HELP_NAME)) { return display_help(stdout); } else if (bst_vm_d.count(ARG_USAGE)) { return display_usage(stdout); } // set debug and verbosity levels // if (bst_vm_d.count("debug_level")) { std::string val; get_value(val, ARG_DBGL); dbgl_d.set(val.c_str()); } if (bst_vm_d.count("verbosity_level")) { std::string val; get_value(val, ARG_VRBL); vrbl_d.set(val.c_str()); } // display debugging information // if (dbgl_d == Dbgl::FULL) { fprintf(stdout, "%s (line: %d) %s: finished parsing\n", __FILE__, __LINE__, __PRETTY_FUNCTION__); } // exit gracefully // return true; } // // end of file