Public Types | Public Member Functions | Public Attributes | List of all members
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, std::any const value, Protection const protection, std::string src={})
 
 extended_value (bool const in_prolog, value_tag const tag, std::any const value, std::string src={})
 
bool is_a (value_tag const t) const noexcept
 
std::string to_string () const
 
void set_prolog (bool new_prolog_state)
 
void set_src_info (std::string const &src)
 
void reset_protection ()
 
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}
 
std::any value {}
 
std::string src_info {}
 
Protection protection {Protection::NONE}
 

Detailed Description

Definition at line 37 of file extended_value.h.

Member Typedef Documentation

Definition at line 39 of file extended_value.h.

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,
std::any const  value,
Protection const  protection,
std::string  src = {} 
)
inline

Definition at line 46 of file extended_value.h.

50  {})
52  , tag{tag}
53  , value{value}
54  , src_info{move(src)}
56  {}
def move(depos, offset)
Definition: depos.py:107
fhicl::extended_value::extended_value ( bool const  in_prolog,
value_tag const  tag,
std::any const  value,
std::string  src = {} 
)
inline

Definition at line 58 of file extended_value.h.

61  {})
63  {}
def move(depos, offset)
Definition: depos.py:107

Member Function Documentation

bool fhicl::extended_value::is_a ( value_tag const  t) const
inlinenoexcept

Definition at line 66 of file extended_value.h.

67  {
68  return t == tag;
69  }
fhicl::extended_value::operator atom_t ( ) const
inline

Definition at line 90 of file extended_value.h.

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

Definition at line 91 of file extended_value.h.

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

Definition at line 92 of file extended_value.h.

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

Definition at line 93 of file extended_value.h.

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

Definition at line 117 of file extended_value.cc.

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

Definition at line 82 of file extended_value.h.

83  {
84  // See notes below.
86  }
void fhicl::extended_value::set_prolog ( bool  new_prolog_state)

Definition at line 76 of file extended_value.cc.

77 {
78  in_prolog = new_prolog_state;
79 
80  switch (tag) {
81 
82  case NIL:
83  case BOOL:
84  case NUMBER:
85  case STRING:
86  case COMPLEX:
87  case TABLEID: {
88  break;
89  }
90 
91  case SEQUENCE: {
92  auto& q = any_cast<sequence_t&>(value);
93  for (auto& e : q) {
94  e.set_prolog(new_prolog_state);
95  }
96  break;
97  }
98 
99  case TABLE: {
100  auto& t = any_cast<table_t&>(value);
101  for (auto& pr : t) {
102  pr.second.set_prolog(new_prolog_state);
103  }
104  break;
105  }
106 
107  case UNKNOWN:
108  default: {
109  break;
110  }
111 
112  }; // switch
113 
114 } // set_prolog()
const double e
fhicl::extended_value::sequence_t sequence_t
void fhicl::extended_value::set_src_info ( std::string const &  src)
inline

Definition at line 76 of file extended_value.h.

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

Definition at line 19 of file extended_value.cc.

20 {
22  return "";
23 
24  switch (tag) {
25 
26  case NIL:
27  case BOOL:
28  case NUMBER:
29  case STRING: {
30  return any_cast<atom_t>(value);
31  }
32 
33  case COMPLEX: {
34  auto c = any_cast<complex_t>(value);
35  return '(' + c.first + ',' + c.second + ')';
36  }
37 
38  case SEQUENCE: {
39  auto q = any_cast<sequence_t>(value);
40  string s("[");
41  string sep;
42  for (auto const& v : q) {
43  s.append(sep).append(v.to_string());
44  sep = ",";
45  }
46  return s + ']';
47  }
48 
49  case TABLE: {
50  auto t = any_cast<table_t>(value);
51  string s("{");
52  string sep;
53  for (auto const& pr : t) {
54  s.append(sep).append(pr.first + ':' + pr.second.to_string());
55  sep = " ";
56  }
57  return s + '}';
58  }
59 
60  case TABLEID: {
61  return string("@id::") + any_cast<atom_t>(value);
62  }
63 
64  case UNKNOWN:
65  default: {
66  return "";
67  }
68 
69  }; // switch
70 
71 } // to_string()
intermediate_table::complex_t complex_t
bool isSnippetMode(bool m)
Definition: parse_shims.cc:9
std::string string
Definition: nybbler.cc:12
fhicl::extended_value::sequence_t sequence_t
intermediate_table::atom_t atom_t
static QCString * s
Definition: config.cpp:1042
QCString & append(const char *s)
Definition: qcstring.cpp:383

Member Data Documentation

bool fhicl::extended_value::in_prolog {false}

Definition at line 95 of file extended_value.h.

Protection fhicl::extended_value::protection {Protection::NONE}

Definition at line 111 of file extended_value.h.

std::string fhicl::extended_value::src_info {}

Definition at line 98 of file extended_value.h.

value_tag fhicl::extended_value::tag {UNKNOWN}

Definition at line 96 of file extended_value.h.

std::any fhicl::extended_value::value {}

Definition at line 97 of file extended_value.h.


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