fix8  version 1.4.0
Open Source C++ FIX Framework
FIX8::Field< fp_type, field > Class Template Reference

Partial specialisation for fp_type field type. fp_type is singe or double. More...

#include <field.hpp>

Inheritance diagram for FIX8::Field< fp_type, field >:
FIX8::BaseField

Public Member Functions

FieldTrait::FieldType get_underlying_type () const
 The FieldType. More...
 
 Field ()
 Ctor. More...
 
 Field (const Field &from)
 Copy Ctor. More...
 
 Field (const fp_type &val, const RealmBase *rlm=nullptr)
 
 Field (const fp_type &val, const int prec, const RealmBase *rlm=nullptr)
 
 Field (const f8String &from, const RealmBase *rlm=nullptr)
 
 Field (const char *from, const RealmBase *rlm=nullptr)
 
virtual ~Field ()
 Dtor. More...
 
Fieldoperator= (const Field &that)
 Assignment operator. More...
 
bool operator== (const BaseField &that) const
 Equivalence operator. More...
 
bool operator< (const BaseField &that) const
 Less than operator. More...
 
bool operator> (const BaseField &that) const
 Greater than operator. More...
 
void set_precision (const int prec)
 
bool is_valid () const
 
int get_rlm_idx () const
 
const fp_typeget () const
 
const fp_typeoperator() () const
 
const fp_typeset (const fp_type &from)
 
const fp_typeset_from_raw (const f8String &from)
 
Fieldcopy ()
 
std::ostream & print (std::ostream &os) const
 
size_t print (char *to) const
 
- Public Member Functions inherited from FIX8::BaseField
 BaseField (unsigned short fnum, const RealmBase *rlm=nullptr)
 
virtual ~BaseField ()
 Dtor. More...
 
unsigned short get_tag () const
 
template<typename T >
T & from ()
 
template<typename T >
const T * as () const
 
size_t encode (std::ostream &os) const
 
size_t encode (char *to) const
 
bool same_base (const BaseField &that) const
 BaseField Equivalence test. More...
 
bool operator!= (const BaseField &that) const
 Inequivalence operator. More...
 
bool operator<= (const BaseField &that) const
 Less or equal to operator. More...
 
bool operator>= (const BaseField &that) const
 Greater or equal to operator. More...
 
const RealmBaseget_realm () const
 

Static Public Member Functions

static unsigned short get_field_id ()
 Get the FIX fieldID (tag number). More...
 

Protected Attributes

fp_type _value
 
int _precision
 
- Protected Attributes inherited from FIX8::BaseField
const RealmBase_rlm
 

Static Protected Attributes

static const FieldTrait::FieldType _ftype = FieldTrait::ft_float
 

Detailed Description

template<unsigned short field>
class FIX8::Field< fp_type, field >

Partial specialisation for fp_type field type. fp_type is singe or double.

Template Parameters
fieldfield number (fix tag)

Definition at line 596 of file field.hpp.

Constructor & Destructor Documentation

template<unsigned short field>
FIX8::Field< fp_type, field >::Field ( )
inline

Ctor.

Definition at line 611 of file field.hpp.

#define FIX8_DEFAULT_PRECISION
Definition: f8config.h:99
BaseField(unsigned short fnum, const RealmBase *rlm=nullptr)
Definition: field.hpp:138
template<unsigned short field>
FIX8::Field< fp_type, field >::Field ( const Field< fp_type, field > &  from)
inline

Copy Ctor.

Definition at line 615 of file field.hpp.

615 : BaseField(field, from._rlm), _value(from._value), _precision(from._precision) {}
BaseField(unsigned short fnum, const RealmBase *rlm=nullptr)
Definition: field.hpp:138
template<unsigned short field>
FIX8::Field< fp_type, field >::Field ( const fp_type val,
const RealmBase rlm = nullptr 
)
inline

Value ctor.

Parameters
valvalue to set
rlmpointer to the realmbase for this field (if available)

Definition at line 620 of file field.hpp.

620 : BaseField(field, rlm), _value(val), _precision(FIX8_DEFAULT_PRECISION) {}
#define FIX8_DEFAULT_PRECISION
Definition: f8config.h:99
BaseField(unsigned short fnum, const RealmBase *rlm=nullptr)
Definition: field.hpp:138
template<unsigned short field>
FIX8::Field< fp_type, field >::Field ( const fp_type val,
const int  prec,
const RealmBase rlm = nullptr 
)
inline

Value ctor.

Parameters
valvalue to set
precprecision digits
rlmpointer to the realmbase for this field (if available)

Definition at line 626 of file field.hpp.

626 : BaseField(field, rlm), _value(val), _precision(prec) {}
BaseField(unsigned short fnum, const RealmBase *rlm=nullptr)
Definition: field.hpp:138
template<unsigned short field>
FIX8::Field< fp_type, field >::Field ( const f8String from,
const RealmBase rlm = nullptr 
)
inline

Construct from string ctor.

Parameters
fromstring to construct field from
rlmpointer to the realmbase for this field (if available)

Definition at line 631 of file field.hpp.

631 : BaseField(field, rlm), _value(fast_atof(from.c_str())), _precision(FIX8_DEFAULT_PRECISION) {}
#define FIX8_DEFAULT_PRECISION
Definition: f8config.h:99
fp_type fast_atof(const char *p)
Definition: f8utils.hpp:727
BaseField(unsigned short fnum, const RealmBase *rlm=nullptr)
Definition: field.hpp:138
template<unsigned short field>
FIX8::Field< fp_type, field >::Field ( const char *  from,
const RealmBase rlm = nullptr 
)
inline

Construct from char * ctor.

Parameters
fromchar * to construct field from
rlmpointer to the realmbase for this field (if available)

Definition at line 636 of file field.hpp.

#define FIX8_DEFAULT_PRECISION
Definition: f8config.h:99
fp_type fast_atof(const char *p)
Definition: f8utils.hpp:727
BaseField(unsigned short fnum, const RealmBase *rlm=nullptr)
Definition: field.hpp:138
template<unsigned short field>
virtual FIX8::Field< fp_type, field >::~Field ( )
inlinevirtual

Dtor.

Definition at line 639 of file field.hpp.

639 {}

Member Function Documentation

template<unsigned short field>
Field* FIX8::Field< fp_type, field >::copy ( )
inlinevirtual

Copy (clone) this field.

Returns
copy of field

Implements FIX8::BaseField.

Definition at line 701 of file field.hpp.

References FIX8::Field< T, field >::Field().

701 { return new Field(*this); }
template<unsigned short field>
const fp_type& FIX8::Field< fp_type, field >::get ( ) const
inline

Get field value.

Returns
value (fp_type)

Definition at line 683 of file field.hpp.

683 { return _value; }
template<unsigned short field>
static unsigned short FIX8::Field< fp_type, field >::get_field_id ( )
inlinestatic

Get the FIX fieldID (tag number).

Definition at line 605 of file field.hpp.

605 { return field; }
template<unsigned short field>
int FIX8::Field< fp_type, field >::get_rlm_idx ( ) const
inlinevirtual

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

Returns
the index in the domain set of this value

Reimplemented from FIX8::BaseField.

Definition at line 679 of file field.hpp.

References FIX8::BaseField::_rlm, and FIX8::RealmBase::get_rlm_idx().

679 { return _rlm ? _rlm->get_rlm_idx(_value) : -1; }
const RealmBase * _rlm
Definition: field.hpp:132
int get_rlm_idx(const T &what) const
Definition: field.hpp:94
template<unsigned short field>
FieldTrait::FieldType FIX8::Field< fp_type, field >::get_underlying_type ( ) const
inlinevirtual

The FieldType.

Implements FIX8::BaseField.

Definition at line 608 of file field.hpp.

608 { return _ftype; }
static const FieldTrait::FieldType _ftype
Definition: field.hpp:601
template<unsigned short field>
bool FIX8::Field< fp_type, field >::is_valid ( ) const
inline

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

Returns
true if in the set or no domain available

Definition at line 675 of file field.hpp.

References FIX8::BaseField::_rlm, and FIX8::RealmBase::is_valid().

675 { return _rlm ? _rlm->is_valid(_value) : true; }
const RealmBase * _rlm
Definition: field.hpp:132
bool is_valid(const T &what) const
Definition: field.hpp:76
template<unsigned short field>
const fp_type& FIX8::Field< fp_type, field >::operator() ( ) const
inline

Get field value.

Returns
value (fp_type)

Definition at line 687 of file field.hpp.

687 { return _value; }
template<unsigned short field>
bool FIX8::Field< fp_type, field >::operator< ( const BaseField< fp_type, field > &  that) const
inlinevirtual

Less than operator.

Parameters
thatfield to compare
Returns
true if less than

Implements FIX8::BaseField.

Definition at line 660 of file field.hpp.

References FIX8::BaseField::same_base().

661  { return same_base(that) && _value < static_cast<const Field<fp_type, field>&>(that)._value; }
bool same_base(const BaseField &that) const
BaseField Equivalence test.
Definition: field.hpp:207
template<unsigned short field>
Field& FIX8::Field< fp_type, field >::operator= ( const Field< fp_type, field > &  that)
inline

Assignment operator.

Parameters
thatfield to assign from
Returns
field

Definition at line 644 of file field.hpp.

645  {
646  if (this != &that)
647  _value = that._value;
648  return *this;
649  }
template<unsigned short field>
bool FIX8::Field< fp_type, field >::operator== ( const BaseField< fp_type, field > &  that) const
inlinevirtual

Equivalence operator.

Parameters
thatfield to compare
Returns
true if same

Implements FIX8::BaseField.

Definition at line 654 of file field.hpp.

References FIX8::BaseField::same_base().

655  { return same_base(that) && static_cast<const Field<fp_type, field>&>(that)._value == _value; }
bool same_base(const BaseField &that) const
BaseField Equivalence test.
Definition: field.hpp:207
template<unsigned short field>
bool FIX8::Field< fp_type, field >::operator> ( const BaseField< fp_type, field > &  that) const
inlinevirtual

Greater than operator.

Parameters
thatfield to compare
Returns
true if greater than

Implements FIX8::BaseField.

Definition at line 666 of file field.hpp.

References FIX8::BaseField::same_base().

667  { return same_base(that) && _value > static_cast<const Field<fp_type, field>&>(that)._value; }
bool same_base(const BaseField &that) const
BaseField Equivalence test.
Definition: field.hpp:207
template<unsigned short field>
std::ostream& FIX8::Field< fp_type, field >::print ( std::ostream &  os) const
inlinevirtual

Print this field to the supplied stream. Used to format for FIX output.

Parameters
osstream to insert to
Returns
stream

Implements FIX8::BaseField.

Definition at line 706 of file field.hpp.

706 { return os << _value; }
template<unsigned short field>
size_t FIX8::Field< fp_type, field >::print ( char *  to) const
inlinevirtual

Print this field to the supplied buffer.

Parameters
tobuffer to print to
Returns
number bytes encoded

Implements FIX8::BaseField.

Definition at line 711 of file field.hpp.

References FIX8::modp_dtoa().

711 { return modp_dtoa(_value, to, _precision); }
size_t modp_dtoa(double value, char *str, int prec)
Convert double to ascii.
Definition: modp_numtoa.c:68
template<unsigned short field>
const fp_type& FIX8::Field< fp_type, field >::set ( const fp_type from)
inline

Get field value.

Parameters
fromvalue to set
Returns
original value (int)

Definition at line 692 of file field.hpp.

References FIX8::BaseField::from().

692 { return _value = from; }
template<unsigned short field>
const fp_type& FIX8::Field< fp_type, field >::set_from_raw ( const f8String from)
inline

Set the value from a string.

Parameters
fromvalue to set
Returns
original value (fp_type)

Definition at line 697 of file field.hpp.

References FIX8::fast_atof().

697 { return _value = fast_atof(from.c_str()); }
fp_type fast_atof(const char *p)
Definition: f8utils.hpp:727
template<unsigned short field>
void FIX8::Field< fp_type, field >::set_precision ( const int  prec)
inline

Set the output precision

Parameters
precprecision digits

Definition at line 671 of file field.hpp.

671 { _precision = prec; }

Member Data Documentation

template<unsigned short field>
const FieldTrait::FieldType FIX8::Field< fp_type, field >::_ftype = FieldTrait::ft_float
staticprotected

Definition at line 601 of file field.hpp.

template<unsigned short field>
int FIX8::Field< fp_type, field >::_precision
protected

Definition at line 600 of file field.hpp.

template<unsigned short field>
fp_type FIX8::Field< fp_type, field >::_value
protected

Definition at line 599 of file field.hpp.


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