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 51 of file Dictionary.h.

Member Typedef Documentation

◆ const_iterator

Definition at line 76 of file Dictionary.h.

◆ Data

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

Definition at line 74 of file Dictionary.h.

◆ iterator

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

Definition at line 75 of file Dictionary.h.

Constructor & Destructor Documentation

◆ Dictionary() [1/2]

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

Definition at line 70 of file Dictionary.h.

◆ Dictionary() [2/2]

FIX::Dictionary::Dictionary ( )
inline

Definition at line 71 of file Dictionary.h.

◆ ~Dictionary()

virtual FIX::Dictionary::~Dictionary ( )
inlinevirtual

Definition at line 72 of file Dictionary.h.

Member Function Documentation

◆ begin()

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

Definition at line 115 of file Dictionary.h.

Referenced by FIX::operator<<().

◆ end()

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

Definition at line 116 of file Dictionary.h.

Referenced by FIX::operator<<().

◆ getBool()

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

Get a value as a bool.

Definition at line 86 of file Dictionary.cpp.

86 {
87  try
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;

Referenced by FIX::ThreadedSocketAcceptor::ThreadedSocketAcceptor().

◆ getDay()

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

Get a value as a day of week.

Definition at line 99 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 }

◆ getDouble()

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

Get a value as a double.

Definition at line 73 of file Dictionary.cpp.

73 {
74  try
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

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 60 of file Dictionary.cpp.

60 {
61  try
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

References FIX::DoubleConvertor::convert().

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

◆ getName()

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

Get the name of the dictionary.

Definition at line 79 of file Dictionary.h.

◆ 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 47 of file Dictionary.cpp.

47 {
48  try
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

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 164 of file Dictionary.cpp.

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

◆ merge()

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

Merge two dictionaries.

Definition at line 169 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 138 of file Dictionary.cpp.

138  :
139  setString( key, "WE" ); break;
140  case 5:
141  setString( key, "TH" ); break;

◆ setDay()

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

Set a value from a day.

Definition at line 143 of file Dictionary.cpp.

144  :
145  setString( key, "SA" ); break;
146  }
147 }
148 
149 bool Dictionary::has( const std::string& key ) const
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 133 of file Dictionary.cpp.

134  :
135  setString( key, "MO" ); break;
136  case 3:

◆ setInt()

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

Set a value from a int.

Definition at line 128 of file Dictionary.cpp.

129 {
130  switch( value )
131  {

◆ setString()

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

Set a value from a string.

Definition at line 123 of file Dictionary.cpp.

124 {
126 }

References FIX::BoolConvertor::convert(), m_data, FIX::string_strip(), and FIX::string_toUpper().

◆ size()

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

Return the number of key/value pairs.

Definition at line 81 of file Dictionary.h.

84 { return m_data.begin(); }

Referenced by FIX::operator<<().

Member Data Documentation

◆ m_data

Data FIX::Dictionary::m_data
private

Definition at line 119 of file Dictionary.h.

Referenced by setString().

◆ m_name

std::string FIX::Dictionary::m_name
private

Definition at line 120 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:68
FIX::Dictionary::getString
std::string getString(const std::string &, bool capitalize=false) const
Get a value as a string.
Definition: Dictionary.cpp:47
FIX::Dictionary::m_data
Data m_data
Definition: Dictionary.h:119
FIX::string_strip
std::string string_strip(const std::string &value)
Definition: Utility.cpp:82
FIX::Dictionary::setDouble
void setDouble(const std::string &, double)
Set a value from a double.
Definition: Dictionary.cpp:133
FIX::IntConvertor::convert
static std::string convert(signed_int value)
Definition: FieldConvertors.h:168
FIX::Dictionary::getDouble
double getDouble(const std::string &) const
Get a value as a double.
Definition: Dictionary.cpp:73
FIX::Dictionary::has
bool has(const std::string &) const
Check if the dictionary contains a value for key.
Definition: Dictionary.cpp:164
FIX::Dictionary::getDay
int getDay(const std::string &) const
Get a value as a day of week.
Definition: Dictionary.cpp:99
FIX::Dictionary::getBool
bool getBool(const std::string &) const
Get a value as a bool.
Definition: Dictionary.cpp:86
FIX::Dictionary::merge
void merge(const Dictionary &)
Merge two dictionaries.
Definition: Dictionary.cpp:169
FIX::BoolConvertor::convert
static std::string convert(bool value)
Definition: FieldConvertors.h:416
FIX::Dictionary::setString
void setString(const std::string &, const std::string &)
Set a value from a string.
Definition: Dictionary.cpp:123
FIX::Dictionary::Dictionary
Dictionary()
Definition: Dictionary.h:71
FIX::DoubleConvertor::convert
static std::string convert(double value, int padding=0)
Definition: FieldConvertors.h:270
FIX::Dictionary::setInt
void setInt(const std::string &, int)
Set a value from a int.
Definition: Dictionary.cpp:128

Generated on Thu Apr 23 2020 04:32:03 for QuickFIX by doxygen 1.8.16 written by Dimitri van Heesch, © 1997-2001