fix8  version 1.4.0
Open Source C++ FIX Framework
FIX8::RealmBase Struct Reference

Domain range/set static metadata base class. More...

#include <field.hpp>

Public Types

enum  RealmType { dt_range, dt_set }
 

Public Member Functions

 RealmBase (const void *range, RealmType dtype, FieldTrait::FieldType ftype, int sz, const char *const *descriptions)
 
template<typename T >
bool is_valid (const T &what) const
 
template<typename T >
const T & get_rlm_val (const int idx) const
 
template<typename T >
int get_rlm_idx (const T &what) const
 
template<typename T >
std::ostream & _print (std::ostream &os, int idx) const
 
std::ostream & print (std::ostream &os, int idx) const
 

Public Attributes

const void * _range
 
RealmType _dtype
 
FieldTrait::FieldType _ftype
 
const int _sz
 
const char *const * _descriptions
 

Detailed Description

Domain range/set static metadata base class.

Definition at line 58 of file field.hpp.

Member Enumeration Documentation

Enumerator
dt_range 
dt_set 

Definition at line 60 of file field.hpp.

Constructor & Destructor Documentation

FIX8::RealmBase::RealmBase ( const void *  range,
RealmType  dtype,
FieldTrait::FieldType  ftype,
int  sz,
const char *const *  descriptions 
)
inline

Definition at line 68 of file field.hpp.

69  : _range(range), _dtype(dtype), _ftype(ftype), _sz(sz), _descriptions(descriptions) {}
const void * _range
Definition: field.hpp:62
FieldTrait::FieldType _ftype
Definition: field.hpp:64
const int _sz
Definition: field.hpp:65
RealmType _dtype
Definition: field.hpp:63
const char *const * _descriptions
Definition: field.hpp:66

Member Function Documentation

template<typename T >
std::ostream& FIX8::RealmBase::_print ( std::ostream &  os,
int  idx 
) const
inline

Printer helper

Template Parameters
Ttarget type
Parameters
osoutput stream
idxindex of value in range
Returns
the output stream

Definition at line 110 of file field.hpp.

References _range.

110 { return os << *((static_cast<const T *>(_range) + idx)); }
const void * _range
Definition: field.hpp:62
template<typename T >
int FIX8::RealmBase::get_rlm_idx ( const T &  what) const
inline

Get the realm index of this value in the domain set.

Template Parameters
Tdomain type
Parameters
whatthe value to check
Returns
the index in the domain set of this value

Definition at line 94 of file field.hpp.

References dt_set.

Referenced by FIX8::Field< int, field >::get_rlm_idx(), FIX8::Field< f8String, field >::get_rlm_idx(), FIX8::Field< fp_type, field >::get_rlm_idx(), FIX8::Field< char, field >::get_rlm_idx(), and FIX8::Field< Boolean, field >::get_rlm_idx().

95  {
96  if (_dtype == dt_set)
97  {
98  const T *rng(static_cast<const T*>(_range)), *res(std::lower_bound(rng, rng + _sz, what));
99  return res != rng + _sz ? res - rng : -1;
100  }
101  return 0;
102  }
const void * _range
Definition: field.hpp:62
const int _sz
Definition: field.hpp:65
RealmType _dtype
Definition: field.hpp:63
template<typename T >
const T& FIX8::RealmBase::get_rlm_val ( const int  idx) const
inline

Get the realm value with the specified index

Template Parameters
Tdomain type
Parameters
idxof value
Returns
reference to the associated value

Definition at line 87 of file field.hpp.

References _range.

Referenced by FIX8::Inst::_gen::_make().

87 { return *(static_cast<const T*>(_range) + idx); }
const void * _range
Definition: field.hpp:62
template<typename T >
bool FIX8::RealmBase::is_valid ( const T &  what) const
inline

Check if this value is a member/in range of the domain set.

Template Parameters
Tdomain type
Parameters
whatthe value to check
Returns
true if in the set or no domain available

Definition at line 76 of file field.hpp.

References dt_set.

Referenced by FIX8::Field< int, field >::is_valid(), FIX8::Field< f8String, field >::is_valid(), FIX8::Field< fp_type, field >::is_valid(), and FIX8::Field< char, field >::is_valid().

77  {
78  const T *rng(static_cast<const T*>(_range));
79  return _dtype == dt_set ? std::binary_search(rng, rng + _sz, what) : *rng <= what && what <= *(rng + 1);
80  }
const void * _range
Definition: field.hpp:62
const int _sz
Definition: field.hpp:65
RealmType _dtype
Definition: field.hpp:63
std::ostream& FIX8::RealmBase::print ( std::ostream &  os,
int  idx 
) const
inline

Print the given value by index to the supplied stream

Parameters
osoutput stream
idxindex of value in range
Returns
the output stream

Definition at line 116 of file field.hpp.

References FIX8::FieldTrait::is_char(), FIX8::FieldTrait::is_float(), FIX8::FieldTrait::is_int(), and FIX8::FieldTrait::is_string().

Referenced by FIX8::ConsoleMenu::SelectRealm().

117  {
118  return FieldTrait::is_int(_ftype) ? _print<int>(os, idx)
119  : FieldTrait::is_char(_ftype) ? _print<char>(os, idx)
120  : FieldTrait::is_float(_ftype) ? _print<fp_type>(os, idx)
121  : FieldTrait::is_string(_ftype) ? _print<f8String>(os, idx) : os;
122  }
static bool is_char(FieldType ftype)
Definition: traits.hpp:88
FieldTrait::FieldType _ftype
Definition: field.hpp:64
static bool is_float(FieldType ftype)
Definition: traits.hpp:93
static bool is_int(FieldType ftype)
Definition: traits.hpp:83
static bool is_string(FieldType ftype)
Definition: traits.hpp:98

Member Data Documentation

const char* const* FIX8::RealmBase::_descriptions

Definition at line 66 of file field.hpp.

Referenced by FIX8::ConsoleMenu::SelectRealm().

RealmType FIX8::RealmBase::_dtype

Definition at line 63 of file field.hpp.

Referenced by FIX8::Inst::_gen::_make().

FieldTrait::FieldType FIX8::RealmBase::_ftype

Definition at line 64 of file field.hpp.

const void* FIX8::RealmBase::_range

Definition at line 62 of file field.hpp.

Referenced by _print(), and get_rlm_val().

const int FIX8::RealmBase::_sz

Definition at line 65 of file field.hpp.

Referenced by FIX8::Inst::_gen::_make(), and FIX8::ConsoleMenu::SelectRealm().


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