Public Types | Public Member Functions | Private Attributes | List of all members
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

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 ( )
inlinevirtual

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.

88  {
89  std::string value = getString(key);
90  if( value.size() < 2 ) throw FieldConvertError();
91  std::string abbr = value.substr(0, 2);
92  std::transform( abbr.begin(), abbr.end(), abbr.begin(), tolower );
93  if( abbr == "su" ) return 1;
94  if( abbr == "mo" ) return 2;
95  if( abbr == "tu" ) return 3;
96  if( abbr == "we" ) return 4;
97  if( abbr == "th" ) return 5;
98  if( abbr == "fr" ) return 6;
99  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.

102  {
103  throw ConfigError( "Illegal value " + getString(key) + " for " + key );
104  }
105  return -1;
106 }
107 
108 void Dictionary::setString( const std::string& key, const std::string& value )
109 {
111 }
112 
113 void Dictionary::setInt( const std::string& key, int value )
114 {
116 }
117 
118 void Dictionary::setDouble( const std::string& key, double value )
119 {
121 }
122 
123 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.

75  {
76  return BoolConvertor::convert( getString(key) );
77  }
78  catch ( FieldConvertError& )
79  {
80  throw ConfigError( "Illegal value " + getString(key) + " for " + key );
81  }
82 }
83 
84 int Dictionary::getDay( const std::string& key ) const
85 throw( ConfigError, FieldConvertError )
86 {

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.

62  {
63  return DoubleConvertor::convert( getString(key) );
64  }
65  catch ( FieldConvertError& )
66  {
67  throw ConfigError( "Illegal value " + getString(key) + " for " + key );
68  }
69 }
70 
71 bool Dictionary::getBool( const std::string& key ) const
72 throw( ConfigError, FieldConvertError )
73 {

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.

84 { 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.

49  {
50  return IntConvertor::convert( getString(key) );
51  }
52  catch ( FieldConvertError& )
53  {
54  throw ConfigError( "Illegal value " + getString(key) + " for " + key );
55  }
56 }
57 
58 double Dictionary::getDouble( const std::string& key ) const
59 throw( ConfigError, FieldConvertError )
60 {

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

◆ 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.

140  :
141  setString( key, "TH" ); break;
142  case 6:
143  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.

150 {
151  return m_data.find( string_toUpper(key) ) != m_data.end();
152 }
153 
154 void Dictionary::merge( const Dictionary& toMerge )
155 {
156  Data::const_iterator i = toMerge.m_data.begin();
157  for ( ; i != toMerge.m_data.end(); ++i )
158  if ( m_data.find( i->first ) == m_data.end() )
159  m_data[ i->first ] = i->second;
160 }
161 }

◆ 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.

136  :
137  setString( key, "TU" ); break;
138  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.

131  {
132  case 1:
133  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.

129 {

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.

84 { 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:
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

Generated on Wed Apr 29 2020 19:41:30 for QuickFIX by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2001