FIX::FieldBase Class Reference

Base representation of all Field classes. More...

`#include <Field.h>`

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

## Classes

class | field_metrics
| Class used to store field metrics like total length and checksum. More...

## 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...
size_t | 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 their tag numbers. More...

## Private Member Functions

| FieldBase (int field, std::string::const_iterator valueStart, std::string::const_iterator valueEnd, std::string::const_iterator tagStart, std::string::const_iterator tagEnd)
| Constructor which also calculates field metrics. More...
void | calculate () const
void | encodeTo (std::string &result) const
| Serializes string representation of the Field to input string. More...

## Static Private Member Functions

static field_metrics | no_metrics ()
static field_metrics | calculateMetrics (std::string::const_iterator const start, std::string::const_iterator const end)
| Calculate metrics for any input string. More...
static field_metrics | calculateMetrics (const std::string &field)

## Private Attributes

int | m_field
std::string | m_string
std::string | m_data
field_metrics | m_metrics

## 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

## FieldBase() [1/2]

FIX::FieldBase::FieldBase | ( | int | field,
|  | std::string::const_iterator | valueStart,
|  | std::string::const_iterator | valueEnd,
|  | std::string::const_iterator | tagStart,
|  | std::string::const_iterator | tagEnd
| ) |  |

inline private

Constructor which also calculates field metrics.

Definition at line 76 of file Field.h.

: m_field( field )
, m_string( valueStart, valueEnd )
, m_metrics( calculateMetrics( tagStart, tagEnd ) )
{}
FIX::FieldBase::calculateMetrics
static field_metrics calculateMetrics(std::string::const_iterator const start, std::string::const_iterator const end)
Calculate metrics for any input string.
Definition: Field.h:173
FIX::FieldBase::m_string
std::string m_string
Definition: Field.h:190
FIX::FieldBase::m_field
int m_field
Definition: Field.h:189
FIX::FieldBase::m_metrics
field_metrics m_metrics
Definition: Field.h:192

## FieldBase() [2/2]

FIX::FieldBase::FieldBase | ( | int | field,
|  | const std::string & | string
| ) |  |

inline

Definition at line 87 of file Field.h.

: m_field( field ), m_string(string), m_metrics( no_metrics() )
{}
FIX::FieldBase::m_string
std::string m_string
Definition: Field.h:190
FIX::FieldBase::m_field
int m_field
Definition: Field.h:189
FIX::FieldBase::m_metrics
field_metrics m_metrics
Definition: Field.h:192
FIX::FieldBase::no_metrics
static field_metrics no_metrics()
Definition: Field.h:167

## ~FieldBase()

virtual FIX::FieldBase::~FieldBase | ( |  | ) |

inline virtual

Definition at line 91 of file Field.h.

{}

## Member Function Documentation

## calculate()

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

inline private

Definition at line 144 of file Field.h.

References calculateMetrics(), getFixString(), FIX::FieldBase::field_metrics::isValid(), and m_metrics.

Referenced by getLength(), and getTotal().

{
if( m_metrics.isValid() ) return;
m_metrics = calculateMetrics( getFixString() );
}
FIX::FieldBase::calculateMetrics
static field_metrics calculateMetrics(std::string::const_iterator const start, std::string::const_iterator const end)
Calculate metrics for any input string.
Definition: Field.h:173
FIX::FieldBase::getFixString
const std::string & getFixString() const
Get the string representation of the Field (i.e.) 55=MSFT[SOH].
Definition: Field.h:116
FIX::FieldBase::m_metrics
field_metrics m_metrics
Definition: Field.h:192
FIX::FieldBase::field_metrics::isValid
bool isValid() const
Definition: Field.h:64

## calculateMetrics() [1/2]

static field_metrics FIX::FieldBase::calculateMetrics | ( | std::string::const_iterator const | start,
|  | std::string::const_iterator const | end
| ) |  |

inline static private

Calculate metrics for any input string.

Definition at line 173 of file Field.h.

References FIX::FieldBase::field_metrics::field_metrics().

Referenced by calculate(), and calculateMetrics().

{
int checksum = 0;
for ( std::string::const_iterator str = start; str != end; ++str )
checksum += (unsigned char)( *str );
return field_metrics( std::distance( start, end ), checksum );
}

## calculateMetrics() [2/2]

static field_metrics FIX::FieldBase::calculateMetrics | ( | const std::string & | field | ) |

inline static private

Definition at line 184 of file Field.h.

References calculateMetrics().

{
return calculateMetrics( field.begin(), field.end() );
}
FIX::FieldBase::calculateMetrics
static field_metrics calculateMetrics(std::string::const_iterator const start, std::string::const_iterator const end)
Calculate metrics for any input string.
Definition: Field.h:173

## encodeTo()

void FIX::FieldBase::encodeTo | ( | std::string & | result | ) | const

inline private

Serializes string representation of the Field to input string.

Definition at line 152 of file Field.h.

References FIX::integer_to_string(), m_field, m_string, and FIX::number_of_symbols_in().

Referenced by getFixString().

{
size_t tagLength = FIX::number_of_symbols_in( m_field ) + 1;
size_t totalLength = tagLength + m_string.length() + 1;
result.resize( totalLength );
char * buf = (char*)result.c_str();
FIX::integer_to_string( buf, tagLength, m_field );
buf[tagLength - 1] = '=';
memcpy( buf + tagLength, m_string.data(), m_string.length() );
buf[totalLength - 1] = '\001';
}
FIX::number_of_symbols_in
int number_of_symbols_in(const signed_int value)
Definition: FieldConvertors.h:45
FIX::integer_to_string
char * integer_to_string(char *buf, const size_t len, signed_int t)
Definition: FieldConvertors.h:93
FIX::FieldBase::m_string
std::string m_string
Definition: Field.h:190
FIX::FieldBase::m_field
int m_field
Definition: Field.h:189

## getField()

int FIX::FieldBase::getField | ( |  | ) | const

inline

Get the fields integer tag.

Definition at line 108 of file Field.h.

References m_field.

Referenced by FIX::DataDictionary::checkGroupCount(), FIX::DataDictionary::checkIsInMessage(), FIX::FieldMap::getFieldIfSet(), FIX::CharField::getValue(), FIX::DoubleField::getValue(), FIX::IntField::getValue(), FIX::BoolField::getValue(), FIX::UtcTimeStampField::getValue(), FIX::UtcDateField::getValue(), FIX::UtcTimeOnlyField::getValue(), FIX::CheckSumField::getValue(), 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().

{ return m_field; }
FIX::FieldBase::m_field
int m_field
Definition: Field.h:189

## getFixString()

const std::string& FIX::FieldBase::getFixString | ( |  | ) | const

inline

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

Definition at line 116 of file Field.h.

References encodeTo(), and m_data.

Referenced by calculate().

{
if( m_data.empty() )
encodeTo( m_data );
return m_data;
}
FIX::FieldBase::encodeTo
void encodeTo(std::string &result) const
Serializes string representation of the Field to input string.
Definition: Field.h:152
FIX::FieldBase::m_data
std::string m_data
Definition: Field.h:191

## getLength()

size_t FIX::FieldBase::getLength | ( |  | ) | const

inline

Get the length of the fields string representation.

Definition at line 125 of file Field.h.

References calculate(), FIX::FieldBase::field_metrics::getLength(), and m_metrics.

{
calculate();
return m_metrics.getLength();
}
FIX::FieldBase::field_metrics::getLength
size_t getLength() const
Definition: Field.h:58
FIX::FieldBase::calculate
void calculate() const
Definition: Field.h:144
FIX::FieldBase::m_metrics
field_metrics m_metrics
Definition: Field.h:192

## getString()

const std::string& FIX::FieldBase::getString | ( |  | ) | const

inline

Get the string representation of the fields value.

Definition at line 112 of file Field.h.

References m_string.

Referenced by FIX::DataDictionary::checkGroupCount(), FIX::FieldMap::getField(), FIX::StringField::getValue(), FIX::CharField::getValue(), FIX::DoubleField::getValue(), FIX::IntField::getValue(), FIX::BoolField::getValue(), FIX::UtcTimeStampField::getValue(), FIX::UtcDateField::getValue(), FIX::UtcTimeOnlyField::getValue(), FIX::CheckSumField::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().

{ return m_string; }
FIX::FieldBase::m_string
std::string m_string
Definition: Field.h:190

## getTotal()

int FIX::FieldBase::getTotal | ( |  | ) | const

inline

Get the total value the fields characters added together.

Definition at line 132 of file Field.h.

References calculate(), FIX::FieldBase::field_metrics::getCheckSum(), and m_metrics.

{
calculate();
return m_metrics.getCheckSum();
}
FIX::FieldBase::calculate
void calculate() const
Definition: Field.h:144
FIX::FieldBase::m_metrics
field_metrics m_metrics
Definition: Field.h:192
FIX::FieldBase::field_metrics::getCheckSum
int getCheckSum() const
Definition: Field.h:61

## no_metrics()

static field_metrics FIX::FieldBase::no_metrics | ( |  | ) |

inline static private

Definition at line 167 of file Field.h.

References FIX::FieldBase::field_metrics::field_metrics().

Referenced by setField(), and setString().

{
return field_metrics( 0, 0 );
}

## operator<()

bool FIX::FieldBase::operator< | ( | const FieldBase & | field | ) | const

inline

Compares fields based on their tag numbers.

Definition at line 139 of file Field.h.

References m_field.

Referenced by FIX::StringField::operator>=().

{ return m_field < field.m_field; }
FIX::FieldBase::m_field
int m_field
Definition: Field.h:189

## setField()

void FIX::FieldBase::setField | ( | int | field | ) |

inline

Definition at line 93 of file Field.h.

References m_data, m_field, m_metrics, and no_metrics().

{
m_field = field;
m_metrics = no_metrics();
m_data.clear();
}
FIX::FieldBase::m_field
int m_field
Definition: Field.h:189
FIX::FieldBase::m_metrics
field_metrics m_metrics
Definition: Field.h:192
FIX::FieldBase::no_metrics
static field_metrics no_metrics()
Definition: Field.h:167
FIX::FieldBase::m_data
std::string m_data
Definition: Field.h:191

## setString()

void FIX::FieldBase::setString | ( | const std::string & | string | ) |

inline

Definition at line 100 of file Field.h.

References m_data, m_metrics, m_string, and no_metrics().

Referenced by FIX::StringField::setValue(), FIX::CharField::setValue(), FIX::DoubleField::setValue(), FIX::IntField::setValue(), FIX::BoolField::setValue(), FIX::UtcTimeStampField::setValue(), FIX::UtcDateField::setValue(), FIX::UtcTimeOnlyField::setValue(), and FIX::CheckSumField::setValue().

{
m_string = string;
m_metrics = no_metrics();
m_data.clear();
}
FIX::FieldBase::m_string
std::string m_string
Definition: Field.h:190
FIX::FieldBase::m_metrics
field_metrics m_metrics
Definition: Field.h:192
FIX::FieldBase::no_metrics
static field_metrics no_metrics()
Definition: Field.h:167
FIX::FieldBase::m_data
std::string m_data
Definition: Field.h:191

## Friends And Related Function Documentation

## Message

friend class Message

friend

Definition at line 73 of file Field.h.

## Member Data Documentation

## m_data

std::string FIX::FieldBase::m_data

mutable private

Definition at line 191 of file Field.h.

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

## m_field

int FIX::FieldBase::m_field

private

Definition at line 189 of file Field.h.

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

## m_metrics

field_metrics FIX::FieldBase::m_metrics

mutable private

Definition at line 192 of file Field.h.

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

## m_string

std::string FIX::FieldBase::m_string

private

Definition at line 190 of file Field.h.

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

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

- Field.h