@@ -44,13 +44,26 @@ CommandActionKind ArgumentsParser::parse_command_kind(char *arg)
4444 return command_kind;
4545}
4646
47- uint64_t ArgumentsParser::parse_number (char *arg)
47+ uint32_t ArgumentsParser::parse_domain_id (char *arg)
48+ {
49+ std::stringstream stream (arg);
50+ uint32_t value;
51+ if (!(stream >> value)) {
52+ std::stringstream error_stream;
53+ error_stream << " Error: could not parse domain id value provided, '" << arg
54+ << " '" ;
55+ throw std::runtime_error (error_stream.str ());
56+ }
57+ return value;
58+ }
59+
60+ uint64_t ArgumentsParser::parse_timestamp (char *arg)
4861{
4962 std::stringstream stream (arg);
5063 uint64_t value;
5164 if (!(stream >> value)) {
5265 std::stringstream error_stream;
53- error_stream << " Error: could not parse uint64 value provided, '" << arg
66+ error_stream << " Error: could not parse timestamp value provided, '" << arg
5467 << " '" ;
5568 throw std::runtime_error (error_stream.str ());
5669 }
@@ -237,7 +250,7 @@ ArgumentsParser::ArgumentsParser(int argc, char *argv[])
237250 << DOMAIN_ID_ARG_NAME << " parameter" ;
238251 throw std::runtime_error (error_stream.str ());
239252 }
240- admin_domain_id_ = parse_number (argv[current_arg + 1 ]);
253+ admin_domain_id_ = parse_domain_id (argv[current_arg + 1 ]);
241254 current_arg += 2 ;
242255 } else if (TIME_TAG_ARG_NAME.compare (argv[current_arg]) == 0 ) {
243256 // This parameter may use one or two arguments
@@ -264,7 +277,7 @@ ArgumentsParser::ArgumentsParser(int argc, char *argv[])
264277 octet_kind_ = OctetKind::BREAKPOINT;
265278 // This parameter may use one or two arguments
266279 br_params_.value ().timestamp_nanos (
267- parse_number (argv[current_arg + 1 ]));
280+ parse_timestamp (argv[current_arg + 1 ]));
268281 // Check if a label has been provided
269282 if (current_arg + 2 < argc) {
270283 br_params_.label (std::string (argv[current_arg + 2 ]));
@@ -285,14 +298,14 @@ ArgumentsParser::ArgumentsParser(int argc, char *argv[])
285298 // This parameter may use one or two arguments
286299 if (is_number (argv[current_arg + 1 ])) {
287300 br_params_.value ().timestamp_nanos (
288- parse_number (argv[current_arg + 1 ]));
301+ parse_timestamp (argv[current_arg + 1 ]));
289302 } else {
290303 br_params_.label (std::string (argv[current_arg + 1 ]));
291304 }
292305 current_arg += 2 ;
293306 } else if (current_arg + 2 < argc) {
294307 br_params_.value ().timestamp_nanos (
295- parse_number (argv[current_arg + 1 ]));
308+ parse_timestamp (argv[current_arg + 1 ]));
296309 br_params_.label (std::string (argv[current_arg + 2 ]));
297310 current_arg += 3 ;
298311 } else {
@@ -308,14 +321,14 @@ ArgumentsParser::ArgumentsParser(int argc, char *argv[])
308321 // This parameter may use one or two arguments
309322 if (is_number (argv[current_arg + 1 ])) {
310323 br_params_.value ().timestamp_nanos (
311- parse_number (argv[current_arg + 1 ]));
324+ parse_timestamp (argv[current_arg + 1 ]));
312325 } else {
313326 br_params_.label (std::string (argv[current_arg + 1 ]));
314327 }
315328 current_arg += 2 ;
316329 } else if (current_arg + 2 < argc) {
317330 br_params_.value ().timestamp_nanos (
318- parse_number (argv[current_arg + 1 ]));
331+ parse_timestamp (argv[current_arg + 1 ]));
319332 br_params_.label (std::string (argv[current_arg + 2 ]));
320333 current_arg += 3 ;
321334 } else {
@@ -330,7 +343,7 @@ ArgumentsParser::ArgumentsParser(int argc, char *argv[])
330343 if (current_arg + 1 < argc) {
331344 octet_kind_ = OctetKind::CONTINUE;
332345 continue_params_.value ().offset (
333- parse_number (argv[current_arg + 1 ]));
346+ parse_timestamp (argv[current_arg + 1 ]));
334347 current_arg += 2 ;
335348 } else {
336349 // No number of seconds for the continue param
@@ -344,7 +357,7 @@ ArgumentsParser::ArgumentsParser(int argc, char *argv[])
344357 if (current_arg + 1 < argc) {
345358 octet_kind_ = OctetKind::CONTINUE;
346359 continue_params_.value ().slices (
347- parse_number (argv[current_arg + 1 ]));
360+ parse_timestamp (argv[current_arg + 1 ]));
348361 current_arg += 2 ;
349362 } else {
350363 // No number of slices for the continue param
@@ -357,7 +370,7 @@ ArgumentsParser::ArgumentsParser(int argc, char *argv[])
357370 if (current_arg + 1 < argc) {
358371 octet_kind_ = OctetKind::TIMESTAMPHOLDER;
359372 timestamp_holder_.timestamp_nanos (
360- parse_number (argv[current_arg + 1 ]));
373+ parse_timestamp (argv[current_arg + 1 ]));
361374 current_arg += 2 ;
362375 } else {
363376 // No timestamp for the jump in time
0 commit comments