File: test_get_opt.cpp

package info (click to toggle)
ace 6.0.3%2Bdfsg-0.1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 49,368 kB
  • sloc: cpp: 341,826; perl: 30,850; ansic: 20,952; makefile: 10,144; sh: 4,744; python: 828; exp: 787; yacc: 511; xml: 330; lex: 158; lisp: 116; csh: 48; tcl: 5
file content (54 lines) | stat: -rw-r--r-- 1,335 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// $Id: test_get_opt.cpp 91671 2010-09-08 18:39:23Z johnnyw $

// Test the ACE_Get_Opt class.

#include "ace/OS_main.h"
#include "ace/Get_Opt.h"
#include "ace/Log_Msg.h"



int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("ab:cd:ef:gh:"));
  int c;

  while ((c = get_opt ()) != EOF)
    switch (c)
      {
      case 'a':
        ACE_DEBUG ((LM_DEBUG, "got a\n"));
        break;
      case 'b':
        ACE_DEBUG ((LM_DEBUG, "got b with arg %s\n", get_opt.opt_arg ()));
        break;
      case 'c':
        ACE_DEBUG ((LM_DEBUG, "got c\n"));
        break;
      case 'd':
        ACE_DEBUG ((LM_DEBUG, "got d with arg %s\n", get_opt.opt_arg ()));
        break;
      case 'e':
        ACE_DEBUG ((LM_DEBUG, "got e\n"));
        break;
      case 'f':
        ACE_DEBUG ((LM_DEBUG, "got f with arg %s\n", get_opt.opt_arg ()));
        break;
      case 'g':
        ACE_DEBUG ((LM_DEBUG, "got g\n"));
        break;
      case 'h':
        ACE_DEBUG ((LM_DEBUG, "got h with arg %s\n", get_opt.opt_arg ()));
        break;
      default:
        ACE_DEBUG ((LM_DEBUG, "got %c, which is unrecognized!\n", c));
        break;
      }

  for (int i = get_opt.opt_ind (); i < argc; i++)
    ACE_DEBUG ((LM_DEBUG, "optind = %d, argv[optind] = %s\n",
                i, argv[i]));

  return 0;
}