ParameterSetImplHelpers.h
Go to the documentation of this file.
1 #ifndef fhiclcpp_detail_ParameterSetImplHelpers_h
2 #define fhiclcpp_detail_ParameterSetImplHelpers_h
3 
4 #include "fhiclcpp/coding.h"
5 
6 #include <any>
7 #include <string>
8 #include <vector>
9 
10 namespace fhicl::detail {
11 
12  //===============================================================
13  // get_names
14 
15  class Keys {
16  public:
17  Keys(std::vector<std::string> const& keys, std::string const& last)
18  : tables_{keys}, last_{last}
19  {}
20 
21  auto const&
22  tables() const noexcept
23  {
24  return tables_;
25  }
26  auto const&
27  last() const noexcept
28  {
29  return last_;
30  }
31 
32  private:
33  std::vector<std::string> tables_;
35  };
36 
37  Keys get_names(std::string const& key);
38 
39  //===============================================================
40  // get_sequence_indices
41 
42  class SequenceKey {
43  public:
45  std::vector<std::size_t> const& indices)
46  : name_{name}, indices_{indices}
47  {}
48 
49  auto const&
50  name() const noexcept
51  {
52  return name_;
53  }
54  auto const&
55  indices() const noexcept
56  {
57  return indices_;
58  }
59 
60  private:
62  std::vector<std::size_t> indices_;
63  };
64 
66 
67  //===============================================================
68  // find_an_any
69 
71 
72  inline bool
73  find_an_any(cit_size_t it, cit_size_t const cend, std::any& a)
74  {
75  if (it == cend) {
76  // If we got this far, that means the element must exist,
77  // otherwise the previous recursive 'find_parameter' call would
78  // have returned false.
79  return true;
80  }
81 
82  auto seq = std::any_cast<ps_sequence_t>(a);
83  if (*it >= seq.size())
84  return false;
85 
86  a = std::move(seq[*it]);
87 
88  return find_an_any(++it, cend, a);
89  }
90 }
91 
92 #endif /* fhiclcpp_detail_ParameterSetImplHelpers_h */
93 
94 // Local variables:
95 // mode: c++
96 // End:
static QCString name
Definition: declinfo.cpp:673
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
Definition: StdUtils.h:87
std::string string
Definition: nybbler.cc:12
auto const & indices() const noexcept
Keys get_names(std::string const &key)
intermediate_table::const_iterator const_iterator
bool find_an_any(cit_size_t it, cit_size_t const cend, std::any &a)
std::vector< std::any > ps_sequence_t
Definition: coding.h:45
auto const & name() const noexcept
std::vector< std::string > tables_
def key(type, name=None)
Definition: graph.py:13
const double a
def move(depos, offset)
Definition: depos.py:107
std::vector< std::size_t > indices_
constexpr std::array< std::size_t, geo::vect::dimension< Vector >)> indices()
Returns a sequence of indices valid for a vector of the specified type.
auto const & last() const noexcept
SequenceKey get_sequence_indices(std::string const &key)
SequenceKey(std::string const &name, std::vector< std::size_t > const &indices)
auto const & tables() const noexcept
Keys(std::vector< std::string > const &keys, std::string const &last)
std::vector< std::size_t >::const_iterator cit_size_t