Skip to content
Snippets Groups Projects
Commit 1ed5a626 authored by David Flitney's avatar David Flitney
Browse files

*** empty log message ***

parent 875ff313
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
#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()) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment