Public Member Functions | Private Member Functions | Private Attributes | List of all members
fhicl::detail::PrintAllowedConfiguration Class Reference

#include <PrintAllowedConfiguration.h>

Inheritance diagram for fhicl::detail::PrintAllowedConfiguration:
fhicl::detail::ParameterWalker< tt::const_flavor::require_const >

Public Member Functions

 PrintAllowedConfiguration (std::ostream &os, bool const showParents=false, std::string const &prefix=std::string(3, ' '), bool const stlf=false)
 
- Public Member Functions inherited from fhicl::detail::ParameterWalker< tt::const_flavor::require_const >
 ParameterWalker ()=default
 
virtual ~ParameterWalker ()=default
 
void walk_over (tt::maybe_const_t< ParameterBase, C > &)
 
bool do_before_action (tt::maybe_const_t< ParameterBase, C > &p)
 
void do_after_action (tt::maybe_const_t< ParameterBase, C > &p)
 
void do_enter_table (tt::maybe_const_t< TableBase, C > &t)
 
void do_exit_table (tt::maybe_const_t< TableBase, C > &t)
 
void do_enter_sequence (tt::maybe_const_t< SequenceBase, C > &s)
 
void do_exit_sequence (tt::maybe_const_t< SequenceBase, C > &s)
 
void do_atom (tt::maybe_const_t< AtomBase, C > &a)
 
void do_delegated_parameter (tt::maybe_const_t< DelegateBase, C > &dp)
 

Private Member Functions

bool before_action (ParameterBase const &) override
 
void after_action (ParameterBase const &) override
 
void enter_table (TableBase const &) override
 
void exit_table (TableBase const &) override
 
void enter_sequence (SequenceBase const &) override
 
void exit_sequence (SequenceBase const &) override
 
void atom (AtomBase const &) override
 
void delegated_parameter (DelegateBase const &) override
 
void cacheTopLevelParameter (ParameterBase const &p)
 
void maybeReleaseTopLevelParameter (ParameterBase const &p)
 
bool suppressFormat (ParameterBase const &p)
 

Private Attributes

std::ostream & buffer_
 
Indentation indent_
 
bool suppressTopLevelFormatting_
 
std::string cachedTopLevelParameter_ {}
 
std::stack< MaybeDisplayParentmps_ {}
 
std::unordered_set< std::stringkeysWithCommas_ {}
 
std::unordered_set< std::stringkeysWithEllipses_ {}
 
bool showParentsForFirstParam_
 

Detailed Description

Definition at line 15 of file PrintAllowedConfiguration.h.

Constructor & Destructor Documentation

PrintAllowedConfiguration::PrintAllowedConfiguration ( std::ostream &  os,
bool const  showParents = false,
std::string const &  prefix = std::string(3, ' '),
bool const  stlf = false 
)

Member Function Documentation

void PrintAllowedConfiguration::after_action ( ParameterBase const &  p)
overrideprivate

Definition at line 159 of file PrintAllowedConfiguration.cc.

160 {
161  buffer_ << suffix(keysWithCommas_, keysWithEllipses_, p.key(), indent_());
162 
163  if (p.has_default() && p.parameter_type() == par_type::ATOM)
164  buffer_ << " # default";
165 
166  if (!suppressFormat(p)) {
167  if (p.is_conditional()) {
168  indent_.modify_top("└" + string_repeat(30, "─"));
169  buffer_ << '\n' << indent_();
170  indent_.modify_top(std::string(3, ' '));
171  } else if (p.is_optional()) {
172  indent_.modify_top(std::string(3, ' '));
173  }
174  }
175 
177  buffer_ << '\n' << mps_.top().closing_braces();
178  mps_.pop();
179 }
std::string string
Definition: nybbler.cc:12
void maybeReleaseTopLevelParameter(ParameterBase const &p)
void modify_top(std::string const &s)
Definition: Indentation.h:36
p
Definition: test.py:223
std::unordered_set< std::string > keysWithCommas_
std::unordered_set< std::string > keysWithEllipses_
void PrintAllowedConfiguration::atom ( AtomBase const &  a)
overrideprivate

Definition at line 244 of file PrintAllowedConfiguration.cc.

245 {
246  buffer_ << maybeName{a, indent_()} << a.stringified_value();
247 }
const double a
bool PrintAllowedConfiguration::before_action ( ParameterBase const &  p)
overrideprivate

Definition at line 108 of file PrintAllowedConfiguration.cc.

109 {
110 
113 
114  if (!suppressFormat(p)) {
115 
116  if (p.is_conditional()) {
117  buffer_ << '\n';
118  indent_.modify_top("┌" + string_repeat(30, "─"));
119  buffer_ << non_whitespace(indent_(), indent_.size()) << '\n';
120  indent_.modify_top("│ ");
121  }
122 
123  if (!p.comment().empty()) {
124  if (!p.is_conditional())
125  buffer_ << non_whitespace(indent_(), indent_.size()) << '\n';
126  for (auto const& line : cet::split_by_regex(p.comment(), reNewLine))
127  buffer_ << indent_() << "## " << line << '\n';
128  }
129  }
130 
131  if (!is_sequence_element(p.key())) {
132  buffer_ << non_whitespace(indent_(), indent_.size()) << '\n';
133 
134  // In general, optional parameters cannot be template arguments to
135  // sequences. However, the implementation for 'TupleAs' uses
136  // OptionalTuple<...> as the holding type of the sequence
137  // elements. In the case where we have Sequence< TupleAs<> >, the
138  // TupleAs entries will be prefaced with '#', and we don't want
139  // that. Therefore, we modify the top indentation fragment only
140  // if the parameter is not a sequence element.
141 
142  if (p.is_optional()) {
143  if (p.is_conditional())
144  indent_.modify_top("│# ");
145  else
146  indent_.modify_top(" # ");
147  }
148  }
149 
152 
153  buffer_ << mps_.top().parent_names();
154 
155  return true;
156 }
bool is_sequence_element(std::string const &key)
std::vector< std::string > split_by_regex(std::string const &str, std::regex const &reDelimSet)
void modify_top(std::string const &s)
Definition: Indentation.h:36
p
Definition: test.py:223
void line(double t, double *p, double &x, double &y, double &z)
void cacheTopLevelParameter(ParameterBase const &p)
void fhicl::detail::PrintAllowedConfiguration::cacheTopLevelParameter ( ParameterBase const &  p)
inlineprivate

Definition at line 47 of file PrintAllowedConfiguration.h.

48  {
49  if (cachedTopLevelParameter_ == "")
51  }
p
Definition: test.py:223
void PrintAllowedConfiguration::delegated_parameter ( DelegateBase const &  dp)
overrideprivate

Definition at line 252 of file PrintAllowedConfiguration.cc.

253 {
254  buffer_ << maybeName{dp, indent_()} << "<< delegated >>";
255 }
void PrintAllowedConfiguration::enter_sequence ( SequenceBase const &  s)
overrideprivate

Definition at line 200 of file PrintAllowedConfiguration.cc.

201 {
202  buffer_ << maybeName{s, indent_()} << "[\n";
203 
204  indent_.push();
205 
206  if (s.empty())
207  return;
208 
209  // We want the printout to look like this for sequences with
210  // defaults:
211  //
212  // list1: [
213  // 1, # default
214  // 2 # default
215  // ]
216  //
217  // And like this for vectors w/o defaults (has length 1):
218  //
219  // list2: [
220  // <int>,
221  // ...
222  // ]
223 
224  if (s.has_default() || (s.parameter_type() != par_type::SEQ_VECTOR)) {
225  for (std::size_t i{}; i != s.size() - 1; ++i)
226  keysWithCommas_.emplace(s.key() + "[" + std::to_string(i) + "]");
227  return;
228  }
229 
230  keysWithCommas_.emplace(s.key() + "[0]");
231  keysWithEllipses_.emplace(s.key() + "[0]");
232 }
uint size() const
Definition: qcstring.h:201
std::unordered_set< std::string > keysWithCommas_
std::unordered_set< std::string > keysWithEllipses_
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
static QCString * s
Definition: config.cpp:1042
void PrintAllowedConfiguration::enter_table ( TableBase const &  t)
overrideprivate
void PrintAllowedConfiguration::exit_sequence ( SequenceBase const &  )
overrideprivate
void PrintAllowedConfiguration::exit_table ( TableBase const &  )
overrideprivate
void fhicl::detail::PrintAllowedConfiguration::maybeReleaseTopLevelParameter ( ParameterBase const &  p)
inlineprivate

Definition at line 54 of file PrintAllowedConfiguration.h.

55  {
56  if (p.key() == cachedTopLevelParameter_)
58  }
p
Definition: test.py:223
bool fhicl::detail::PrintAllowedConfiguration::suppressFormat ( ParameterBase const &  p)
inlineprivate

Definition at line 61 of file PrintAllowedConfiguration.h.

62  {
63  return p.key() == cachedTopLevelParameter_;
64  }
p
Definition: test.py:223

Member Data Documentation

std::ostream& fhicl::detail::PrintAllowedConfiguration::buffer_
private

Definition at line 24 of file PrintAllowedConfiguration.h.

std::string fhicl::detail::PrintAllowedConfiguration::cachedTopLevelParameter_ {}
private

Definition at line 27 of file PrintAllowedConfiguration.h.

Indentation fhicl::detail::PrintAllowedConfiguration::indent_
private

Definition at line 25 of file PrintAllowedConfiguration.h.

std::unordered_set<std::string> fhicl::detail::PrintAllowedConfiguration::keysWithCommas_ {}
private

Definition at line 29 of file PrintAllowedConfiguration.h.

std::unordered_set<std::string> fhicl::detail::PrintAllowedConfiguration::keysWithEllipses_ {}
private

Definition at line 30 of file PrintAllowedConfiguration.h.

std::stack<MaybeDisplayParent> fhicl::detail::PrintAllowedConfiguration::mps_ {}
private

Definition at line 28 of file PrintAllowedConfiguration.h.

bool fhicl::detail::PrintAllowedConfiguration::showParentsForFirstParam_
private

Definition at line 31 of file PrintAllowedConfiguration.h.

bool fhicl::detail::PrintAllowedConfiguration::suppressTopLevelFormatting_
private

Definition at line 26 of file PrintAllowedConfiguration.h.


The documentation for this class was generated from the following files: