CMS 3D CMS Logo

Namespaces | Classes | Functions
cxxopts::values Namespace Reference

Namespaces

 detail
 

Classes

class  Abstract_value
 
class  Standard_value
 
class  Standard_value< bool >
 
struct  Type_is_container
 
struct  Type_is_container< std::vector< T > >
 

Functions

template<typename R , typename T >
checked_negate (T &&t, const std::string &, std::true_type)
 
template<typename R , typename T >
T checked_negate (T &&, const std::string &text, std::false_type)
 
template<typename T >
void integer_parser (const std::string &text, T &value)
 
void parse_value (const std::string &text, uint8_t &value)
 
void parse_value (const std::string &text, int8_t &value)
 
void parse_value (const std::string &text, uint16_t &value)
 
void parse_value (const std::string &text, int16_t &value)
 
void parse_value (const std::string &text, uint32_t &value)
 
void parse_value (const std::string &text, int32_t &value)
 
void parse_value (const std::string &text, uint64_t &value)
 
void parse_value (const std::string &text, int64_t &value)
 
void parse_value (const std::string &text, bool &value)
 
void parse_value (const std::string &text, std::string &value)
 
template<typename T >
void parse_value (const std::string &text, T &value)
 
template<typename T >
void parse_value (const std::string &text, std::vector< T > &value)
 
template<typename T >
void stringstream_parser (const std::string &text, T &value)
 

Function Documentation

◆ checked_negate() [1/2]

template<typename R , typename T >
R cxxopts::values::checked_negate ( T &&  t,
const std::string &  ,
std::true_type   
)

Definition at line 327 of file cxxopts.h.

References dttmaxenums::R, and submitPVValidationJobs::t.

327  {
328  // if we got to here, then `t` is a positive number that fits into
329  // `R`. So to avoid MSVC C4146, we first cast it to `R`.
330  // See https://github.com/jarro2783/cxxopts/issues/62 for more details.
331  return -static_cast<R>(t);
332  }

◆ checked_negate() [2/2]

template<typename R , typename T >
T cxxopts::values::checked_negate ( T &&  ,
const std::string &  text,
std::false_type   
)

Definition at line 335 of file cxxopts.h.

References submitPVValidationJobs::text.

335  {
336  throw Argument_incorrect_type(text);
337  }

◆ integer_parser()

template<typename T >
void cxxopts::values::integer_parser ( const std::string &  text,
T value 
)

Definition at line 340 of file cxxopts.h.

References edmMakeDummyCfis::base, ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), WZElectronSkims53X_cff::max, mps_fire::result, and submitPVValidationJobs::text.

Referenced by parse_value().

340  {
341  std::smatch match;
342  std::regex_match(text, match, integer_pattern);
343 
344  if (match.length() == 0) {
345  throw Argument_incorrect_type(text);
346  }
347 
348  if (match.length(4) > 0) {
349  value = 0;
350  return;
351  }
352 
353  using US = typename std::make_unsigned<T>::type;
354 
355  constexpr auto umax = (std::numeric_limits<US>::max)();
356  constexpr bool is_signed = std::numeric_limits<T>::is_signed;
357  const bool negative = match.length(1) > 0;
358  const uint8_t base = match.length(2) > 0 ? 16 : 10;
359 
360  auto value_match = match[3];
361 
362  US result = 0;
363 
364  for (auto iter = value_match.first; iter != value_match.second; ++iter) {
365  US digit = 0;
366 
367  if (*iter >= '0' && *iter <= '9') {
368  digit = *iter - '0';
369  } else if (base == 16 && *iter >= 'a' && *iter <= 'f') {
370  digit = *iter - 'a' + 10;
371  } else if (base == 16 && *iter >= 'A' && *iter <= 'F') {
372  digit = *iter - 'A' + 10;
373  } else {
374  throw Argument_incorrect_type(text);
375  }
376 
377  if (umax - digit < result * base) {
378  throw Argument_incorrect_type(text);
379  }
380 
381  result = result * base + digit;
382  }
383 
384  detail::check_signed_range<T>(negative, result, text);
385 
386  if (negative) {
387  value = checked_negate<T>(result, text, std::integral_constant<bool, is_signed>());
388  } else {
389  value = result;
390  }
391  }
Definition: value.py:1
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10

◆ parse_value() [1/12]

void cxxopts::values::parse_value ( const std::string &  text,
uint8_t &  value 
)
inline

Definition at line 402 of file cxxopts.h.

References integer_parser(), and submitPVValidationJobs::text.

Referenced by cxxopts::KeyValue::as(), cxxopts::values::Abstract_value< bool >::parse(), and parse_value().

void integer_parser(const std::string &text, T &value)
Definition: cxxopts.h:340
Definition: value.py:1

◆ parse_value() [2/12]

void cxxopts::values::parse_value ( const std::string &  text,
int8_t &  value 
)
inline

Definition at line 404 of file cxxopts.h.

References integer_parser(), and submitPVValidationJobs::text.

void integer_parser(const std::string &text, T &value)
Definition: cxxopts.h:340
Definition: value.py:1

◆ parse_value() [3/12]

void cxxopts::values::parse_value ( const std::string &  text,
uint16_t &  value 
)
inline

Definition at line 406 of file cxxopts.h.

References integer_parser(), and submitPVValidationJobs::text.

void integer_parser(const std::string &text, T &value)
Definition: cxxopts.h:340
Definition: value.py:1

◆ parse_value() [4/12]

void cxxopts::values::parse_value ( const std::string &  text,
int16_t &  value 
)
inline

Definition at line 408 of file cxxopts.h.

References integer_parser(), and submitPVValidationJobs::text.

void integer_parser(const std::string &text, T &value)
Definition: cxxopts.h:340
Definition: value.py:1

◆ parse_value() [5/12]

void cxxopts::values::parse_value ( const std::string &  text,
uint32_t &  value 
)
inline

Definition at line 410 of file cxxopts.h.

References integer_parser(), and submitPVValidationJobs::text.

void integer_parser(const std::string &text, T &value)
Definition: cxxopts.h:340
Definition: value.py:1

◆ parse_value() [6/12]

void cxxopts::values::parse_value ( const std::string &  text,
int32_t &  value 
)
inline

Definition at line 412 of file cxxopts.h.

References integer_parser(), and submitPVValidationJobs::text.

void integer_parser(const std::string &text, T &value)
Definition: cxxopts.h:340
Definition: value.py:1

◆ parse_value() [7/12]

void cxxopts::values::parse_value ( const std::string &  text,
uint64_t &  value 
)
inline

Definition at line 414 of file cxxopts.h.

References integer_parser(), and submitPVValidationJobs::text.

void integer_parser(const std::string &text, T &value)
Definition: cxxopts.h:340
Definition: value.py:1

◆ parse_value() [8/12]

void cxxopts::values::parse_value ( const std::string &  text,
int64_t &  value 
)
inline

Definition at line 416 of file cxxopts.h.

References integer_parser(), and submitPVValidationJobs::text.

void integer_parser(const std::string &text, T &value)
Definition: cxxopts.h:340
Definition: value.py:1

◆ parse_value() [9/12]

void cxxopts::values::parse_value ( const std::string &  text,
bool &  value 
)
inline

Definition at line 418 of file cxxopts.h.

References mps_fire::result, and submitPVValidationJobs::text.

418  {
419  std::smatch result;
420  std::regex_match(text, result, truthy_pattern);
421 
422  if (!result.empty()) {
423  value = true;
424  return;
425  }
426 
427  std::regex_match(text, result, falsy_pattern);
428  if (!result.empty()) {
429  value = false;
430  return;
431  }
432 
433  throw Argument_incorrect_type(text);
434  }
Definition: value.py:1

◆ parse_value() [10/12]

void cxxopts::values::parse_value ( const std::string &  text,
std::string &  value 
)
inline

Definition at line 436 of file cxxopts.h.

References submitPVValidationJobs::text.

◆ parse_value() [11/12]

template<typename T >
void cxxopts::values::parse_value ( const std::string &  text,
T value 
)

Definition at line 442 of file cxxopts.h.

References stringstream_parser(), and submitPVValidationJobs::text.

442  {
444  }
void stringstream_parser(const std::string &text, T &value)
Definition: cxxopts.h:394
Definition: value.py:1

◆ parse_value() [12/12]

template<typename T >
void cxxopts::values::parse_value ( const std::string &  text,
std::vector< T > &  value 
)

Definition at line 447 of file cxxopts.h.

References parse_value(), submitPVValidationJobs::text, and findQualityFiles::v.

447  {
448  T v;
449  parse_value(text, v);
450  value.push_back(v);
451  }
void parse_value(const std::string &text, std::vector< T > &value)
Definition: cxxopts.h:447
Definition: value.py:1
long double T

◆ stringstream_parser()

template<typename T >
void cxxopts::values::stringstream_parser ( const std::string &  text,
T value 
)

Definition at line 394 of file cxxopts.h.

References recoMuon::in, submitPVValidationJobs::text, and cxxopts::value().

Referenced by parse_value().

394  {
395  std::stringstream in(text);
396  in >> value;
397  if (!in) {
398  throw Argument_incorrect_type(text);
399  }
400  }
std::shared_ptr< Value > value(T &t)
Definition: cxxopts.h:579