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

◆ main()

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

Definition at line 85 of file handletest.cc.

References tfxx::cmdline::arg_no, CODE, HANDLETEST_VERSION, ILLEGAL, and tfxx::cmdline::Commandline::optset().

86 {
87 
88  // define usage information
89  char usage_text[]=
90  {
92  "usage: handletest" "\n"
93  " or: handletest --help|-h" "\n"
94  };
95 
96  // define full help text
97  char help_text[]=
98  {
99  HANDLETEST_CVSID
100  };
101 
102  // define commandline options
103  using namespace tfxx::cmdline;
104  static Declare options[]=
105  {
106  // 0: print help
107  {"help",arg_no,"-"},
108  // 1: verbose mode
109  {"v",arg_no,"-"},
110  {NULL}
111  };
112 
113  // no arguments? print usage...
114  if (iargc<1)
115  {
116  cerr << usage_text << endl;
117  exit(0);
118  }
119 
120  // collect options from commandline
121  Commandline cmdline(iargc, argv, options);
122 
123  // help requested? print full help text...
124  if (cmdline.optset(0))
125  {
126  cerr << usage_text << endl;
127  cerr << help_text << endl;
128  exit(0);
129  }
130 
131  CODE( Tirange r1(4,8) );
132  CODE( cout << r1 << endl );
133  CODE( typedef tfxx::Handle<Tirange> Tirhandle );
134  CODE( Tirhandle h1(r1) );
135  CODE( cout << *h1 << endl );
136  CODE( Tirhandle h2(h1) );
137  CODE( cout << *h2 << endl );
138  CODE( *h1=Tirange(12,34) );
139  CODE( cout << *h2 << endl );
140  CODE( h2->shift(-12) );
141  CODE( cout << *h1 << endl );
142  CODE( Tirhandle::Tcoc ch1(h1) );
143  CODE( cout << *ch1 << endl );
144  CODE( h2->shift(10) );
145  CODE( cout << *ch1 << endl );
146  ILLEGAL( ch1->shift(10) );
147  CODE( cout << *h1 << ", " << h1 << endl );
148  CODE( cout << *ch1 << ", " << ch1 << endl );
149 
150  CODE( String s1("Hi there") );
151  CODE( s1.print() );
152  CODE( Int i1(13) );
153  CODE( i1.print() );
154  CODE( typedef tfxx::Handle<Any> Tanyhandle );
155  CODE( Tanyhandle ah1(s1) );
156  CODE( ah1->print() );
157  CODE( Tanyhandle ah2(new String("ein string")) );
158  CODE( ah2->print() );
159  CODE( Tanyhandle ah3(ah2) );
160  CODE( ah3->print() );
161  CODE( Tanyhandle ah4(new Int(4321)) );
162  CODE( ah4->print() );
163  CODE( ah3=ah4 );
164  CODE( ah3->print() );
165 }
#define HANDLETEST_VERSION
Definition: handletest.cc:34
#define CODE(line)
Show code along with output of executed code.
Definition: handletest.cc:48
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 ILLEGAL(line)
Show code that does not compile.
Definition: handletest.cc:51
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: