fix8  version 1.4.0
Open Source C++ FIX Framework
FIX8::FieldTraits Class Reference

A collection of FieldTraits for a message. Which fields are required, which are present. More...

#include <traits.hpp>

Public Member Functions

template<typename InputIterator >
 FieldTraits (const InputIterator begin, const size_t cnt, const FieldTrait_Hash_Array *ftha)
 
 FieldTraits ()
 Ctor. More...
 
bool has (const unsigned short field, Presence::const_iterator &itr) const
 
bool has (const unsigned short field) const
 
unsigned getval (const unsigned short field)
 
size_t size () const
 
bool get (const unsigned short field, FieldTrait::TraitTypes type=FieldTrait::present) const
 
bool get (const unsigned short field, Presence::const_iterator &itr, FieldTrait::TraitTypes type) const
 
unsigned short find_missing (FieldTrait::TraitTypes type=FieldTrait::mandatory) const
 
void set (const unsigned short field, Presence::const_iterator &itr, FieldTrait::TraitTypes type)
 
void set (const unsigned short field, FieldTrait::TraitTypes type=FieldTrait::present)
 
void clear (const unsigned short field, Presence::const_iterator &itr, FieldTrait::TraitTypes type=FieldTrait::present)
 
void clear (const unsigned short field, FieldTrait::TraitTypes type=FieldTrait::present)
 
bool add (const FieldTrait &what)
 
template<typename InputIterator >
void add (const InputIterator begin, const size_t cnt)
 
void clear_flag (FieldTrait::TraitTypes type=FieldTrait::present)
 
bool is_present (const unsigned short field) const
 
bool is_mandatory (const unsigned short field) const
 
bool is_group (const unsigned short field, Presence::const_iterator &itr) const
 
bool is_group (const unsigned short field) const
 
bool is_component (const unsigned short field) const
 
unsigned short getComp (const unsigned short field, Presence::const_iterator &itr) const
 
unsigned short getComp (const unsigned short field) const
 
unsigned short getPos (const unsigned short field, Presence::const_iterator &itr) const
 
unsigned short getPos (const unsigned short field) const
 
const Presenceget_presence () const
 

Private Attributes

Presence _presence
 

Friends

F8API std::ostream & operator<< (std::ostream &os, const FieldTraits &what)
 

Detailed Description

A collection of FieldTraits for a message. Which fields are required, which are present.

Definition at line 437 of file traits.hpp.

Constructor & Destructor Documentation

template<typename InputIterator >
FIX8::FieldTraits::FieldTraits ( const InputIterator  begin,
const size_t  cnt,
const FieldTrait_Hash_Array ftha 
)
inline

Ctor.

Template Parameters
InputIteratorinput iterator to construct from
Parameters
beginstart iterator to input
cntnumber of elements to input
fthafield trait hash array

Definition at line 448 of file traits.hpp.

449  : _presence(begin, cnt, ftha) {}
Presence _presence
Definition: traits.hpp:439
FIX8::FieldTraits::FieldTraits ( )
inline

Ctor.

Definition at line 451 of file traits.hpp.

451 {}

Member Function Documentation

bool FIX8::FieldTraits::add ( const FieldTrait what)
inline

Add a FieldTrait.

Parameters
whatTraitType to add
Returns
true on success (false already present)

Definition at line 575 of file traits.hpp.

References FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::insert().

Referenced by FIX8::MessageBase::add_trait(), parse_groups(), and process_message_fields().

575 { return _presence.insert(&what).second; }
Presence _presence
Definition: traits.hpp:439
template<typename InputIterator >
void FIX8::FieldTraits::add ( const InputIterator  begin,
const size_t  cnt 
)
inline

Add from a range of traits.

Parameters
beginstart iterator to input
cntnumber of elements to input

Definition at line 581 of file traits.hpp.

References FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::insert().

581 { _presence.insert(begin, begin + cnt); }
Presence _presence
Definition: traits.hpp:439
void FIX8::FieldTraits::clear ( const unsigned short  field,
Presence::const_iterator itr,
FieldTrait::TraitTypes  type = FieldTrait::present 
)
inline

Clear a trait for a specified field.

Parameters
fieldto set
itrhint iterator: if end, set to itr of found element, if not end use it to locate element
typeTraitType to set (default present)

Definition at line 550 of file traits.hpp.

References FIX8::FieldTrait::_field_traits, FIX8::ebitset< T, B >::clear(), FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::end(), and FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::find().

Referenced by process_special_traits().

551  {
552  if (itr == _presence.end())
553  {
554  itr = _presence.find(field);
555  if (itr != _presence.end())
556  itr->_field_traits.clear(type);
557  }
558  else
559  itr->_field_traits.clear(type);
560  }
void clear(const T sbit)
Definition: f8utils.hpp:913
ebitset< TraitTypes, unsigned short > _field_traits
Definition: traits.hpp:155
Presence _presence
Definition: traits.hpp:439
iterator find(const FieldTrait what, bool &answer)
Definition: traits.hpp:282
void FIX8::FieldTraits::clear ( const unsigned short  field,
FieldTrait::TraitTypes  type = FieldTrait::present 
)
inline

Clear a trait for a specified field.

Parameters
fieldto set
typeTraitType to set (default present)

Definition at line 565 of file traits.hpp.

References FIX8::FieldTrait::_field_traits, FIX8::ebitset< T, B >::clear(), FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::end(), and FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::find().

566  {
567  Presence::iterator itr(_presence.find(field));
568  if (itr != _presence.end())
569  itr->_field_traits.clear(type);
570  }
void clear(const T sbit)
Definition: f8utils.hpp:913
ebitset< TraitTypes, unsigned short > _field_traits
Definition: traits.hpp:155
Presence _presence
Definition: traits.hpp:439
iterator find(const FieldTrait what, bool &answer)
Definition: traits.hpp:282
unsigned short FIX8::FieldTraits::find_missing ( FieldTrait::TraitTypes  type = FieldTrait::mandatory) const
inline

Find the first field that does not have the specified trait.

Parameters
typeTraitType to check (default mandatory)
Returns
field number of field, 0 if none

Definition at line 512 of file traits.hpp.

References FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::begin(), FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::end(), and FIX8::FieldTrait::present.

513  {
514  for (Presence::const_iterator itr(_presence.begin()); itr != _presence.end(); ++itr)
515  if ((itr->_field_traits & type) && (itr->_field_traits & FieldTrait::present) == 0)
516  return itr->_fnum;
517  return 0;
518  }
Presence _presence
Definition: traits.hpp:439
bool FIX8::FieldTraits::get ( const unsigned short  field,
FieldTrait::TraitTypes  type = FieldTrait::present 
) const
inline

Check if a field has a specified trait.

Parameters
fieldto check
typeTraitType to check (default present)
Returns
true if field has trait

Definition at line 490 of file traits.hpp.

References FIX8::FieldTrait::_field_traits, FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::end(), FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::find(), and FIX8::ebitset< T, B >::has().

Referenced by FIX8::MessageBase::add_field(), FIX8::MessageBase::copy_legal(), FIX8::MessageBase::has(), FIX8::MessageBase::have(), and FIX8::MessageBase::move_legal().

491  {
493  return itr != _presence.end() ? itr->_field_traits.has(type) : false;
494  }
ebitset< TraitTypes, unsigned short > _field_traits
Definition: traits.hpp:155
Presence _presence
Definition: traits.hpp:439
integral_type has(const T sbit) const
Definition: f8utils.hpp:876
iterator find(const FieldTrait what, bool &answer)
Definition: traits.hpp:282
bool FIX8::FieldTraits::get ( const unsigned short  field,
Presence::const_iterator itr,
FieldTrait::TraitTypes  type 
) const
inline

Check if a field has a specified trait.

Parameters
fieldto check
itrhint iterator: if end, set to itr of found element, if not end use it to locate element
typeTraitType to check (default present)
Returns
true if field has trait

Definition at line 501 of file traits.hpp.

References FIX8::FieldTrait::_field_traits, FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::end(), FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::find(), and FIX8::ebitset< T, B >::has().

502  {
503  if (itr != _presence.end())
504  return itr->_field_traits.has(type);
505  itr = _presence.find(field);
506  return itr != _presence.end() ? itr->_field_traits.has(type) : false;
507  }
ebitset< TraitTypes, unsigned short > _field_traits
Definition: traits.hpp:155
Presence _presence
Definition: traits.hpp:439
integral_type has(const T sbit) const
Definition: f8utils.hpp:876
iterator find(const FieldTrait what, bool &answer)
Definition: traits.hpp:282
const Presence& FIX8::FieldTraits::get_presence ( ) const
inline
unsigned short FIX8::FieldTraits::getComp ( const unsigned short  field,
Presence::const_iterator itr 
) const
inline

Get the field component index of a specified field.

Parameters
fieldfield to get
itrhint iterator: if end, set to itr of found element, if not end use it to locate element
Returns
index of component of field, 0 if not found

Definition at line 618 of file traits.hpp.

References FIX8::FieldTrait::_component, FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::end(), and FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::find().

619  {
620  if (itr != _presence.end())
621  return itr->_component;
622  itr = _presence.find(field);
623  return itr != _presence.end() ? itr->_component : 0;
624  }
unsigned short _component
Definition: traits.hpp:154
Presence _presence
Definition: traits.hpp:439
iterator find(const FieldTrait what, bool &answer)
Definition: traits.hpp:282
unsigned short FIX8::FieldTraits::getComp ( const unsigned short  field) const
inline

Get the field component index of a specified field.

Parameters
fieldfield to get
Returns
index of component of field, 0 if not found

Definition at line 629 of file traits.hpp.

References FIX8::FieldTrait::_component, FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::end(), and FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::find().

unsigned short FIX8::FieldTraits::getPos ( const unsigned short  field,
Presence::const_iterator itr 
) const
inline

Get the field position of a specified field.

Parameters
fieldfield to get
itrhint iterator: if end, set to itr of found element, if not end use it to locate element
Returns
position of field, 0 if no pos or not found

Definition at line 639 of file traits.hpp.

References FIX8::FieldTrait::_field_traits, FIX8::FieldTrait::_pos, FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::end(), FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::find(), FIX8::ebitset< T, B >::has(), and FIX8::FieldTrait::position.

Referenced by FIX8::MessageBase::add_field(), and FIX8::MessageBase::getPos().

640  {
641  if (itr != _presence.end())
642  return itr->_field_traits.has(FieldTrait::position) ? itr->_pos : 0;
643  itr = _presence.find(field);
644  return itr != _presence.end() && itr->_field_traits.has(FieldTrait::position) ? itr->_pos : 0;
645  }
ebitset< TraitTypes, unsigned short > _field_traits
Definition: traits.hpp:155
Presence _presence
Definition: traits.hpp:439
integral_type has(const T sbit) const
Definition: f8utils.hpp:876
iterator find(const FieldTrait what, bool &answer)
Definition: traits.hpp:282
unsigned short FIX8::FieldTraits::getPos ( const unsigned short  field) const
inline

Get the field position of a specified field.

Parameters
fieldfield to get
Returns
position of field, 0 if no pos or not found

Definition at line 650 of file traits.hpp.

References FIX8::FieldTrait::_field_traits, FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::end(), FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::find(), FIX8::ebitset< T, B >::has(), and FIX8::FieldTrait::position.

651  {
653  return itr != _presence.end() && itr->_field_traits.has(FieldTrait::position) ? itr->_pos : 0;
654  }
ebitset< TraitTypes, unsigned short > _field_traits
Definition: traits.hpp:155
Presence _presence
Definition: traits.hpp:439
integral_type has(const T sbit) const
Definition: f8utils.hpp:876
iterator find(const FieldTrait what, bool &answer)
Definition: traits.hpp:282
unsigned FIX8::FieldTraits::getval ( const unsigned short  field)
inline

Get the traits for a field.

Parameters
fieldto get
Returns
traits as an unsigned short

Definition at line 476 of file traits.hpp.

References FIX8::FieldTrait::_field_traits, FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::end(), FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::find(), and FIX8::ebitset< T, B >::get().

477  {
479  return itr != _presence.end() ? itr->_field_traits.get() : 0;
480  }
integral_type get() const
Definition: f8utils.hpp:924
ebitset< TraitTypes, unsigned short > _field_traits
Definition: traits.hpp:155
Presence _presence
Definition: traits.hpp:439
iterator find(const FieldTrait what, bool &answer)
Definition: traits.hpp:282
bool FIX8::FieldTraits::has ( const unsigned short  field,
Presence::const_iterator itr 
) const
inline

Check if a field is present

Parameters
fieldto check
itrhint iterator: set to itr of found element
Returns
true if present

Definition at line 457 of file traits.hpp.

References FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::end(), and FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::find().

Referenced by FIX8::MessageBase::add_field(), FIX8::MessageBase::copy_legal(), FIX8::MessageBase::is_legal(), and FIX8::MessageBase::move_legal().

458  {
459  if (itr == _presence.end())
460  itr = _presence.find(field);
461  return itr != _presence.end();
462  }
Presence _presence
Definition: traits.hpp:439
iterator find(const FieldTrait what, bool &answer)
Definition: traits.hpp:282
bool FIX8::FieldTraits::has ( const unsigned short  field) const
inline
bool FIX8::FieldTraits::is_component ( const unsigned short  field) const
inline

Check if a specified field has the component bit set (is a component).

Parameters
fieldfield to check
Returns
true if a component

Definition at line 612 of file traits.hpp.

References FIX8::FieldTrait::component.

612 { return get(field, FieldTrait::component); }
bool FIX8::FieldTraits::is_group ( const unsigned short  field,
Presence::const_iterator itr 
) const
inline

Check if a specified field has the group bit set (is a group).

Parameters
fieldfield to check
itrhint iterator: if end, set to itr of found element, if not end use it to locate element
Returns
true if a group

Definition at line 602 of file traits.hpp.

References FIX8::FieldTrait::group.

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

602 { return get(field, itr, FieldTrait::group); }
bool FIX8::FieldTraits::is_group ( const unsigned short  field) const
inline

Check if a specified field has the group bit set (is a group).

Parameters
fieldfield to check
Returns
true if a group

Definition at line 607 of file traits.hpp.

References FIX8::FieldTrait::group.

607 { return get(field, FieldTrait::group); }
bool FIX8::FieldTraits::is_mandatory ( const unsigned short  field) const
inline

Check if a specified field has the mandator bit set.

Parameters
fieldfield to check
Returns
true if mandatory set

Definition at line 596 of file traits.hpp.

References FIX8::FieldTrait::mandatory.

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

596 { return get(field, FieldTrait::mandatory); }
bool FIX8::FieldTraits::is_present ( const unsigned short  field) const
inline

Check if a specified field has the present bit set (is present).

Parameters
fieldfield to check
Returns
true if present

Definition at line 591 of file traits.hpp.

References FIX8::FieldTrait::present.

591 { return get(field, FieldTrait::present); }
void FIX8::FieldTraits::set ( const unsigned short  field,
Presence::const_iterator itr,
FieldTrait::TraitTypes  type 
)
inline

Set a trait for a specified field.

Parameters
fieldto set
itrhint iterator: if end, set to itr of found element, if not end use it to locate element
typeTraitType to set (default present)

Definition at line 524 of file traits.hpp.

References FIX8::FieldTrait::_field_traits, FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::end(), FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::find(), and FIX8::ebitset< T, B >::set().

Referenced by FIX8::MessageBase::add_field(), process_special_traits(), FIX8::MessageBase::set(), and FIX8::Message::setup_reuse().

525  {
526  if (itr == _presence.end())
527  {
528  itr = _presence.find(field);
529  if (itr != _presence.end())
530  itr->_field_traits.set(type);
531  }
532  else
533  itr->_field_traits.set(type);
534  }
ebitset< TraitTypes, unsigned short > _field_traits
Definition: traits.hpp:155
Presence _presence
Definition: traits.hpp:439
iterator find(const FieldTrait what, bool &answer)
Definition: traits.hpp:282
void set(const T sbit, bool on=true)
Definition: f8utils.hpp:886
void FIX8::FieldTraits::set ( const unsigned short  field,
FieldTrait::TraitTypes  type = FieldTrait::present 
)
inline

Set a trait for a specified field.

Parameters
fieldto set
typeTraitType to set (default present)

Definition at line 539 of file traits.hpp.

References FIX8::FieldTrait::_field_traits, FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::end(), FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::find(), and FIX8::ebitset< T, B >::set().

540  {
541  Presence::iterator itr(_presence.find(field));
542  if (itr != _presence.end())
543  itr->_field_traits.set(type);
544  }
ebitset< TraitTypes, unsigned short > _field_traits
Definition: traits.hpp:155
Presence _presence
Definition: traits.hpp:439
iterator find(const FieldTrait what, bool &answer)
Definition: traits.hpp:282
void set(const T sbit, bool on=true)
Definition: f8utils.hpp:886
size_t FIX8::FieldTraits::size ( ) const
inline

Get the number of possible fields

Returns
number of fields

Definition at line 484 of file traits.hpp.

References FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::size().

Referenced by FIX8::MessageBase::size().

Friends And Related Function Documentation

F8API std::ostream& operator<< ( std::ostream &  os,
const FieldTraits what 
)
friend

Inserter friend.

Parameters
osstream to send to
whatFieldTraits
Returns
stream

Member Data Documentation

Presence FIX8::FieldTraits::_presence
private

Definition at line 439 of file traits.hpp.

Referenced by get_presence().


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