LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
check_nargs_for_bounded_sequences.cc
Go to the documentation of this file.
3 
4 #include <cstddef>
5 #include <sstream>
6 #include <string>
7 
8 void
10  std::size_t const expected,
11  std::size_t const nargs)
12 {
13  constexpr auto maybe_plural = [](std::size_t const nargs) {
14  return nargs == 1ull ? "" : "s";
15  };
16  constexpr auto has_or_have = [](std::size_t const nargs) {
17  return nargs == 1ull ? "has" : "have";
18  };
19  if (nargs != expected) {
20  std::ostringstream oss;
21  oss << '\n'
22  << nargs << " value" << maybe_plural(nargs) << ' ' << has_or_have(nargs)
23  << " been provided for the parameter with key:\n"
24  << " " << key << '\n'
25  << "which expects " << expected << " value" << maybe_plural(expected)
26  << '.';
27  throw detail::validationException{oss.str().c_str()};
28  }
29 }
void check_nargs_for_bounded_sequences(std::string const &key, std::size_t expected, std::size_t provided)