![]() |
Base representation of all Field classes. More...
#include <Field.h>
Public Member Functions | |
FieldBase (int field, const std::string &string) | |
virtual | ~FieldBase () |
void | setField (int field) |
void | setString (const std::string &string) |
int | getField () const |
Get the fields integer tag. | |
const std::string & | getString () const |
Get the string representation of the fields value. | |
const std::string & | getValue () const |
Get the string representation of the Field (i.e.) 55=MSFT[SOH]. | |
int | getLength () const |
Get the length of the fields string representation. | |
int | getTotal () const |
Get the total value the fields characters added together. | |
bool | operator< (const FieldBase &field) const |
Compares fields based on thier tag numbers. | |
Private Member Functions | |
void | calculate () const |
Private Attributes | |
int | m_field |
std::string | m_string |
std::string | m_data |
int | m_length |
int | m_total |
bool | m_calculated |
Friends | |
class | Message |
Base representation of all Field classes.
This base class is the lowest common denominator of all fields. It keeps all fields in its most generic string representation with its integer tag.
Definition at line 45 of file Field.h.
FIX::FieldBase::FieldBase | ( | int | field, | |
const std::string & | string | |||
) | [inline] |
virtual FIX::FieldBase::~FieldBase | ( | ) | [inline, virtual] |
void FIX::FieldBase::calculate | ( | ) | const [inline, private] |
Definition at line 102 of file Field.h.
References FIX::IntConvertor::convert(), m_calculated, m_data, m_field, m_length, m_string, m_total, and STRING_SPRINTF.
Referenced by getLength(), getTotal(), and getValue().
00103 { 00104 if( m_calculated ) return; 00105 00106 char buf[64]; 00107 00108 if( 13 + m_string.length() < sizeof(buf) ) 00109 { 00110 int tagLength = STRING_SPRINTF( buf, "%d=", m_field ); 00111 m_length = tagLength + m_string.length() + 1; 00112 memcpy( buf + tagLength, m_string.data(), m_string.length() ); 00113 buf[m_length - 1] = '\001'; 00114 m_data.assign( buf, m_length ); 00115 } 00116 else 00117 { 00118 m_data = IntConvertor::convert(m_field) + "=" + m_string + "\001"; 00119 m_length = m_data.length(); 00120 } 00121 00122 const unsigned char* iter = 00123 reinterpret_cast<const unsigned char*>( m_data.c_str() ); 00124 m_total = std::accumulate( iter, iter + m_length, 0 ); 00125 00126 m_calculated = true; 00127 }
int FIX::FieldBase::getField | ( | ) | const [inline] |
Get the fields integer tag.
Definition at line 69 of file Field.h.
References m_field.
Referenced by FIX::DataDictionary::checkGroupCount(), FIX::DataDictionary::checkIsInMessage(), FIX::Message::isHeaderField(), FIX::FieldMap::isSetField(), FIX::Message::isTrailerField(), FIX::DataDictionary::iterate(), FIX::FieldMap::setField(), FIX::Message::setGroup(), FIX::Message::setString(), FIX::Message::setStringHeader(), and FIX::DataDictionary::shouldCheckTag().
00070 { return m_field; }
int FIX::FieldBase::getLength | ( | ) | const [inline] |
const std::string& FIX::FieldBase::getString | ( | ) | const [inline] |
Get the string representation of the fields value.
Definition at line 73 of file Field.h.
References m_string.
Referenced by FIX::DataDictionary::checkGroupCount(), FIX::FieldMap::getField(), FIX::StringField::getValue(), FIX::StringField::operator const std::string &(), FIX::StringField::operator!=(), FIX::StringField::operator<(), FIX::StringField::operator<=(), FIX::StringField::operator==(), FIX::StringField::operator>(), FIX::StringField::operator>=(), and FIX::Message::setString().
00074 { return m_string; }
int FIX::FieldBase::getTotal | ( | ) | const [inline] |
const std::string& FIX::FieldBase::getValue | ( | ) | const [inline] |
Get the string representation of the Field (i.e.) 55=MSFT[SOH].
Reimplemented in FIX::StringField, FIX::CharField, FIX::DoubleField, FIX::IntField, FIX::BoolField, FIX::UtcTimeStampField, FIX::UtcDateField, FIX::UtcTimeOnlyField, and FIX::CheckSumField.
Definition at line 77 of file Field.h.
References calculate(), and m_data.
bool FIX::FieldBase::operator< | ( | const FieldBase & | field | ) | const [inline] |
Compares fields based on thier tag numbers.
Reimplemented in FIX::StringField, FIX::UtcTimeStampField, FIX::UtcDateField, and FIX::UtcTimeOnlyField.
Definition at line 98 of file Field.h.
References m_field.
00099 { return m_field < field.m_field; }
void FIX::FieldBase::setField | ( | int | field | ) | [inline] |
Definition at line 56 of file Field.h.
References m_calculated, and m_field.
00057 { 00058 m_field = field; 00059 m_calculated = false; 00060 }
void FIX::FieldBase::setString | ( | const std::string & | string | ) | [inline] |
Definition at line 62 of file Field.h.
References m_calculated, and m_string.
Referenced by FIX::StringField::setValue().
00063 { 00064 m_string = string; 00065 m_calculated = false; 00066 }
bool FIX::FieldBase::m_calculated [mutable, private] |
Definition at line 134 of file Field.h.
Referenced by calculate(), setField(), and setString().
std::string FIX::FieldBase::m_data [mutable, private] |
Definition at line 131 of file Field.h.
Referenced by calculate(), and getValue().
int FIX::FieldBase::m_field [private] |
Definition at line 129 of file Field.h.
Referenced by calculate(), getField(), operator<(), and setField().
int FIX::FieldBase::m_length [mutable, private] |
Definition at line 132 of file Field.h.
Referenced by calculate(), and getLength().
std::string FIX::FieldBase::m_string [private] |
Definition at line 130 of file Field.h.
Referenced by calculate(), getString(), and setString().
int FIX::FieldBase::m_total [mutable, private] |
Definition at line 133 of file Field.h.
Referenced by calculate(), and getTotal().