diff --git a/options.h b/options.h index 31aabcbc3db5819bfec286d53ea3bed8fd02d544..f2127c66005ba9fabc18879e1a6a8473ea7a25eb 100644 --- a/options.h +++ b/options.h @@ -8,7 +8,12 @@ #define POSIX_SOURCE 1 -namespace Options { +namespace Utilities { + + void string_to_T(bool &b, const string& s); + void string_to_T(string& d, const string& s); + void string_to_T(int& i, const string& s); + void string_to_T(float& v, const string& s); typedef enum { no_argument = 0, requires_argument, optional_argument @@ -92,10 +97,7 @@ namespace Options { bool unset_, compulsory_; }; - void string_to_T(bool &b, const string& s); - void string_to_T(string& d, const string& s); - void string_to_T(int& i, const string& s); - void string_to_T(float& v, const string& s); + ostream& operator<<(ostream &os, const BaseOption& o); /** Template class adding type specific behaviour to BaseOption. Define diff --git a/opttst.cc b/opttst.cc index 71b5a82bfeb7b7840c9b637afbfd2311be414314..1afb4724ef191bc54c9362d85215bee22d205cf2 100644 --- a/opttst.cc +++ b/opttst.cc @@ -1,7 +1,8 @@ +#include "options.h" +// $Id$ - -using namespace Options; +using namespace Utilities; Option<bool> verbose(string("-V,--verbose"), false, string("switch on diagnostic messages"), @@ -19,10 +20,18 @@ Option<string> resid(string("-r,--res"), string("res4d"), string("4d `residual-of-fit' image"), true, requires_argument); +string title = +"opttst (Version 1.0)\n\ +\t\t\t\tCopyright(c) 2000, University of Oxford\n\ +\t\t\t\tDave Flitney"; + +string examples = +"opttst -d <number> --mask <filename> --res <filename>\n\ +opttst --verbose\n"; + int main(unsigned int argc, char **argv) { - OptionParser options("options", - "-d <number> --mask <filename> --res <filename>"); + OptionParser options(title, examples); try { @@ -35,7 +44,7 @@ int main(unsigned int argc, char **argv) { for(unsigned int a = options.parse_command_line(argc, argv); a < argc; a++) cout << argv[a] << endl; - if(help.value()) + if(help.value() || ! options.check_compulsory_arguments()) options.usage(); if(verbose.value()) {