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

Function parse_args

tools/inspect/Inspect.cpp:161–213  ·  view source on GitHub ↗

parse the command line arguments

Source from the content-addressed store, hash-verified

159
160// parse the command line arguments
161int parse_args(int argc, ACE_TCHAR* argv[])
162{
163 unsigned long mask = ACE_LOG_MSG->priority_mask(ACE_Log_Msg::PROCESS);
164 ACE_LOG_MSG->priority_mask(mask | LM_TRACE | LM_DEBUG, ACE_Log_Msg::PROCESS);
165
166 prog_name = ACE_TEXT_ALWAYS_CHAR(argv[0]);
167 Args args;
168 for (int i = 1; i < argc; ++i) {
169 args.push_back(ACE_TEXT_ALWAYS_CHAR(argv[i]));
170 }
171
172 try {
173 // Parse options
174 if (has_option(args, "-h") || has_option(args, "--help")) {
175 print_help();
176 std::exit(0);
177 }
178 if (has_option(args, "-v") || has_option(args, "--version")) {
179 std::cout << "Version " OPENDDS_VERSION << std::endl;
180 std::exit(0);
181 }
182 writer_count = has_option(args, "-w") || has_option(args, "--writer-count");
183 {
184 const std::string opt = "--samples";
185 AfterOpt after_opt = get_option(args, opt);
186 if (after_opt.first) {
187 num_samples = get_option_argument_uint<unsigned>(args, after_opt, opt);
188 }
189 }
190 {
191 const std::string opt = "--time";
192 AfterOpt after_opt = get_option(args, opt);
193 if (after_opt.first) {
194 num_seconds = get_option_argument_uint<unsigned>(args, after_opt, opt);
195 }
196 }
197 check_for_unknown_options(args);
198
199 // Parse positional arguments
200 if (args.size() != 3) {
201 std::cerr << "ERROR: incorrect number of arguments: expected 3, received " << args.size() << "\n";
202 throw 1;
203 }
204 topic_name = args[0];
205 type_name = args[1];
206 domainid = get_pos_argument_int<DDS::DomainId_t>(args, 2, "DOMAIN_ID");
207 } catch(int value) {
208 print_usage(true);
209 return value;
210 }
211
212 return 0;
213}
214
215class RecorderListenerImpl : public RecorderListener {
216public:

Callers 2

runFunction · 0.70

Calls 6

has_optionFunction · 0.85
print_helpFunction · 0.85
get_optionFunction · 0.85
print_usageFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected