LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
fhicl::OptionalTupleAs< T(ARGS...)> Class Template Reference

#include "OptionalTupleAs.h"

Public Member Functions

 OptionalTupleAs (Name &&name)
 
 OptionalTupleAs (Name &&name, Comment &&comment)
 
 OptionalTupleAs (Name &&name, Comment &&comment, std::function< bool()> maybeUse)
 
std::optional< T > operator() () const
 
bool operator() (T &result) const
 
bool hasValue () const
 

Private Member Functions

Comment conversion_comment (Comment &&comment) const
 

Private Attributes

OptionalTuple< ARGS... > tupleObj_
 

Detailed Description

template<typename T, typename... ARGS>
class fhicl::OptionalTupleAs< T(ARGS...)>

Definition at line 25 of file OptionalTupleAs.h.

Constructor & Destructor Documentation

template<typename T , typename... ARGS>
fhicl::OptionalTupleAs< T(ARGS...)>::OptionalTupleAs ( Name &&  name)
explicit

Definition at line 83 of file OptionalTupleAs.h.

84  : OptionalTupleAs{std::move(name), Comment("")}
85  {}
template<typename T , typename... ARGS>
fhicl::OptionalTupleAs< T(ARGS...)>::OptionalTupleAs ( Name &&  name,
Comment &&  comment 
)
explicit

Definition at line 88 of file OptionalTupleAs.h.

89  : tupleObj_{std::move(name), conversion_comment(std::move(comment))}
90  {}
Comment conversion_comment(Comment &&comment) const
OptionalTuple< ARGS... > tupleObj_
template<typename T , typename... ARGS>
fhicl::OptionalTupleAs< T(ARGS...)>::OptionalTupleAs ( Name &&  name,
Comment &&  comment,
std::function< bool()>  maybeUse 
)
explicit

Definition at line 93 of file OptionalTupleAs.h.

96  : tupleObj_{std::move(name),
97  conversion_comment(std::move(comment)),
98  maybeUse}
99  {}
Comment conversion_comment(Comment &&comment) const
OptionalTuple< ARGS... > tupleObj_

Member Function Documentation

template<typename T , typename... ARGS>
Comment fhicl::OptionalTupleAs< T(ARGS...)>::conversion_comment ( Comment &&  comment) const
inlineprivate

Definition at line 63 of file OptionalTupleAs.h.

References fhicl::Comment::value.

64  {
65  std::string const preface =
66  "N.B. The following sequence is converted to type:";
67  std::string const name =
68  " '" + cet::demangle_symbol(typeid(T).name()) + "'";
69  std::string const user_comment =
70  comment.value.empty() ? "" : "\n\n" + comment.value;
71 
72  std::ostringstream oss;
73  oss << preface << '\n' << name << user_comment;
74 
75  return Comment{oss.str().c_str()};
76  }
template<typename T , typename... ARGS>
bool fhicl::OptionalTupleAs< T(ARGS...)>::hasValue ( ) const
inline

Definition at line 54 of file OptionalTupleAs.h.

55  {
56  return tupleObj_.hasValue();
57  }
bool hasValue() const
Definition: OptionalTuple.h:54
OptionalTuple< ARGS... > tupleObj_
template<typename T , typename... ARGS>
std::optional<T> fhicl::OptionalTupleAs< T(ARGS...)>::operator() ( ) const
inline

Definition at line 34 of file OptionalTupleAs.h.

35  {
36  if (auto via = tupleObj_()) {
37  return make_optional(std::make_from_tuple(*via));
38  }
39  return std::nullopt;
40  }
OptionalTuple< ARGS... > tupleObj_
template<typename T , typename... ARGS>
bool fhicl::OptionalTupleAs< T(ARGS...)>::operator() ( T &  result) const
inline

Definition at line 44 of file OptionalTupleAs.h.

45  {
46  auto t = operator()();
47  if (t) {
48  result = *t;
49  }
50  return t.has_value();
51  }
std::optional< T > operator()() const

Member Data Documentation

template<typename T , typename... ARGS>
OptionalTuple<ARGS...> fhicl::OptionalTupleAs< T(ARGS...)>::tupleObj_
private

Definition at line 60 of file OptionalTupleAs.h.


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