High Frequency FIX Parser
C++ library for high frequency messaging with the Financial Information Exchange (FIX) protocol.
|
One FIX message for reading. More...
#include <hffix.hpp>
Public Types | |
typedef field | value_type |
typedef field const & | const_reference |
typedef message_reader_const_iterator | const_iterator |
typedef field const * | const_pointer |
typedef size_t | size_type |
Public Member Functions | |
message_reader (char const *buffer, size_t size) | |
Construct by buffer size. | |
message_reader (char const *begin, char const *end) | |
Construct by buffer begin and end. | |
message_reader (message_reader const &that) | |
Copy constructor. The hffix::message_reader is immutable, so copying it is fine. | |
message_reader & | operator= (const message_reader &that) |
Copy assignment operator. The hffix::message_reader is immutable, so copying it is fine. | |
message_reader (message_writer const &that) | |
Construct a message_reader from a message_writer. Equivalent to. | |
template<size_t N> | |
message_reader (const char(&buffer)[N]) | |
Construct on an array reference to a buffer. | |
~message_reader () | |
Owns no resources, so destruction is no-op. | |
bool | is_complete () const |
True if the buffer contains a complete FIX message. | |
bool | is_valid () const |
True if the message is valid. | |
message_reader | next_message_reader () const |
Returns a new message_reader for the next FIX message in the buffer. | |
unsigned char | calculate_check_sum () |
Calulate the checksum for this message. | |
Field Access | |
const_iterator | begin () const |
An iterator to the MsgType field in the FIX message. Same as hffix::message_reader::message_type(). | |
const_iterator | end () const |
An iterator to the CheckSum field in the FIX message. Same as hffix::message_reader::check_sum(). | |
const_iterator | message_type () const |
An iterator to the MsgType field in the FIX message. Same as hffix::message_reader::begin(). | |
const_iterator | check_sum () const |
An iterator to the CheckSum field in the FIX message. Same as hffix::message_reader::end(). | |
char const * | prefix_begin () const |
Returns the FIX version prefix BeginString field value begin pointer. (Example: "FIX.4.4") | |
char const * | prefix_end () const |
Returns the FIX version prefix BeginString field value end pointer. | |
size_t | prefix_size () const |
Returns the FIX version prefix BeginString field value size. (Example: returns 7 for "FIX.4.4") | |
bool | find_with_hint (int tag, const_iterator &i) const |
Convenient synonym for hffix::find_with_hint(reader.begin(), reader.end(), hffix::tag_equal(tag), i) . | |
Buffer Access | |
char const * | buffer_begin () const |
A pointer to the begining of the buffer. | |
char const * | buffer_end () const |
A pointer to past-the-end of the buffer. | |
size_t | buffer_size () const |
The size of the buffer in bytes. | |
char const * | message_begin () const |
A pointer to the beginning of the FIX message in the buffer. | |
char const * | message_end () const |
A pointer to past-the-end of the FIX message in the buffer. | |
size_t | message_size () const |
The entire size of the FIX message in bytes. | |
One FIX message for reading.
An immutable Forward Container of FIX fields. Given a buffer containing a FIX message, the hffix::message_reader will provide an Iterator for iterating over the fields in the message without modifying the buffer. The buffer used to construct the hffix::message_reader must outlive the hffix::message_reader.
During construction, hffix::message_reader checks to make sure there is a complete, valid FIX message in the buffer. It looks only at the header and trailer transport fields in the message, not at the content fields, so construction is O(1).
If hffix::message_reader is complete and valid after construction, hffix::message_reader::begin() returns an iterator that points to the MsgType field in the FIX Standard Message Header, and hffix::message_reader::end() returns an iterator that points to the CheckSum field in the FIX Standard Message Trailer.
The hffix::message_reader will only iterate over content fields of the message, and will skip over all of the framing transport fields that are mixed in with the content fields in FIX. Here is the list of skipped fields which will not appear when iterating over the fields of the message:
Fields of binary data type are content fields, and will be iterated over like any other field. The special FIX binary data length framing fields will be skipped, but the length of the binary data is accessible from the hffix::message_reader::value_type::value().size() of the content field.
typedef field const* hffix::message_reader::const_pointer |
typedef field const& hffix::message_reader::const_reference |
|
inline |
|
inline |
|
inline |
Copy constructor. The hffix::message_reader is immutable, so copying it is fine.
|
inline |
Construct a message_reader from a message_writer. Equivalent to.
|
inline |
|
inline |
|
inline |
An iterator to the MsgType field in the FIX message. Same as hffix::message_reader::message_type().
std::logic_error | if called on an invalid message. This exception is preventable by program logic. You should always check if a message is_valid() before reading. |
|
inline |
A pointer to the begining of the buffer.
|
inline |
|
inline |
|
inline |
Calulate the checksum for this message.
Note that the hffix library never does this calculation implicitly for messages read. For checksum calculation this function must be explicitly called.
The only thing to do after calculating the checksum for this message is to compare it to the CheckSum field that the message reports for itself, like so:
std::logic_error | if called on an invalid message. Check for is_valid() before calling. |
|
inline |
An iterator to the CheckSum field in the FIX message. Same as hffix::message_reader::end().
std::logic_error | if called on an invalid message. This exception is preventable by program logic. You should always check if a message is_valid() before reading. |
|
inline |
An iterator to the CheckSum field in the FIX message. Same as hffix::message_reader::check_sum().
std::logic_error | if called on an invalid message. This exception is preventable by program logic. You should always check if a message is_valid() before reading. |
|
inline |
Convenient synonym for hffix::find_with_hint(reader.begin(), reader.end(), hffix::tag_equal(tag), i)
.
Similar to std::find_if
. See hffix::find_with_hint
for details.
tag | The field tag number to find. |
i | If a field is found which has the tag number tag , then i is modified to point to the found item. Else i is unmodified. |
i
was modified to point to the found field.Example usage:
|
inline |
|
inline |
True if the message is valid.
A valid message must meet these criteria.
If false, the message is unintelligable, and the length of the message is unknown.
fix-42_with_errata_20010501.pdf p.17: "Valid FIX Message is a message that is properly formed according to this specification and contains a valid body length and checksum field"
|
inline |
A pointer to the beginning of the FIX message in the buffer.
buffer_begin() == message_begin()
std::logic_error | if called on an invalid message. This exception is preventable by program logic. You should always check if a message is_valid() before reading. |
|
inline |
A pointer to past-the-end of the FIX message in the buffer.
std::logic_error | if called on an invalid message. This exception is preventable by program logic. You should always check if a message is_valid() before reading. |
|
inline |
The entire size of the FIX message in bytes.
std::logic_error | if called on an invalid message. This exception is preventable by program logic. You should always check if a message is_valid() before reading. |
|
inline |
An iterator to the MsgType field in the FIX message. Same as hffix::message_reader::begin().
std::logic_error | if called on an invalid message. This exception is preventable by program logic. You should always check if a message is_valid() before reading. |
|
inline |
Returns a new message_reader for the next FIX message in the buffer.
If this message is_valid() and is_complete(), assume that the next message comes immediately after this one and return a new message_reader constructed at this->message_end().
If this message !
is_valid(), will search the remainder of the buffer for the text "8=FIX", to see if there might be a complete or partial valid message anywhere else in the remainder of the buffer, will return a new message_reader constructed at that location.
std::logic_error | If this message ! is_complete(). |
|
inline |
Copy assignment operator. The hffix::message_reader is immutable, so copying it is fine.
|
inline |
|
inline |
|
inline |