LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
fhicl::extended_value Class Reference

#include "extended_value.h"

Public Types

using atom_t = std::string
 
using complex_t = std::pair< std::string, std::string >
 
using sequence_t = std::vector< extended_value >
 
using table_t = shims::map< std::string, extended_value >
 

Public Member Functions

 extended_value ()=default
 
 extended_value (bool const in_prolog, value_tag const tag, boost::any const value, Protection const protection, std::string const &src={})
 
 extended_value (bool const in_prolog, value_tag const tag, boost::any const value, std::string const &src={})
 
bool is_a (value_tag t) const
 
std::string to_string () const
 
void set_prolog (bool new_prolog_state)
 
void set_src_info (std::string const &src)
 
std::string pretty_src_info () const
 
 operator atom_t () const
 
 operator complex_t () const
 
 operator sequence_t () const
 
 operator table_t () const
 

Public Attributes

bool in_prolog {false}
 
value_tag tag {UNKNOWN}
 
boost::any value {}
 
std::string src_info {}
 
Protection protection {Protection::NONE}
 

Detailed Description

Definition at line 37 of file extended_value.h.

Member Typedef Documentation

using fhicl::extended_value::atom_t = std::string

Definition at line 39 of file extended_value.h.

using fhicl::extended_value::complex_t = std::pair<std::string, std::string>

Definition at line 40 of file extended_value.h.

Definition at line 41 of file extended_value.h.

Definition at line 42 of file extended_value.h.

Constructor & Destructor Documentation

fhicl::extended_value::extended_value ( )
default
fhicl::extended_value::extended_value ( bool const  in_prolog,
value_tag const  tag,
boost::any const  value,
Protection const  protection,
std::string const &  src = {} 
)
inline

Definition at line 46 of file extended_value.h.

References src_info.

50  {})
52  , tag{tag}
53  , value{value}
54  , src_info{src}
56  {}
fhicl::extended_value::extended_value ( bool const  in_prolog,
value_tag const  tag,
boost::any const  value,
std::string const &  src = {} 
)
inline

Definition at line 58 of file extended_value.h.

References src_info.

61  {})
63  {}

Member Function Documentation

bool fhicl::extended_value::is_a ( value_tag  t) const
inline
fhicl::extended_value::operator atom_t ( ) const
inline

Definition at line 83 of file extended_value.h.

References value.

83 { return boost::any_cast<atom_t>(value); }
intermediate_table::atom_t atom_t
fhicl::extended_value::operator complex_t ( ) const
inline

Definition at line 85 of file extended_value.h.

References value.

85 { return boost::any_cast<complex_t>(value); }
intermediate_table::complex_t complex_t
fhicl::extended_value::operator sequence_t ( ) const
inline

Definition at line 87 of file extended_value.h.

References value.

87 { return boost::any_cast<sequence_t>(value); }
fhicl::extended_value::sequence_t sequence_t
fhicl::extended_value::operator table_t ( ) const
inline

Definition at line 89 of file extended_value.h.

References value.

89 { return boost::any_cast<table_t>(value); }
std::string fhicl::extended_value::pretty_src_info ( ) const

Definition at line 119 of file extended_value.cc.

References src_info.

Referenced by fhicl::intermediate_table::locate_(), and set_src_info().

120 {
121  std::string result;
122  static std::regex const splitRE("(.*):([0-9-]*)");
123  std::smatch m;
124  if (std::regex_match(src_info, m, splitRE)) {
125  result =
126  std::string("line ") + m[2].str() + " of file \"" + m[1].str() + '"';
127  } else {
128  result = "<unknown>";
129  }
130  return result;
131 }
void fhicl::extended_value::set_prolog ( bool  new_prolog_state)

Definition at line 78 of file extended_value.cc.

References shims::map< Key, T, Compare, Allocator >::begin(), fhicl::BOOL, fhicl::COMPLEX, e, shims::map< Key, T, Compare, Allocator >::end(), in_prolog, fhicl::NIL, fhicl::NUMBER, fhicl::SEQUENCE, fhicl::STRING, fhicl::TABLE, fhicl::TABLEID, tag, fhicl::UNKNOWN, and value.

Referenced by is_a(), and fhicl::intermediate_table::locate_().

79 {
80  in_prolog = new_prolog_state;
81 
82  switch (tag) {
83 
84  case NIL:
85  case BOOL:
86  case NUMBER:
87  case STRING:
88  case COMPLEX:
89  case TABLEID: {
90  break;
91  }
92 
93  case SEQUENCE: {
94  sequence_t& q = any_cast<sequence_t&>(value);
95  for (sequence_t::iterator it = q.begin(), e = q.end(); it != e; ++it) {
96  it->set_prolog(new_prolog_state);
97  }
98  break;
99  }
100 
101  case TABLE: {
102  table_t& t = any_cast<table_t&>(value);
103  for (table_t::iterator it = t.begin(), e = t.end(); it != e; ++it) {
104  it->second.set_prolog(new_prolog_state);
105  }
106  break;
107  }
108 
109  case UNKNOWN:
110  default: {
111  break;
112  }
113 
114  }; // switch
115 
116 } // set_prolog()
iterator begin()
Definition: stdmap_shims.h:155
intermediate_table::iterator iterator
iterator end()
Definition: stdmap_shims.h:177
fhicl::extended_value::sequence_t sequence_t
Float_t e
Definition: plot.C:34
void fhicl::extended_value::set_src_info ( std::string const &  src)
inline

Definition at line 76 of file extended_value.h.

References pretty_src_info(), and src_info.

77  {
78  src_info = src;
79  }
std::string fhicl::extended_value::to_string ( ) const

Definition at line 17 of file extended_value.cc.

References fhicl::BOOL, shims::map< Key, T, Compare, Allocator >::cbegin(), shims::map< Key, T, Compare, Allocator >::cend(), fhicl::COMPLEX, e, in_prolog, shims::isSnippetMode(), fhicl::NIL, fhicl::NUMBER, s, fhicl::SEQUENCE, fhicl::STRING, fhicl::TABLE, fhicl::TABLEID, tag, fhicl::UNKNOWN, and value.

Referenced by is_a().

18 {
20  return "";
21 
22  switch (tag) {
23 
24  case NIL:
25  case BOOL:
26  case NUMBER:
27  case STRING: {
28  return any_cast<atom_t>(value);
29  }
30 
31  case COMPLEX: {
32  complex_t c = any_cast<complex_t>(value);
33  return '(' + c.first + ',' + c.second + ')';
34  }
35 
36  case SEQUENCE: {
37  sequence_t q = any_cast<sequence_t>(value);
38  string s("[");
39  string sep;
40  for (sequence_t::const_iterator b = q.begin(), e = q.end(), it = b;
41  it != e;
42  ++it) {
43  s.append(sep).append(it->to_string());
44  sep = ",";
45  }
46  return s + ']';
47  }
48 
49  case TABLE: {
50  table_t t = any_cast<table_t>(value);
51  string s("{");
52  string sep;
53  for (table_t::const_iterator b = t.cbegin(), e = t.cend(), it = b;
54  it != e;
55  ++it) {
56  s.append(sep).append(it->first + ':' + it->second.to_string());
57  sep = " ";
58  }
59  return s + '}';
60  }
61 
62  case TABLEID: {
63  return string("@id::") + any_cast<atom_t>(value);
64  }
65 
66  case UNKNOWN:
67  default: {
68  return "";
69  }
70 
71  }; // switch
72 
73 } // to_string()
Float_t s
Definition: plot.C:23
intermediate_table::complex_t complex_t
bool isSnippetMode(bool m)
Definition: parse_shims.cc:9
intermediate_table::const_iterator const_iterator
const_iterator cbegin() const
Definition: stdmap_shims.h:171
fhicl::extended_value::sequence_t sequence_t
intermediate_table::atom_t atom_t
const_iterator cend() const
Definition: stdmap_shims.h:193
Float_t e
Definition: plot.C:34

Member Data Documentation

bool fhicl::extended_value::in_prolog {false}
Protection fhicl::extended_value::protection {Protection::NONE}
std::string fhicl::extended_value::src_info {}

Definition at line 94 of file extended_value.h.

Referenced by extended_value(), pretty_src_info(), and set_src_info().

value_tag fhicl::extended_value::tag {UNKNOWN}

Definition at line 92 of file extended_value.h.

Referenced by fhicl::detail::encode(), is_a(), set_prolog(), and to_string().


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