summaryrefslogtreecommitdiff
path: root/option.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2006-02-27 23:52:31 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 02:41:27 -0400
commit7901598f1d1e419e19c860e81749805371298030 (patch)
treef3b4b42ad4217cd5a59eafb8cb8ffacea83b60ca /option.h
parent4507573d4fbc4ece6a4bb832b2e1fffae0885db8 (diff)
downloadfork-ledger-7901598f1d1e419e19c860e81749805371298030.tar.gz
fork-ledger-7901598f1d1e419e19c860e81749805371298030.tar.bz2
fork-ledger-7901598f1d1e419e19c860e81749805371298030.zip
Checked in all major updates.
Diffstat (limited to 'option.h')
-rw-r--r--option.h33
1 files changed, 12 insertions, 21 deletions
diff --git a/option.h b/option.h
index 6de6ac91..1acc20e9 100644
--- a/option.h
+++ b/option.h
@@ -5,20 +5,14 @@
#include <string>
#include <exception>
-struct option_handler {
- bool handled;
- option_handler() : handled(false) {}
- virtual ~option_handler() {}
- virtual void operator()(const char * arg = NULL) = 0;
-};
+typedef void (*handler_t)(const char * arg);
struct option_t {
- char short_opt;
- std::string long_opt;
- bool wants_arg;
- option_handler * handler;
-
- option_t() : short_opt(0), wants_arg(false), handler(NULL) {}
+ const char * long_opt;
+ char short_opt;
+ bool wants_arg;
+ handler_t handler;
+ bool handled;
};
class option_error : public std::exception {
@@ -32,14 +26,11 @@ class option_error : public std::exception {
}
};
-void add_option_handler(std::list<option_t>& options, const std::string& label,
- const std::string& opt_chars, option_handler& option);
-bool process_option(std::list<option_t>& options,
- const std::string& opt, const char * arg = NULL);
-void process_arguments(std::list<option_t>& options,
- int argc, char ** argv, const bool anywhere,
- std::list<std::string>& args);
-void process_environment(std::list<option_t>& options,
- char ** envp, const std::string& tag);
+bool process_option(option_t * options, const std::string& opt,
+ const char * arg = NULL);
+void process_arguments(option_t * options, int argc, char ** argv,
+ const bool anywhere, std::list<std::string>& args);
+void process_environment(option_t * options, char ** envp,
+ const std::string& tag);
#endif // _OPTION_H