18 #include "pandatoolbase.h" 20 #include "distanceUnit.h" 21 #include "pathReplace.h" 22 #include "pathStore.h" 24 #include "pointerTo.h" 25 #include "vector_string.h" 46 INLINE
void show_text(
const string &text);
47 void show_text(
const string &prefix,
int indent_width,
string text);
60 typedef bool (*OptionDispatchFunction)(
const string &opt,
const string &parm,
void *data);
61 typedef bool (*OptionDispatchMethod)(
ProgramBase *
self,
const string &opt,
const string &parm,
void *data);
63 virtual bool handle_args(Args &args);
64 virtual bool post_command_line();
66 void set_program_brief(
const string &brief);
67 void set_program_description(
const string &description);
68 void clear_runlines();
69 void add_runline(
const string &runline);
71 void add_option(
const string &
option,
const string &parm_name,
72 int index_group,
const string &description,
73 OptionDispatchFunction option_function,
74 bool *bool_var = (
bool *)NULL,
75 void *option_data = (
void *)NULL);
76 void add_option(
const string &option,
const string &parm_name,
77 int index_group,
const string &description,
78 OptionDispatchMethod option_method,
79 bool *bool_var = (
bool *)NULL,
80 void *option_data = (
void *)NULL);
81 bool redescribe_option(
const string &option,
const string &description);
82 bool remove_option(
const string &option);
84 void add_path_replace_options();
85 void add_path_store_options();
87 static bool dispatch_none(
const string &opt,
const string &arg,
void *);
88 static bool dispatch_true(
const string &opt,
const string &arg,
void *var);
89 static bool dispatch_false(
const string &opt,
const string &arg,
void *var);
90 static bool dispatch_count(
const string &opt,
const string &arg,
void *var);
91 static bool dispatch_int(
const string &opt,
const string &arg,
void *var);
92 static bool dispatch_int_pair(
const string &opt,
const string &arg,
void *var);
93 static bool dispatch_int_quad(
const string &opt,
const string &arg,
void *var);
94 static bool dispatch_double(
const string &opt,
const string &arg,
void *var);
95 static bool dispatch_double_pair(
const string &opt,
const string &arg,
void *var);
96 static bool dispatch_double_triple(
const string &opt,
const string &arg,
void *var);
97 static bool dispatch_double_quad(
const string &opt,
const string &arg,
void *var);
98 static bool dispatch_color(
const string &opt,
const string &arg,
void *var);
99 static bool dispatch_string(
const string &opt,
const string &arg,
void *var);
100 static bool dispatch_vector_string(
const string &opt,
const string &arg,
void *var);
101 static bool dispatch_vector_string_comma(
const string &opt,
const string &arg,
void *var);
102 static bool dispatch_filename(
const string &opt,
const string &arg,
void *var);
103 static bool dispatch_search_path(
const string &opt,
const string &arg,
void *var);
104 static bool dispatch_coordinate_system(
const string &opt,
const string &arg,
void *var);
105 static bool dispatch_units(
const string &opt,
const string &arg,
void *var);
106 static bool dispatch_image_type(
const string &opt,
const string &arg,
void *var);
107 static bool dispatch_path_replace(
const string &opt,
const string &arg,
void *var);
108 static bool dispatch_path_store(
const string &opt,
const string &arg,
void *var);
110 static bool handle_help_option(
const string &opt,
const string &arg,
void *);
112 static void format_text(ostream &out,
bool &last_newline,
113 const string &prefix,
int indent_width,
114 const string &text,
int line_width);
117 bool _got_path_store;
118 bool _got_path_directory;
123 void get_terminal_width();
132 OptionDispatchFunction _option_function;
133 OptionDispatchMethod _option_method;
138 class SortOptionsByIndex {
140 bool operator () (
const Option *a,
const Option *b)
const;
146 typedef vector_string Runlines;
151 OptionsByName _options_by_name;
152 OptionsByIndex _options_by_index;
154 bool _sorted_options;
157 GotOptions _got_options;
161 bool _got_terminal_width;
163 bool _got_option_indent;
166 #include "programBase.I" This is intended to be the base class for most general-purpose utility programs in the PANDATOOL tree...
virtual void parse_command_line(int argc, char **argv)
Dispatches on each of the options on the command line, and passes the remaining parameters to handle_...
void show_usage()
Writes the usage line(s) to stderr.
void show_description()
Writes the program description to stderr.
The name of a file, such as a texture file or an Egg file.
void show_text(const string &text)
Formats the indicated text to stderr with the known _terminal_width.
string get_exec_command() const
Returns the command that invoked this program, as a shell-friendly string, suitable for pasting into ...
void show_options()
Describes each of the available options to stderr.
This encapsulates the user's command-line request to replace existing, incorrect pathnames to models ...
void write_man_page(ostream &out)
Generates a man page in nroff syntax based on the description and options.