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 tag, const std::string &string)
virtual | ~FieldBase ()
| FieldBase (const FieldBase &rhs)
FieldBase & | operator= (const FieldBase &rhs)
void | swap (FieldBase &rhs)
void | setTag (int tag)
void | setField (int field)
void | setString (const std::string &string)
int | getTag () const
| Get the fields integer tag. More...
int | getField () const
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 tag, 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_tag
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 66 of file Field.h.

## Constructor & Destructor Documentation

## FieldBase() [1/3]

FIX::FieldBase::FieldBase | ( | int | tag,
|  | 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 114 of file Field.h.

{
std::swap( m_tag, rhs.m_tag );
std::swap( m_metrics, rhs.m_metrics );
m_string.swap( rhs.m_string );
m_data.swap( rhs.m_data );
}

Referenced by FIX::UtcTimeStampField::getValue(), FIX::UtcDateField::getValue(), and FIX::UtcTimeOnlyField::getValue().

## FieldBase() [2/3]

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

inline

Definition at line 125 of file Field.h.

{

## ~FieldBase()

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

inline virtual

Definition at line 129 of file Field.h.

{

## FieldBase() [3/3]

FIX::FieldBase::FieldBase | ( | const FieldBase & | rhs | ) |

inline

Definition at line 131 of file Field.h.

{
setTag( field );
}
void setString( const std::string& string )
{

References setTag().

## Member Function Documentation

## calculate()

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

inline private

Definition at line 218 of file Field.h.

Referenced by setField(), and setString().

## calculateMetrics() [1/2]

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

inline static private

Definition at line 264 of file Field.h.

: FieldBase( field, "" ) {}
void setValue( const std::string& value )
{ setString( value ); }

## calculateMetrics() [2/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 247 of file Field.h.

{
lhs.swap( rhs );
}
class StringField : public FieldBase
{
public:
explicit StringField( int field, const std::string& data )
: FieldBase( field, data ) {}

## encodeTo()

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

inline private

Serializes string representation of the Field to input string.

Definition at line 226 of file Field.h.

{
return calculateMetrics( field.begin(), field.end() );
}
int m_tag;
std::string m_string;
mutable std::string m_data;
mutable field_metrics m_metrics;
};

Referenced by setTag().

## getField()

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

inline

Deprecated:
  Use getTag

Definition at line 182 of file Field.h.

:

## getFixString()

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

inline

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

Definition at line 190 of file Field.h.

{
size_t tagLength = FIX::number_of_symbols_in( m_tag );
size_t totalLength = tagLength + m_string.length() + 2;

References m_string, m_tag, and FIX::number_of_symbols_in().

## getLength()

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

inline

Get the length of the fields string representation.

Definition at line 199 of file Field.h.

{

## getString()

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

inline

Get the string representation of the fields value.

Definition at line 186 of file Field.h.

Referenced by FIX::BoolField::operator bool(), FIX::CharField::operator char(), FIX::IntField::operator const int(), FIX::DoubleField::operator double(), FIX::UtcTimeStampField::operator!=(), FIX::UtcDateField::operator!=(), FIX::UtcTimeOnlyField::operator!=(), FIX::operator>=(), FIX::StringField::setValue(), and FIX::StringField::StringField().

## getTag()

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

inline

Get the fields integer tag.

Definition at line 178 of file Field.h.

{ return m_tag < field.m_tag; }

Referenced by FIX::DataDictionary::iterate(), FIX::operator>=(), swap(), and FIX::DataDictionary::validate().

## getTotal()

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

inline

Get the total value the fields characters added together.

Definition at line 206 of file Field.h.

{
return field_metrics( 0, 0 );
}

## no_metrics()

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

inline static private

Definition at line 241 of file Field.h.

{

## operator<()

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

inline

Compares fields based on their tag numbers.

Definition at line 213 of file Field.h.

## operator=()

FieldBase& FIX::FieldBase::operator= | ( | const FieldBase & | rhs | ) |

inline

Definition at line 139 of file Field.h.

{ return m_tag; }

## setField()

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

inline

Deprecated:
  Use setTag

Definition at line 165 of file Field.h.

{
calculate();
return m_metrics.getLength();

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

## setString()

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

inline

Definition at line 170 of file Field.h.

{
calculate();
return m_metrics.getCheckSum();

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

Referenced by FIX::CharField::getValue(), FIX::DoubleField::getValue(), FIX::IntField::getValue(), FIX::BoolField::getValue(), FIX::UtcTimeStampField::operator<(), FIX::UtcDateField::operator<(), FIX::UtcTimeOnlyField::operator<(), FIX::operator<=(), and FIX::swap().

## setTag()

void FIX::FieldBase::setTag | ( | int | tag | ) |

inline

Definition at line 157 of file Field.h.

{
if( m_data.empty() )
encodeTo( m_data );
return m_data;
}

References encodeTo(), and m_data.

Referenced by FieldBase().

## swap()

void FIX::FieldBase::swap | ( | FieldBase & | rhs | ) |

inline

Definition at line 149 of file Field.h.

{ return getTag(); }
const std::string& getString() const
{ return m_string; }

References getTag().

## Friends And Related Function Documentation

## Message

friend class Message

friend

Definition at line 111 of file Field.h.

## Member Data Documentation

## m_data

std::string FIX::FieldBase::m_data

mutable private

Definition at line 271 of file Field.h.

Referenced by setTag().

## m_metrics

field_metrics FIX::FieldBase::m_metrics

mutable private

Definition at line 272 of file Field.h.

Referenced by FIX::FieldBase::field_metrics::getCheckSum(), setField(), and setString().

## m_string

std::string FIX::FieldBase::m_string

private

Definition at line 270 of file Field.h.

Referenced by getFixString().

## m_tag

int FIX::FieldBase::m_tag

private

Definition at line 269 of file Field.h.

Referenced by FIX::FieldBase::field_metrics::getCheckSum(), and getFixString().

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

- Field.h

FIX::FieldBase::m_data
std::string m_data
Definition: Field.h:271
FIX::number_of_symbols_in
int number_of_symbols_in(const signed_int value)
Definition: FieldConvertors.h:68
FIX::FieldBase::m_string
std::string m_string
Definition: Field.h:270
swap
void swap(T &lhs, T &rhs)
Definition: pugixml.cpp:5991
FIX::FieldBase::encodeTo
void encodeTo(std::string &result) const
Serializes string representation of the Field to input string.
Definition: Field.h:226
FIX::FieldBase::setTag
void setTag(int tag)
Definition: Field.h:157
FIX::FieldBase::getTag
int getTag() const
Get the fields integer tag.
Definition: Field.h:178
FIX::FieldBase::m_tag
int m_tag
Definition: Field.h:269
FIX::FieldBase::setString
void setString(const std::string &string)
Definition: Field.h:170
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:247
FIX::FieldBase::m_metrics
field_metrics m_metrics
Definition: Field.h:272
FIX::FieldBase::field_metrics::getLength
size_t getLength() const
Definition: Field.h:113
FIX::FieldBase::calculate
void calculate() const
Definition: Field.h:218
FIX::FieldBase::FieldBase
FieldBase(int tag, 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.
Definition: Field.h:114
FIX::FieldBase::field_metrics::getCheckSum
int getCheckSum() const
Definition: Field.h:116
FIX::FieldBase::getString
const std::string & getString() const
Get the string representation of the fields value.
Definition: Field.h:186