FIX::Dictionary Class Reference

For storage and retrieval of key/value pairs. More...

`#include <Dictionary.h>`

## Public Types

typedef std::map< std::string, std::string > | Data
typedef Data::const_iterator | iterator
typedef iterator | const_iterator

## Public Member Functions

| Dictionary (const std::string &name)
| Dictionary ()
virtual | ~Dictionary ()
std::string | getName () const
| Get the name of the dictionary. More...
size_t | size () const
| Return the number of key/value pairs. More...
std::string | getString (const std::string &, bool capitalize=false) const throw ( ConfigError, FieldConvertError )
| Get a value as a string. More...
int | getInt (const std::string &) const throw ( ConfigError, FieldConvertError )
| Get a value as a int. More...
double | getDouble (const std::string &) const throw ( ConfigError, FieldConvertError )
| Get a value as a double. More...
bool | getBool (const std::string &) const throw ( ConfigError, FieldConvertError )
| Get a value as a bool. More...
int | getDay (const std::string &) const throw ( ConfigError, FieldConvertError )
| Get a value as a day of week. More...
void | setString (const std::string &, const std::string &)
| Set a value from a string. More...
void | setInt (const std::string &, int)
| Set a value from a int. More...
void | setDouble (const std::string &, double)
| Set a value from a double. More...
void | setBool (const std::string &, bool)
| Set a value from a bool. More...
void | setDay (const std::string &, int)
| Set a value from a day. More...
bool | has (const std::string &) const
| Check if the dictionary contains a value for key. More...
void | merge (const Dictionary &)
| Merge two dictionaries. More...
iterator | begin () const
iterator | end () const

## Private Attributes

Data | m_data
std::string | m_name

## Detailed Description

For storage and retrieval of key/value pairs.

Definition at line 53 of file Dictionary.h.

## Member Typedef Documentation

## const_iterator

typedef iterator FIX::Dictionary::const_iterator

Definition at line 79 of file Dictionary.h.

## Data

typedef std::map< std::string, std::string > FIX::Dictionary::Data

Definition at line 77 of file Dictionary.h.

## iterator

typedef Data::const_iterator FIX::Dictionary::iterator

Definition at line 78 of file Dictionary.h.

## Constructor & Destructor Documentation

## Dictionary() [1/2]

FIX::Dictionary::Dictionary | ( | const std::string & | name | ) |

inline

Definition at line 73 of file Dictionary.h.

## Dictionary() [2/2]

FIX::Dictionary::Dictionary | ( |  | ) |

inline

Definition at line 74 of file Dictionary.h.

## ~Dictionary()

virtual FIX::Dictionary::~Dictionary | ( |  | ) |

inline virtual

Definition at line 75 of file Dictionary.h.

## Member Function Documentation

## begin()

iterator FIX::Dictionary::begin | ( |  | ) | const

inline

Definition at line 118 of file Dictionary.h.

## end()

iterator FIX::Dictionary::end | ( |  | ) | const

inline

Definition at line 119 of file Dictionary.h.

## getBool()

bool FIX::Dictionary::getBool | ( | const std::string & | key | ) | const
throw | ( | ConfigError,
|  | FieldConvertError
| ) |  |

Get a value as a bool.

Definition at line 88 of file Dictionary.cpp.

{
std::string value = getString(key);
if( value.size() < 2 ) throw FieldConvertError();
std::string abbr = value.substr(0, 2);
std::transform( abbr.begin(), abbr.end(), abbr.begin(), tolower );
if( abbr == "su" ) return 1;
if( abbr == "mo" ) return 2;
if( abbr == "tu" ) return 3;
if( abbr == "we" ) return 4;
if( abbr == "th" ) return 5;
if( abbr == "fr" ) return 6;
if( abbr == "sa" ) return 7;

Referenced by FIX::ThreadedSocketAcceptor::ThreadedSocketAcceptor(), and FIX::ThreadedSocketInitiator::ThreadedSocketInitiator().

## getDay()

int FIX::Dictionary::getDay | ( | const std::string & | key | ) | const
throw | ( | ConfigError,
|  | FieldConvertError
| ) |  |

Get a value as a day of week.

Definition at line 101 of file Dictionary.cpp.

{
throw ConfigError( "Illegal value " + getString(key) + " for " + key );
}
return -1;
}
void Dictionary::setString( const std::string& key, const std::string& value )
{
m_data[ string_strip(string_toUpper(key)) ] = string_strip(value);
}
void Dictionary::setInt( const std::string& key, int value )
{
m_data[ string_strip(string_toUpper(key)) ] = IntConvertor::convert( value );
}
void Dictionary::setDouble( const std::string& key, double value )
{
m_data[ string_strip(string_toUpper(key)) ] = DoubleConvertor::convert( value );
}
void Dictionary::setBool( const std::string& key, bool value )

## getDouble()

double FIX::Dictionary::getDouble | ( | const std::string & | key | ) | const
throw | ( | ConfigError,
|  | FieldConvertError
| ) |  |

Get a value as a double.

Definition at line 75 of file Dictionary.cpp.

{
return BoolConvertor::convert( getString(key) );
}
catch ( FieldConvertError& )
{
throw ConfigError( "Illegal value " + getString(key) + " for " + key );
}
}
int Dictionary::getDay( const std::string& key ) const
throw( ConfigError, FieldConvertError )
{

References FIX::BoolConvertor::convert().

## getInt()

int FIX::Dictionary::getInt | ( | const std::string & | key | ) | const
throw | ( | ConfigError,
|  | FieldConvertError
| ) |  |

Get a value as a int.

Definition at line 62 of file Dictionary.cpp.

{
return DoubleConvertor::convert( getString(key) );
}
catch ( FieldConvertError& )
{
throw ConfigError( "Illegal value " + getString(key) + " for " + key );
}
}
bool Dictionary::getBool( const std::string& key ) const
throw( ConfigError, FieldConvertError )
{

References FIX::DoubleConvertor::convert().

Referenced by FIX::SocketInitiator::getHost(), FIX::SocketAcceptor::onConfigure(), FIX::ThreadedSocketAcceptor::onConfigure(), FIX::SocketAcceptor::SocketAcceptor(), FIX::ThreadedSocketAcceptor::ThreadedSocketAcceptor(), and FIX::ThreadedSocketInitiator::ThreadedSocketInitiator().

## getName()

std::string FIX::Dictionary::getName | ( |  | ) | const

inline

Get the name of the dictionary.

Definition at line 82 of file Dictionary.h.

{ return m_data.begin(); }

## getString()

std::string FIX::Dictionary::getString | ( | const std::string & | key,
|  | bool | capitalize = `false`
| ) |  | const
throw | ( | ConfigError,
|  | FieldConvertError
| ) |  |

Get a value as a string.

Definition at line 49 of file Dictionary.cpp.

{
return IntConvertor::convert( getString(key) );
}
catch ( FieldConvertError& )
{
throw ConfigError( "Illegal value " + getString(key) + " for " + key );
}
}
double Dictionary::getDouble( const std::string& key ) const
throw( ConfigError, FieldConvertError )
{

References FIX::IntConvertor::convert().

Referenced by FIX::Acceptor::Acceptor(), FIX::SocketInitiator::getHost(), and FIX::operator>>().

## has()

bool FIX::Dictionary::has | ( | const std::string & | key | ) | const

Check if the dictionary contains a value for key.

Definition at line 166 of file Dictionary.cpp.

Referenced by FIX::SocketInitiator::getHost(), FIX::SocketAcceptor::onConfigure(), FIX::operator>>(), FIX::SocketAcceptor::SocketAcceptor(), FIX::ThreadedSocketAcceptor::ThreadedSocketAcceptor(), and FIX::ThreadedSocketInitiator::ThreadedSocketInitiator().

## merge()

void FIX::Dictionary::merge | ( | const Dictionary & | toMerge | ) |

Merge two dictionaries.

Definition at line 171 of file Dictionary.cpp.

Referenced by FIX::operator>>().

## setBool()

void FIX::Dictionary::setBool | ( | const std::string & | key,
|  | bool | value
| ) |  |

Set a value from a bool.

Definition at line 140 of file Dictionary.cpp.

:
setString( key, "TH" ); break;
case 6:
setString( key, "FR" ); break;

## setDay()

void FIX::Dictionary::setDay | ( | const std::string & | key,
|  | int | value
| ) |  |

Set a value from a day.

Definition at line 145 of file Dictionary.cpp.

{
return m_data.find( string_toUpper(key) ) != m_data.end();
}
void Dictionary::merge( const Dictionary& toMerge )
{
Data::const_iterator i = toMerge.m_data.begin();
for ( ; i != toMerge.m_data.end(); ++i )
if ( m_data.find( i->first ) == m_data.end() )
m_data[ i->first ] = i->second;
}
}

## setDouble()

void FIX::Dictionary::setDouble | ( | const std::string & | key,
|  | double | value
| ) |  |

Set a value from a double.

Definition at line 135 of file Dictionary.cpp.

:
setString( key, "TU" ); break;
case 4:

## setInt()

void FIX::Dictionary::setInt | ( | const std::string & | key,
|  | int | value
| ) |  |

Set a value from a int.

Definition at line 130 of file Dictionary.cpp.

{
case 1:
setString( key, "SU" ); break;

References setString().

## setString()

void FIX::Dictionary::setString | ( | const std::string & | key,
|  | const std::string & | value
| ) |  |

Set a value from a string.

Definition at line 125 of file Dictionary.cpp.

{

Referenced by setInt().

## size()

size_t FIX::Dictionary::size | ( |  | ) | const

inline

Return the number of key/value pairs.

Definition at line 84 of file Dictionary.h.

{ return m_data.begin(); }

References m_data.

## Member Data Documentation

## m_data

Data FIX::Dictionary::m_data

private

Definition at line 122 of file Dictionary.h.

Referenced by size().

## m_name

std::string FIX::Dictionary::m_name

private

Definition at line 123 of file Dictionary.h.

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

- Dictionary.h
- Dictionary.cpp

FIX::string_toUpper
std::string string_toUpper(const std::string &value)
Definition: Utility.cpp:70
FIX::Dictionary::getString
std::string getString(const std::string &, bool capitalize=false) const
Get a value as a string.
Definition: Dictionary.cpp:49
FIX::Dictionary::m_data
Data m_data
Definition: Dictionary.h:122
FIX::string_strip
std::string string_strip(const std::string &value)
Definition: Utility.cpp:84
FIX::Dictionary::setDouble
void setDouble(const std::string &, double)
Set a value from a double.
Definition: Dictionary.cpp:135
FIX::IntConvertor::convert
static std::string convert(signed_int value)
Definition: FieldConvertors.h:170
FIX::Dictionary::getDouble
double getDouble(const std::string &) const
Get a value as a double.
Definition: Dictionary.cpp:75
FIX::Dictionary::getDay
int getDay(const std::string &) const
Get a value as a day of week.
Definition: Dictionary.cpp:101
FIX::Dictionary::getBool
bool getBool(const std::string &) const
Get a value as a bool.
Definition: Dictionary.cpp:88
FIX::Dictionary::merge
void merge(const Dictionary &)
Merge two dictionaries.
Definition: Dictionary.cpp:171
FIX::BoolConvertor::convert
static std::string convert(bool value)
Definition: FieldConvertors.h:418
FIX::Dictionary::setString
void setString(const std::string &, const std::string &)
Set a value from a string.
Definition: Dictionary.cpp:125
FIX::Dictionary::Dictionary
Dictionary()
Definition: Dictionary.h:74
FIX::Dictionary::setBool
void setBool(const std::string &, bool)
Set a value from a bool.
Definition: Dictionary.cpp:140
FIX::DoubleConvertor::convert
static std::string convert(double value, int padding=0)
Definition: FieldConvertors.h:272
FIX::Dictionary::setInt
void setInt(const std::string &, int)
Set a value from a int.
Definition: Dictionary.cpp:130