Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / ACE / examples / Misc / test_get_opt.cpp
blob5c35ad26ff2254fe15566da31437df623dc6da5e
1 // Test the ACE_Get_Opt class.
3 #include "ace/OS_main.h"
4 #include "ace/Get_Opt.h"
5 #include "ace/Log_Msg.h"
8 int
9 ACE_TMAIN (int argc, ACE_TCHAR *argv[])
11 ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("ab:cd:ef:gh:"));
12 int c;
14 while ((c = get_opt ()) != EOF)
15 switch (c)
17 case 'a':
18 ACE_DEBUG ((LM_DEBUG, "got a\n"));
19 break;
20 case 'b':
21 ACE_DEBUG ((LM_DEBUG, "got b with arg %s\n", get_opt.opt_arg ()));
22 break;
23 case 'c':
24 ACE_DEBUG ((LM_DEBUG, "got c\n"));
25 break;
26 case 'd':
27 ACE_DEBUG ((LM_DEBUG, "got d with arg %s\n", get_opt.opt_arg ()));
28 break;
29 case 'e':
30 ACE_DEBUG ((LM_DEBUG, "got e\n"));
31 break;
32 case 'f':
33 ACE_DEBUG ((LM_DEBUG, "got f with arg %s\n", get_opt.opt_arg ()));
34 break;
35 case 'g':
36 ACE_DEBUG ((LM_DEBUG, "got g\n"));
37 break;
38 case 'h':
39 ACE_DEBUG ((LM_DEBUG, "got h with arg %s\n", get_opt.opt_arg ()));
40 break;
41 default:
42 ACE_DEBUG ((LM_DEBUG, "got %c, which is unrecognized!\n", c));
43 break;
46 for (int i = get_opt.opt_ind (); i < argc; i++)
47 ACE_DEBUG ((LM_DEBUG, "optind = %d, argv[optind] = %s\n",
48 i, argv[i]));
50 return 0;