Index  Source Files  Annotated Class List  Alphabetical Class List  Class Hierarchy  Graphical Class Hierarchy   
 

FIX::FieldBase Class Reference

Base representation of all Field classes. More...

#include <Field.h>

Inheritance diagram for FIX::FieldBase:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 FieldBase (int field, const std::string &string, bool doCalculate=true)
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

Detailed Description

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.


Constructor & Destructor Documentation

FIX::FieldBase::FieldBase int  field,
const std::string &  string,
bool  doCalculate = true
[inline]
 

Definition at line 49 of file Field.h.

References m_calculated, m_field, m_length, m_string, and m_total.

00050     : m_field( field ), m_string(string), m_length( 0 ), m_total( 0 ),
00051       m_calculated( false )
00052   {}


Member Function Documentation

void FIX::FieldBase::calculate  )  const [inline, private]
 

Definition at line 100 of file Field.h.

References m_calculated, m_field, m_length, m_string, m_total, and STRING_SPRINTF.

Referenced by getLength(), getTotal(), and getValue().

00101   {
00102     if( m_calculated ) return;
00103 
00104     char buf[64];
00105 
00106     if( 13 + m_string.length() < sizeof(buf) )
00107     {
00108       int tagLength = STRING_SPRINTF( buf, "%d=", m_field );
00109       m_length = tagLength + m_string.length() + 1;
00110       memcpy( buf + tagLength, m_string.data(), m_string.length() );
00111       buf[m_length - 1] = '\001';
00112       m_data.assign( buf, m_length );
00113     }
00114     else
00115     {
00116       m_data = IntConvertor::convert(m_field) + "=" + m_string + "\001";
00117       m_length = m_data.length();
00118     }
00119 
00120     const unsigned char* iter =
00121       reinterpret_cast<const unsigned char*>( m_data.c_str() );
00122     m_total = std::accumulate( iter, iter + m_length, 0 );
00123 
00124     m_calculated = true;
00125   }

int FIX::FieldBase::getField  )  const [inline]
 

Get the fields integer tag.

Definition at line 67 of file Field.h.

References m_field.

Referenced by FIX::Message::isHeaderField(), FIX::FieldMap::isSetField(), FIX::Message::isTrailerField(), FIX::DataDictionary::iterate(), FIX::Message::setGroup(), FIX::Message::setString(), FIX::Message::setStringHeader(), and FIX::DataDictionary::shouldCheckTag().

00068     { return m_field; }

int FIX::FieldBase::getLength  )  const [inline]
 

Get the length of the fields string representation.

Definition at line 82 of file Field.h.

References calculate(), and m_length.

00083   {
00084     calculate();
00085     return m_length;
00086   }

const std::string& FIX::FieldBase::getString  )  const [inline]
 

Get the string representation of the fields value.

Definition at line 71 of file Field.h.

References m_string.

Referenced by 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().

00072     { return m_string; }

int FIX::FieldBase::getTotal  )  const [inline]
 

Get the total value the fields characters added together.

Definition at line 89 of file Field.h.

References calculate(), and m_total.

00090   {
00091     calculate();
00092     return m_total;
00093   }

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 75 of file Field.h.

References calculate().

00076   {
00077     calculate();
00078     return m_data;
00079   }

bool FIX::FieldBase::operator< const FieldBase field  )  const [inline]
 

Compares fields based on thier tag numbers.

Definition at line 96 of file Field.h.

References m_field.

00097     { return m_field < field.m_field; }

void FIX::FieldBase::setField int  field  )  [inline]
 

Definition at line 54 of file Field.h.

References m_calculated, and m_field.

00055   {
00056     m_field = field;
00057     m_calculated = false;
00058   }

void FIX::FieldBase::setString const std::string &  string  )  [inline]
 

Definition at line 60 of file Field.h.

References m_calculated, and m_string.

Referenced by FIX::StringField::setValue().

00061   {
00062     m_string = string;
00063     m_calculated = false;
00064   }


Member Data Documentation

bool FIX::FieldBase::m_calculated [mutable, private]
 

Definition at line 132 of file Field.h.

Referenced by calculate(), FieldBase(), setField(), and setString().

std::string FIX::FieldBase::m_data [mutable, private]
 

Definition at line 129 of file Field.h.

int FIX::FieldBase::m_field [private]
 

Definition at line 127 of file Field.h.

Referenced by calculate(), FieldBase(), getField(), operator<(), and setField().

int FIX::FieldBase::m_length [mutable, private]
 

Definition at line 130 of file Field.h.

Referenced by calculate(), FieldBase(), and getLength().

std::string FIX::FieldBase::m_string [private]
 

Definition at line 128 of file Field.h.

Referenced by calculate(), FieldBase(), getString(), and setString().

int FIX::FieldBase::m_total [mutable, private]
 

Definition at line 131 of file Field.h.

Referenced by calculate(), FieldBase(), and getTotal().


The documentation for this class was generated from the following file:
Generated on Mon Jul 24 19:36:41 2006 for QuickFIX by doxygen 1.3.6-20040222 written by Dimitri van Heesch, © 1997-2001