Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
FIX::FieldBase Class Reference

Base representation of all Field classes. More...

#include <Field.h>

Inheritance diagram for FIX::FieldBase:
Inheritance graph
[legend]

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. More...
 
const std::string & getString () const
 Get the string representation of the fields value. More...
 
const std::string & getFixString () const
 Get the string representation of the Field (i.e.) 55=MSFT[SOH]. More...
 
int getLength () const
 Get the length of the fields string representation. More...
 
int getTotal () const
 Get the total value the fields characters added together. More...
 
bool operator< (const FieldBase &field) const
 Compares fields based on thier tag numbers. More...
 

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
 

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 
)
inline

Definition at line 49 of file Field.h.

50  : m_field( field ), m_string(string), m_length( 0 ), m_total( 0 ),
51  m_calculated( false )
52  {}
std::string m_string
Definition: Field.h:125
int m_field
Definition: Field.h:124
int m_length
Definition: Field.h:127
bool m_calculated
Definition: Field.h:129
int m_total
Definition: Field.h:128
virtual FIX::FieldBase::~FieldBase ( )
inlinevirtual

Definition at line 54 of file Field.h.

54 {}

Member Function Documentation

void FIX::FieldBase::calculate ( ) const
inlineprivate

Definition at line 102 of file Field.h.

References FIX::integer_to_string(), m_calculated, m_data, m_field, m_length, m_string, m_total, and FIX::number_of_symbols_in().

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

103  {
104  if( m_calculated ) return;
105 
106  int tagLength = FIX::number_of_symbols_in( m_field ) + 1;
107  m_length = tagLength + m_string.length() + 1;
108 
109  m_data.resize( m_length );
110 
111  char * buf = (char*)m_data.c_str();
112  FIX::integer_to_string(buf, tagLength, m_field);
113 
114  buf[tagLength - 1] = '=';
115  memcpy( buf + tagLength, m_string.data(), m_string.length() );
116  buf[m_length - 1] = '\001';
117 
118  const unsigned char* iter = reinterpret_cast<const unsigned char*>( m_data.c_str() );
119  m_total = std::accumulate( iter, iter + m_length, 0 );
120 
121  m_calculated = true;
122  }
int number_of_symbols_in(const signed_int value)
char * integer_to_string(char *buf, const size_t len, signed_int t)
std::string m_string
Definition: Field.h:125
int m_field
Definition: Field.h:124
int m_length
Definition: Field.h:127
bool m_calculated
Definition: Field.h:129
std::string m_data
Definition: Field.h:126
int m_total
Definition: Field.h:128
int FIX::FieldBase::getField ( ) const
inline
const std::string& FIX::FieldBase::getFixString ( ) const
inline

Get the string representation of the Field (i.e.) 55=MSFT[SOH].

Definition at line 77 of file Field.h.

References calculate(), and m_data.

78  {
79  calculate();
80  return m_data;
81  }
std::string m_data
Definition: Field.h:126
void calculate() const
Definition: Field.h:102
int FIX::FieldBase::getLength ( ) const
inline

Get the length of the fields string representation.

Definition at line 84 of file Field.h.

References calculate(), and m_length.

85  {
86  calculate();
87  return m_length;
88  }
int m_length
Definition: Field.h:127
void calculate() const
Definition: Field.h:102
const std::string& FIX::FieldBase::getString ( ) const
inline
int FIX::FieldBase::getTotal ( ) const
inline

Get the total value the fields characters added together.

Definition at line 91 of file Field.h.

References calculate(), and m_total.

92  {
93  calculate();
94  return m_total;
95  }
int m_total
Definition: Field.h:128
void calculate() const
Definition: Field.h:102
bool FIX::FieldBase::operator< ( const FieldBase field) const
inline

Compares fields based on thier tag numbers.

Definition at line 98 of file Field.h.

References m_field.

99  { return m_field < field.m_field; }
int m_field
Definition: Field.h:124
void FIX::FieldBase::setField ( int  field)
inline

Definition at line 56 of file Field.h.

References m_calculated, and m_field.

57  {
58  m_field = field;
59  m_calculated = false;
60  }
int m_field
Definition: Field.h:124
bool m_calculated
Definition: Field.h:129
void FIX::FieldBase::setString ( const std::string &  string)
inline

Friends And Related Function Documentation

friend class Message
friend

Definition at line 47 of file Field.h.

Member Data Documentation

bool FIX::FieldBase::m_calculated
mutableprivate

Definition at line 129 of file Field.h.

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

std::string FIX::FieldBase::m_data
mutableprivate

Definition at line 126 of file Field.h.

Referenced by calculate(), and getFixString().

int FIX::FieldBase::m_field
private

Definition at line 124 of file Field.h.

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

int FIX::FieldBase::m_length
mutableprivate

Definition at line 127 of file Field.h.

Referenced by calculate(), and getLength().

std::string FIX::FieldBase::m_string
private

Definition at line 125 of file Field.h.

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

int FIX::FieldBase::m_total
mutableprivate

Definition at line 128 of file Field.h.

Referenced by calculate(), and getTotal().


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

Generated on Sat Mar 29 2014 15:13:34 for QuickFIX by doxygen 1.8.5 written by Dimitri van Heesch, © 1997-2001