TF++, Miscellaneous classes and modules in C++:

◆ main()

int main ( int  iargc,
char *  argv[] 
)

Definition at line 50 of file rangetest.cc.

References tfxx::RangeList< T >::append(), tfxx::cmdline::arg_no, tfxx::cmdline::arg_yes, CODE, tfxx::cmdline::Commandline::int_arg(), tfxx::cmdline::Commandline::optset(), RANGETEST_VERSION, and tfxx::cmdline::Commandline::string_arg().

51 {
52 
53  // define usage information
54  char usage_text[]=
55  {
57  "usage: rangetest [-v] [-step s] [-list l]" "\n"
58  " or: rangetest --help|-h" "\n"
59  };
60 
61  // define full help text
62  char help_text[]=
63  {
64  RANGETEST_CVSID
65  };
66 
67  // define commandline options
68  using namespace tfxx::cmdline;
69  static Declare options[]=
70  {
71  // 0: print help
72  {"help",arg_no,"-"},
73  // 1: verbose mode
74  {"v",arg_no,"-"},
75  // 2: step size
76  {"step",arg_yes,"1"},
77  // 3: step size
78  {"list",arg_yes,"1-10"},
79  {NULL}
80  };
81 
82  // no arguments? print usage...
83  if (iargc<1)
84  {
85  cerr << usage_text << endl;
86  exit(0);
87  }
88 
89  // collect options from commandline
90  Commandline cmdline(iargc, argv, options);
91 
92  // help requested? print full help text...
93  if (cmdline.optset(0))
94  {
95  cerr << usage_text << endl;
96  cerr << help_text << endl;
97  exit(0);
98  }
99 
100  int step=cmdline.int_arg(2);
101  std::string list=cmdline.string_arg(3);
102 
103  CODE( tfxx::Range<int> Tirange(5,12) );
105  CODE( while (RS.more()) { cout << ++RS << ", "; });
106  cout << endl;
107 
108  CODE( tfxx::Range<int> R1(5,12) );
109  CODE( tfxx::Range<int> R2(50) );
110  CODE( tfxx::Range<int> R3(18,29) );
112  CODE( RL.append(R1) );
113  CODE( RL.append(R2) );
114  CODE( RL.append(R3) );
115  CODE( tfxx::RangeListStepper<int> RLS(RL, 2) );
116  CODE( while (RLS.valid()) { cout << RLS << ", "; ++RLS; });
117  cout << endl;
118 
119  CODE( cout << step << endl );
120  CODE( cout << list << endl );
121  // tfxx::RangeListStepper<int> RLSsa(tfxx::string::rangelist<int>(list), step);
122  CODE( tfxx::RangeListStepper<int> RLSs(tfxx::string::rangelist<int>(list), step) );
123  CODE( while (RLSs.valid()) { cout << RLSs << ", "; ++RLSs; });
124  cout << endl;
125 }
option requires an argument
Definition: commandline.h:102
#define RANGETEST_VERSION
Definition: rangetest.cc:34
A class to deal with numerical ranges.
Definition: range.h:50
Namespace containing all components of module commandline. ,.
Definition: commandline.cc:41
Evaluates commandline by calling long_getopt. ,You may instantiate a Commandline object by passing th...
Definition: commandline.h:201
#define CODE(line)
Show code along with output of executed code.
Definition: rangetest.cc:48
tfxx::Range< int > Tirange
Definition: handletest.cc:54
struct to define options ,This struct is used to define a list of options. An example is: ...
Definition: commandline.h:136
option has no argument
Definition: commandline.h:100
Here is the call graph for this function: