15 #ifndef _DATAT_BITS_INCLUDE_TAG
16 #error Must only be included from sag_connectivity_cpp.hpp, use that instead
43 template<
typename DERIVED,
typename RV>
53 result_type
operator()()
const {
return derived().visitEmpty(); }
55 result_type
visitEmpty()
const {
return derived().error(
"empty"); }
58 result_type
operator()(int64_t &i)
const {
return derived().visitInteger(i); }
60 result_type
visitInteger(int64_t &i)
const {
return derived().error(
"integer"); }
63 result_type
operator()(
double &i)
const {
return derived().visitDouble(i); }
65 result_type
visitDouble(
double &i)
const {
return derived().error(
"double"); }
68 result_type
operator()(
bool &i)
const {
return derived().visitBoolean(i); }
70 result_type
visitBoolean(
bool &i)
const {
return derived().error(
"boolean"); }
73 result_type
operator()(
const char *&i)
const {
return derived().visitString(i); }
75 result_type
visitString(
const char *&i)
const {
return derived().error(
"string"); }
98 result_type
operator()(sag_underlying_custom_t &i)
const {
return derived().visitCustom(i); }
100 result_type
visitCustom(sag_underlying_custom_t &i)
const {
return derived().error(
"custom"); }
105 result_type
error(
const std::string &reason)
const {
throw std::runtime_error(
"Visit type error: "+reason); }
108 const derived_t &derived()
const {
return static_cast<const derived_t&
>(*this); }
135 template<
typename DERIVED,
typename RV>
145 result_type
operator()()
const {
return derived().visitEmpty(); }
147 result_type
visitEmpty()
const {
return derived().error(
"empty"); }
150 result_type
operator()(int64_t i)
const {
return derived().visitInteger(i); }
152 result_type
visitInteger(int64_t i)
const {
return derived().error(
"integer"); }
155 result_type
operator()(
double i)
const {
return derived().visitDouble(i); }
157 result_type
visitDouble(
double i)
const {
return derived().error(
"double"); }
160 result_type
operator()(
bool i)
const {
return derived().visitBoolean(i); }
162 result_type
visitBoolean(
bool i)
const {
return derived().error(
"boolean"); }
165 result_type
operator()(
const char *i)
const {
return derived().visitString(i); }
167 result_type
visitString(
const char *i)
const {
return derived().error(
"string"); }
187 result_type
visitMap(
const map_t &i)
const {
return derived().error(
"map"); }
190 result_type
operator()(
const sag_underlying_custom_t &i)
const {
return derived().visitCustom(i); }
192 result_type
visitCustom(
const sag_underlying_custom_t &i)
const {
return derived().error(
"custom"); }
197 result_type
error(
const std::string &reason)
const {
throw std::runtime_error(
"Visit type error: "+reason); }
200 const derived_t &derived()
const {
return static_cast<const derived_t&
>(*this); }
result_type visitInteger(int64_t &i) const
Visit an integer.
Definition: visitors.hpp:60
result_type visitBoolean(bool i) const
Visit a boolean.
Definition: visitors.hpp:162
result_type operator()() const
Visit an empty variant (don't override this, instead override visitEmpty)
Definition: visitors.hpp:53
result_type operator()(const list_t &i) const
Visit a list (don't override this, instead override visitList)
Definition: visitors.hpp:180
A list class which implements many of the functions on std::vector.
Definition: list_t.hpp:34
A map class which implements many of the functions on std::map.
Definition: map_t.hpp:36
result_type visitCustom(sag_underlying_custom_t &i) const
Visit a custom object.
Definition: visitors.hpp:100
DERIVED derived_t
The type of the derived class.
Definition: visitors.hpp:142
result_type visitMap(const map_t &i) const
Visit a map.
Definition: visitors.hpp:187
result_type operator()(bool &i) const
Visit a boolean (don't override this, instead override visitBoolean)
Definition: visitors.hpp:68
result_type visitBuffer(const buffer_t &i) const
Visit a byte buffer.
Definition: visitors.hpp:177
result_type operator()(list_t &i) const
Visit a list (don't override this, instead override visitList)
Definition: visitors.hpp:88
sag_underlying_decimal_t decimal_t
Decimals are implemented with an underlying 64bit int conforming to IEEE 754 decimal 64...
Definition: sag_connectivity_cpp.hpp:49
Helper class for writing visitors to apply to data_t.
Definition: visitors.hpp:44
result_type error(const std::string &reason) const
Handles visiting unhandled types.
Definition: visitors.hpp:105
result_type visitDouble(double &i) const
Visit a double.
Definition: visitors.hpp:65
result_type visitCustom(const sag_underlying_custom_t &i) const
Visit a custom object.
Definition: visitors.hpp:192
result_type visitInteger(int64_t i) const
Visit an integer.
Definition: visitors.hpp:152
result_type operator()(const buffer_t &i) const
Visit a byte buffer (don't override this, instead override visitBuffer)
Definition: visitors.hpp:175
result_type visitDecimal(const decimal_t &i) const
Visit a decimal.
Definition: visitors.hpp:172
result_type visitEmpty() const
Visit an empty variant.
Definition: visitors.hpp:147
result_type operator()(buffer_t &i) const
Visit a byte buffer (don't override this, instead override visitBuffer)
Definition: visitors.hpp:83
result_type visitDouble(double i) const
Visit a double.
Definition: visitors.hpp:157
result_type visitEmpty() const
Visit an empty variant.
Definition: visitors.hpp:55
result_type operator()(const char *i) const
Visit a string (don't override this, instead override visitString)
Definition: visitors.hpp:165
result_type operator()(const char *&i) const
Visit a string (don't override this, instead override visitString)
Definition: visitors.hpp:73
result_type visitString(const char *&i) const
Visit a string.
Definition: visitors.hpp:75
A class that holds an untyped byte buffer.
Definition: buffer_t.hpp:27
result_type operator()(double &i) const
Visit a double (don't override this, instead override visitDouble)
Definition: visitors.hpp:63
result_type operator()(bool i) const
Visit a boolean (don't override this, instead override visitBoolean)
Definition: visitors.hpp:160
result_type operator()(int64_t &i) const
Visit an integer (don't override this, instead override visitInteger)
Definition: visitors.hpp:58
result_type visitMap(map_t &i) const
Visit a map.
Definition: visitors.hpp:95
DERIVED derived_t
The type of the derived class.
Definition: visitors.hpp:50
result_type operator()(double i) const
Visit a double (don't override this, instead override visitDouble)
Definition: visitors.hpp:155
result_type operator()(const map_t &i) const
Visit a map (don't override this, instead override visitMap)
Definition: visitors.hpp:185
result_type visitBoolean(bool &i) const
Visit a boolean.
Definition: visitors.hpp:70
result_type operator()(map_t &i) const
Visit a map (don't override this, instead override visitMap)
Definition: visitors.hpp:93
RV result_type
The return type from applying this visitor.
Definition: visitors.hpp:140
result_type operator()(decimal_t &i) const
Visit a decimal (don't override this, instead override visitDecimal)
Definition: visitors.hpp:78
result_type visitList(const list_t &i) const
Visit a list.
Definition: visitors.hpp:182
result_type operator()(sag_underlying_custom_t &i) const
Visit a custom object (don't override this, instead override visitCustom)
Definition: visitors.hpp:98
result_type error(const std::string &reason) const
Handles visiting unhandled types.
Definition: visitors.hpp:197
result_type operator()(const sag_underlying_custom_t &i) const
Visit a custom object (don't override this, instead override visitCustom)
Definition: visitors.hpp:190
result_type operator()() const
Visit an empty variant (don't override this, instead override visitEmpty)
Definition: visitors.hpp:145
result_type visitString(const char *i) const
Visit a string.
Definition: visitors.hpp:167
Helper class for writing visitors to apply to data_t.
Definition: visitors.hpp:136
RV result_type
The return type from applying this visitor.
Definition: visitors.hpp:48
result_type operator()(const decimal_t &i) const
Visit a decimal (don't override this, instead override visitDecimal)
Definition: visitors.hpp:170
result_type operator()(int64_t i) const
Visit an integer (don't override this, instead override visitInteger)
Definition: visitors.hpp:150
result_type visitList(list_t &i) const
Visit a list.
Definition: visitors.hpp:90
result_type visitBuffer(buffer_t &i) const
Visit a byte buffer.
Definition: visitors.hpp:85
result_type visitDecimal(decimal_t &i) const
Visit a decimal.
Definition: visitors.hpp:80