MCPcopy Create free account
hub / github.com/OpenDDS/OpenDDS / parse_args

Function parse_args

tests/DCPS/FooTest4/main.cpp:45–100  ·  view source on GitHub ↗

parse the command line arguments

Source from the content-addressed store, hash-verified

43
44/// parse the command line arguments
45int parse_args (int argc, ACE_TCHAR *argv[])
46{
47 u_long mask = ACE_LOG_MSG->priority_mask(ACE_Log_Msg::PROCESS) ;
48 ACE_LOG_MSG->priority_mask(mask | LM_TRACE | LM_DEBUG, ACE_Log_Msg::PROCESS) ;
49 ACE_Arg_Shifter arg_shifter (argc, argv);
50
51 while (arg_shifter.is_anything_left ())
52 {
53 // options:
54 // -t use_take?1:0 defaults to 0
55 // -i num_reads_per_thread defaults to 1
56 // -r num_datareaders defaults to 1
57 // -m multiple_instances?1:0 defaults to 0
58 // -n max_samples_per_instance defaults to INFINITE
59 // -d history.depth defaults to 1
60
61 const ACE_TCHAR *currentArg = 0;
62
63 if ((currentArg = arg_shifter.get_the_parameter(ACE_TEXT("-t"))) != 0)
64 {
65 use_take = ACE_OS::atoi (currentArg);
66 arg_shifter.consume_arg ();
67 }
68 else if ((currentArg = arg_shifter.get_the_parameter(ACE_TEXT("-m"))) != 0)
69 {
70 multiple_instances = ACE_OS::atoi (currentArg);
71 arg_shifter.consume_arg ();
72 }
73 else if ((currentArg = arg_shifter.get_the_parameter(ACE_TEXT("-i"))) != 0)
74 {
75 num_reads_per_thread = ACE_OS::atoi (currentArg);
76 arg_shifter.consume_arg ();
77 }
78 else if ((currentArg = arg_shifter.get_the_parameter(ACE_TEXT("-r"))) != 0)
79 {
80 num_datareaders = ACE_OS::atoi (currentArg);
81 arg_shifter.consume_arg ();
82 }
83 else if ((currentArg = arg_shifter.get_the_parameter(ACE_TEXT("-n"))) != 0)
84 {
85 max_samples_per_instance = ACE_OS::atoi (currentArg);
86 arg_shifter.consume_arg ();
87 }
88 else if ((currentArg = arg_shifter.get_the_parameter(ACE_TEXT("-d"))) != 0)
89 {
90 history_depth = ACE_OS::atoi (currentArg);
91 arg_shifter.consume_arg ();
92 }
93 else
94 {
95 arg_shifter.ignore_arg ();
96 }
97 }
98 // Indicates successful parsing of the command line
99 return 0;
100}
101
102

Callers 5

ACE_TMAINFunction · 0.70
initMethod · 0.50
runMethod · 0.50
initMethod · 0.50
runMethod · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected