// 22-Oct-93 Radek Marik adopted for C++ /* 24-Feb-93, J. Matas, created */ /* A program for a complex command line parsing for usage run: ex4 -help */ /*---------------------------------------------------------------------*/ //static char sccsid[]="@(#)93/06/23 g.matas@ee.surrey.ac.uk 1.1 ex4.c"; #include #include "amma/DList.hh" #include "amma/StdStrm.hh" #include "amma/Boolean.hh" #include "amma/StdType.hh" #include "amma/Option.hh" #include "amma/IntSArr1.hh" int main(int argc, char **argv) //========================= { OptionC option(argc,argv,TRUE); option.Comment("exOption: an example of using OptionC class"); option.Comment("==========================================="); IntT a = option.Int("alpha",10,"first parameter"); IntT d = option.Int("beta",a/10,"lower threshold"); RealT f = option.Real("pi",3.14,"define you own pie"); char * filename = option.CharArr("i","","input filename"); unsigned char sw = option.UnsignedChar("filter",'c', "switch selector for my filter"); BooleanT expand = option.Boolean("expand",0,"expand my panel"); IntSArray1dC pair = option.IntInt("pair", 1, 2,"first test pair"); IntSArray1dC ints = option.IntArr("ints",3,"array of 3 integers"); char * optionN = option.CharArr("o", "", "option string"); DListC opts = option.List("x","List of strings. "); char * file1 = option.CharArr("","","test file 1"); char * file2 = option.CharArr("","","test file 2"); //DListC opts2 = option.List(0,"The rest "); option.CompulsoryArgs(1); option.Compulsory("i"); option.DependXor("pi filter"); //option.DependIf("filter",'z',sw,"expand"); option.Check(); if (option.IsOnCommandLine(optionN)) cerrAMMA << "The option " << optionN << " is on command line.\n"; coutAMMA << "var a: " << a << '\n' << "var d: " << d << '\n' << "var f: " << f << '\n' << "vars pair: " << pair[0] << ' ' << pair[1] << '\n' << "array ints: " << ints[0] << ' ' << ints[1] << ' ' << ints[2] << '\n' << "switch: " << sw << '\n' << "expand: " << expand << '\n' << "filename: " << filename << '\n' << "file 1: " << file1 << '\n' << "file 2: " << file2 << '\n'; option.PrintUsage(); return 0; }