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

#include "/cvmfs/nova.opensciencegrid.org/externals/fhiclcpp/v4_06_10/source/fhiclcpp/types/detail/MaybeDisplayParent.h"

Public Member Functions

 MaybeDisplayParent (ParameterBase const &p, bool const showParents, Indentation &ind)
 
std::string const & parent_names () const
 
std::string closing_braces () const
 

Private Member Functions

std::vector< std::stringget_parents (std::string const &k)
 
bool is_sequence_element (ParameterBase const &p)
 

Private Attributes

bool show_
 
std::string fullPayload_ {}
 
std::vector< std::stringnames_
 
std::vector< std::stringclosingBraces_ {}
 
Indentationindent_
 

Detailed Description

Definition at line 19 of file MaybeDisplayParent.h.

Constructor & Destructor Documentation

fhicl::detail::MaybeDisplayParent::MaybeDisplayParent ( ParameterBase const &  p,
bool const  showParents,
Indentation ind 
)
inline

Definition at line 21 of file MaybeDisplayParent.h.

References closingBraces_, e, fullPayload_, get_parents(), art::detail::indent(), indent_, it, names_, next(), fhicl::detail::Indentation::push(), show_, gen_flatrecord::size, and string.

24  : show_{showParents}
25  , names_{showParents ? get_parents(p.key()) :
26  std::vector<std::string>{}}
27  , indent_{ind}
28  {
29  std::ostringstream os;
30 
31  if (show_) {
32 
33  for (auto it = names_.begin(), e = names_.end() - 1; it != e; ++it) {
34  std::string const& name = *it;
35  std::string const& next_name = *std::next(it);
36 
37  // We use the indent_ member so that we can properly
38  // update the indentation level. However, the literal
39  // indented string should not include any characters in it
40  // for the parents of the parameter in question.
41  std::string const indent(indent_().size(), ' ');
42  if (!std::isdigit(name[0])) {
43  if (std::isdigit(next_name[0])) {
44  os << indent << name << ": [ # index: " << next_name << '\n';
45  closingBraces_.push_back(indent + "]\n");
46  } else {
47  os << indent << name << ": {\n";
48  closingBraces_.push_back(indent + "}\n");
49  }
50  } else {
51  if (!std::isdigit(next_name[0])) {
52  os << indent << "{\n";
53  closingBraces_.push_back(indent + "}\n");
54  } else {
55  os << indent << "[ # index: " << next_name << '\n';
56  closingBraces_.push_back(indent + "]\n");
57  }
58  }
59  indent_.push();
60  }
61  } else {
62  }
63 
64  fullPayload_ = os.str();
65  }
const XML_Char * name
Definition: expat.h:151
set< int >::iterator it
const char * p
Definition: xmltok.h:285
std::vector< std::string > closingBraces_
std::string indent(std::size_t const i)
std::vector< std::string > names_
std::vector< std::string > get_parents(std::string const &k)
Float_t e
Definition: plot.C:35
void next()
Definition: show_event.C:84
enum BeamMode string

Member Function Documentation

std::string fhicl::detail::MaybeDisplayParent::closing_braces ( ) const
inline

Definition at line 74 of file MaybeDisplayParent.h.

References closingBraces_, indent_, it, fhicl::detail::Indentation::pop(), fillBadChanDBTables::result, show_, and string.

75  {
76  if (!show_)
77  return "";
78 
80  for (auto it = closingBraces_.crbegin(), re = closingBraces_.crend();
81  it != re;
82  ++it) {
83  result.append(*it);
84  indent_.pop();
85  }
86  return result;
87  }
set< int >::iterator it
std::vector< std::string > closingBraces_
enum BeamMode string
std::vector<std::string> fhicl::detail::MaybeDisplayParent::get_parents ( std::string const &  k)
private

Referenced by MaybeDisplayParent().

bool fhicl::detail::MaybeDisplayParent::is_sequence_element ( ParameterBase const &  p)
inlineprivate

Definition at line 99 of file MaybeDisplayParent.h.

References fhicl::detail::ParameterBase::key(), and elec2geo::pos.

100  {
101  auto pos = p.key().find_last_of("]");
102  return pos != std::string::npos && pos == p.key().size() - 1;
103  }
const char * p
Definition: xmltok.h:285
std::string const& fhicl::detail::MaybeDisplayParent::parent_names ( ) const
inline

Definition at line 68 of file MaybeDisplayParent.h.

References fullPayload_, and string.

69  {
70  return fullPayload_;
71  }

Member Data Documentation

std::vector<std::string> fhicl::detail::MaybeDisplayParent::closingBraces_ {}
private

Definition at line 93 of file MaybeDisplayParent.h.

Referenced by closing_braces(), and MaybeDisplayParent().

std::string fhicl::detail::MaybeDisplayParent::fullPayload_ {}
private

Definition at line 91 of file MaybeDisplayParent.h.

Referenced by MaybeDisplayParent(), and parent_names().

Indentation& fhicl::detail::MaybeDisplayParent::indent_
private

Definition at line 94 of file MaybeDisplayParent.h.

Referenced by closing_braces(), and MaybeDisplayParent().

std::vector<std::string> fhicl::detail::MaybeDisplayParent::names_
private

Definition at line 92 of file MaybeDisplayParent.h.

Referenced by MaybeDisplayParent().

bool fhicl::detail::MaybeDisplayParent::show_
private

Definition at line 90 of file MaybeDisplayParent.h.

Referenced by closing_braces(), and MaybeDisplayParent().


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