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

Static metadata context class - one per FIX xml schema. More...

#include <message.hpp>

Public Member Functions

 F8MetaCntx (const unsigned version, const MsgTable &bme, const FieldTable &be, const char **cn, const f8String &bg)
 
 ~F8MetaCntx ()
 Dtor. More...
 
const BaseEntryfind_be (const unsigned short fnum) const
 
const BaseEntryreverse_find_be (const char *fieldstr) const
 
unsigned short reverse_find_fnum (const char *fieldstr) const
 
BaseFieldcreate_field (unsigned short fnum, const char *from) const
 
BaseFieldcreate_field (const char *tag, const char *from) const
 
const BaseMsgEntryfind_bme (const char *tag) const
 
const BaseMsgEntryreverse_find_bme (const char *msgstr) const
 
Messagecreate_msg_from_longname (const char *tag, bool deepctor=true) const
 
Messagecreate_msg (const char *tag, bool deepctor=true) const
 
unsigned version () const
 
const f8Stringget_beginStr () const
 

Static Public Member Functions

static bool _comp (const char *p1, const char *p2)
 

Public Attributes

const unsigned _version
 4 digit fix version <Major:1><Minor:1><Revision:2> eg. 4.2r10 is 4210 More...
 
const MsgTable_bme
 Framework generated lookup table to generate Fix messages. More...
 
const FieldTable_be
 Framework generated lookup table to generate Fix fields. More...
 
const char ** _cn
 Framework generated component name table. More...
 
const unsigned _flu_sz
 Number of elements in Hash array. More...
 
const BaseEntry ** _flu
 Hash array for field lookup (built by ctor) More...
 
msg_create _mk_hdr
 References to the header and trailer create functions. More...
 
msg_create _mk_trl
 
const f8String _beginStr
 Fix header beginstring. More...
 
const size_t _preamble_sz
 Preamble length. More...
 
ReverseMsgTable _reverse_msgtable
 
ReverseFieldTable _reverse_fieldtable
 

Detailed Description

Static metadata context class - one per FIX xml schema.

Definition at line 210 of file message.hpp.

Constructor & Destructor Documentation

FIX8::F8MetaCntx::F8MetaCntx ( const unsigned  version,
const MsgTable bme,
const FieldTable be,
const char **  cn,
const f8String bg 
)
inline

Ctor.

Parameters
versionFIX version
bmeGenerated Message Table
beGenerated Field Table
cnComponent name table
bgBeginString

Definition at line 242 of file message.hpp.

References FIX8::_pair< Key, Val >::_key, FIX8::_pair< Key, Val >::_value, FIX8::GeneratedTable< Key, Val >::at(), FIX8::GeneratedTable< Key, Val >::begin(), FIX8::GeneratedTable< Key, Val >::end(), and FIX8::GeneratedTable< Key, Val >::size().

243  : _version(version), _bme(bme), _be(be), _cn(cn),
244  _flu_sz(_be.at(_be.size() - 1)->_key + 1), _flu(new const BaseEntry *[_flu_sz]),
245  _mk_hdr(_bme.find_ref("header")._create._do), _mk_trl(_bme.find_ref("trailer")._create._do),
246  _beginStr(bg), _preamble_sz(2 + _beginStr.size() + 1 + 3),
248  {
249  if (_flu_sz == 1)
250  throw f8Exception("F8MetaCntx initialisation incomplete");
251  std::fill(_flu, _flu + _flu_sz, nullptr);
252  for (unsigned offset(0); offset < _be.size(); ++offset)
253  *(_flu + _be.at(offset)->_key) = &_be.at(offset)->_value;
254 
255  std::for_each(_be.begin(), _be.end(), [this](const FieldTable::Pair& pp)
256  { _reverse_fieldtable.emplace(std::make_pair(pp.second()._name, &pp.second())); });
257  std::for_each(_bme.begin(), _bme.end(), [this](const MsgTable::Pair& pp)
258  { _reverse_msgtable.emplace(std::make_pair(pp.second()._name, &pp.second())); });
259  }
const MsgTable & _bme
Framework generated lookup table to generate Fix messages.
Definition: message.hpp:216
const unsigned _flu_sz
Number of elements in Hash array.
Definition: message.hpp:222
const_iterator begin() const
Definition: f8types.hpp:133
const unsigned _version
4 digit fix version eg. 4.2r10 is 4210
Definition: message.hpp:213
Val _value
Definition: f8types.hpp:72
ReverseMsgTable _reverse_msgtable
Definition: message.hpp:232
const f8String _beginStr
Fix header beginstring.
Definition: message.hpp:228
static bool _comp(const char *p1, const char *p2)
Definition: message.hpp:234
size_t size() const
Definition: f8types.hpp:176
const size_t _preamble_sz
Preamble length.
Definition: message.hpp:230
ReverseFieldTable _reverse_fieldtable
Definition: message.hpp:233
msg_create _mk_trl
Definition: message.hpp:226
const FieldTable & _be
Framework generated lookup table to generate Fix fields.
Definition: message.hpp:218
_pair< Key, Val > Pair
Definition: f8types.hpp:103
const char ** _cn
Framework generated component name table.
Definition: message.hpp:220
unsigned version() const
Definition: message.hpp:352
msg_create _mk_hdr
References to the header and trailer create functions.
Definition: message.hpp:226
const_iterator at(const size_t idx) const
Definition: f8types.hpp:172
const Val & find_ref(const Key &key) const
Definition: f8types.hpp:143
const BaseEntry ** _flu
Hash array for field lookup (built by ctor)
Definition: message.hpp:224
const_iterator end() const
Definition: f8types.hpp:137
FIX8::F8MetaCntx::~F8MetaCntx ( )
inline

Dtor.

Definition at line 262 of file message.hpp.

References _flu.

262 { delete[] _flu; _flu = nullptr; }
const BaseEntry ** _flu
Hash array for field lookup (built by ctor)
Definition: message.hpp:224

Member Function Documentation

static bool FIX8::F8MetaCntx::_comp ( const char *  p1,
const char *  p2 
)
inlinestatic

Definition at line 234 of file message.hpp.

234 { return ::strcmp(p1, p2) < 0; }
BaseField* FIX8::F8MetaCntx::create_field ( unsigned short  fnum,
const char *  from 
) const
inline

Create a new field of the tag type passed, and from the raw string given.

Parameters
fnumFIX field number
fromconst char ptr to string containing value to construct from
Returns
ptr to BaseField or 0 if fnum not found

Definition at line 300 of file message.hpp.

References FIX8::BaseEntry::_create, FIX8::Inst::_do, FIX8::BaseEntry::_rlm, and find_be().

301  {
302  const BaseEntry *be(find_be(fnum));
303  return be ? be->_create._do(from, be->_rlm, -1) : nullptr;
304  }
const BaseEntry * find_be(const unsigned short fnum) const
Definition: message.hpp:267
BaseField* FIX8::F8MetaCntx::create_field ( const char *  tag,
const char *  from 
) const
inline

Create a new field of the tag type passed, and from the raw string given.

Parameters
tagconst char ptr to longname of field to create
fromconst char ptr to string containing value to construct from
Returns
ptr to BaseField or 0 if fnum not found

Definition at line 310 of file message.hpp.

References FIX8::BaseEntry::_create, FIX8::Inst::_do, FIX8::BaseEntry::_rlm, and reverse_find_be().

311  {
312  const BaseEntry *be(reverse_find_be(tag));
313  return be ? be->_create._do(from, be->_rlm, -1) : nullptr;
314  }
const BaseEntry * reverse_find_be(const char *fieldstr) const
Definition: message.hpp:273
Message* FIX8::F8MetaCntx::create_msg ( const char *  tag,
bool  deepctor = true 
) const
inline

Create a new message of the tag type passed.

Parameters
tagconst char ptr to tag of message
deepctorif true, do deep message construction
Returns
ptr to Message or 0 if tag not found

Definition at line 344 of file message.hpp.

References FIX8::BaseMsgEntry::_create, FIX8::Minst::_do, and find_bme().

345  {
346  const BaseMsgEntry *bme(find_bme(tag));
347  return bme ? bme->_create._do(deepctor) : nullptr;
348  }
const BaseMsgEntry * find_bme(const char *tag) const
Definition: message.hpp:319
Message* FIX8::F8MetaCntx::create_msg_from_longname ( const char *  tag,
bool  deepctor = true 
) const
inline

Create a new message from longname

Parameters
tagconst char ptr to tag of message
deepctorif true, do deep message construction
Returns
ptr to Message or 0 if tag not found

Definition at line 334 of file message.hpp.

References FIX8::BaseMsgEntry::_create, FIX8::Minst::_do, and reverse_find_bme().

335  {
336  const BaseMsgEntry *bme(reverse_find_bme(tag));
337  return bme ? bme->_create._do(deepctor) : nullptr;
338  }
const BaseMsgEntry * reverse_find_bme(const char *msgstr) const
Definition: message.hpp:324
const BaseEntry* FIX8::F8MetaCntx::find_be ( const unsigned short  fnum) const
inline

Get the field BaseEntry object for this field number. Will use fast field index lookup.

Parameters
fnumfield to get
Returns
ptr to BaseEntry or 0 if not found

Definition at line 267 of file message.hpp.

Referenced by FIX8::MessageBase::check_set_rlm(), and create_field().

268  { return fnum < _flu_sz ? _flu[fnum] : nullptr; }
const unsigned _flu_sz
Number of elements in Hash array.
Definition: message.hpp:222
const BaseEntry ** _flu
Hash array for field lookup (built by ctor)
Definition: message.hpp:224
const BaseMsgEntry* FIX8::F8MetaCntx::find_bme ( const char *  tag) const
inline

Get the message BaseMsgEntry object for this message.

Parameters
tagconst char ptr to name of message to get
Returns
ptr to BaseMsgEntry or 0 if not found

Definition at line 319 of file message.hpp.

References FIX8::GeneratedTable< Key, Val >::find_ptr().

Referenced by create_msg().

319 { return _bme.find_ptr(tag); }
const MsgTable & _bme
Framework generated lookup table to generate Fix messages.
Definition: message.hpp:216
const Val * find_ptr(const Key &key) const
Definition: f8types.hpp:154
const f8String& FIX8::F8MetaCntx::get_beginStr ( ) const
inline

Get fix header beginstring

Returns
beginstring

Definition at line 356 of file message.hpp.

References _beginStr.

356 { return _beginStr; }
const f8String _beginStr
Fix header beginstring.
Definition: message.hpp:228
const BaseEntry* FIX8::F8MetaCntx::reverse_find_be ( const char *  fieldstr) const
inline

Get the field BaseEntry object for this field by tag. Reverse lookup.

Parameters
fieldstrconst char ptr to longname of field to get
Returns
ptr to BaseEntry or 0 if not found

Definition at line 273 of file message.hpp.

Referenced by create_field().

274  {
275  if (fieldstr && *fieldstr)
276  {
277  auto itr(_reverse_fieldtable.find(fieldstr));
278  return itr != _reverse_fieldtable.cend() ? itr->second : nullptr;
279  }
280  return nullptr;
281  }
ReverseFieldTable _reverse_fieldtable
Definition: message.hpp:233
const BaseMsgEntry* FIX8::F8MetaCntx::reverse_find_bme ( const char *  msgstr) const
inline

Get the message BaseMsgEntry object for this message. Reverse lookup.

Parameters
msgstrconst char ptr to longname of message to get
Returns
ptr to BaseMsgEntry or 0 if not found

Definition at line 324 of file message.hpp.

Referenced by create_msg_from_longname().

325  {
326  auto itr(_reverse_msgtable.find(msgstr));
327  return itr != _reverse_msgtable.cend() ? itr->second : nullptr;
328  }
ReverseMsgTable _reverse_msgtable
Definition: message.hpp:232
unsigned short FIX8::F8MetaCntx::reverse_find_fnum ( const char *  fieldstr) const
inline

Get the field number for this field by tag. Reverse lookup.

Parameters
fieldstrconst char ptr to longname of field to get
Returns
unsigned short field number

Definition at line 286 of file message.hpp.

Referenced by FIX8::MessageBase::get_field_by_name(), and FIX8::Message::get_field_by_name_flattened().

287  {
288  if (fieldstr && *fieldstr)
289  {
290  auto itr(_reverse_fieldtable.find(fieldstr));
291  return itr != _reverse_fieldtable.cend() ? itr->second->_fnum : 0;
292  }
293  return 0;
294  }
ReverseFieldTable _reverse_fieldtable
Definition: message.hpp:233
unsigned FIX8::F8MetaCntx::version ( ) const
inline

4 digit fix version <Major:1><Minor:1><Revision:2> eg. 4.2r10 is 4210

Returns
version

Definition at line 352 of file message.hpp.

References _version.

Referenced by main().

352 { return _version; }
const unsigned _version
4 digit fix version eg. 4.2r10 is 4210
Definition: message.hpp:213

Member Data Documentation

const FieldTable& FIX8::F8MetaCntx::_be

Framework generated lookup table to generate Fix fields.

Definition at line 218 of file message.hpp.

const f8String FIX8::F8MetaCntx::_beginStr

Fix header beginstring.

Definition at line 228 of file message.hpp.

Referenced by get_beginStr(), FIX8::Session::handle_logon(), and main().

const MsgTable& FIX8::F8MetaCntx::_bme

Framework generated lookup table to generate Fix messages.

Definition at line 216 of file message.hpp.

Referenced by FIX8::Session::create_msg(), and FIX8::Message::factory().

const char** FIX8::F8MetaCntx::_cn

Framework generated component name table.

Definition at line 220 of file message.hpp.

const BaseEntry** FIX8::F8MetaCntx::_flu

Hash array for field lookup (built by ctor)

Definition at line 224 of file message.hpp.

Referenced by ~F8MetaCntx().

const unsigned FIX8::F8MetaCntx::_flu_sz

Number of elements in Hash array.

Definition at line 222 of file message.hpp.

msg_create FIX8::F8MetaCntx::_mk_hdr

References to the header and trailer create functions.

Definition at line 226 of file message.hpp.

msg_create FIX8::F8MetaCntx::_mk_trl

Definition at line 226 of file message.hpp.

const size_t FIX8::F8MetaCntx::_preamble_sz

Preamble length.

Definition at line 230 of file message.hpp.

ReverseFieldTable FIX8::F8MetaCntx::_reverse_fieldtable

Definition at line 233 of file message.hpp.

ReverseMsgTable FIX8::F8MetaCntx::_reverse_msgtable

Definition at line 232 of file message.hpp.

const unsigned FIX8::F8MetaCntx::_version

4 digit fix version <Major:1><Minor:1><Revision:2> eg. 4.2r10 is 4210

Definition at line 213 of file message.hpp.

Referenced by version().


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