From 1ed5a6263d285a566396a293d88a25e073cfa90d Mon Sep 17 00:00:00 2001 From: David Flitney <dave.flitney@ndcn.ox.ac.uk> Date: Fri, 24 Nov 2000 13:18:22 +0000 Subject: [PATCH] *** empty log message *** --- options.h | 12 +++++++----- opttst.cc | 19 ++++++++++++++----- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/options.h b/options.h index 31aabcb..f2127c6 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 71b5a82..1afb472 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()) { -- GitLab