Dictionary.h
Go to the documentation of this file.
1 /* -*- C++ -*- */
2 
3 /****************************************************************************
4 ** Copyright (c) 2001-2014
5 **
6 ** This file is part of the QuickFIX FIX Engine
7 **
8 ** This file may be distributed under the terms of the quickfixengine.org
9 ** license as defined by quickfixengine.org and appearing in the file
10 ** LICENSE included in the packaging of this file.
11 **
12 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14 **
15 ** See http://www.quickfixengine.org/LICENSE for licensing information.
16 **
17 ** Contact ask@quickfixengine.org if any conditions of this licensing are
18 ** not clear to you.
19 **
20 ****************************************************************************/
21 
22 #ifndef FIX_DICTIONARY_H
23 #define FIX_DICTIONARY_H
24 
25 #ifdef _MSC_VER
26 #pragma warning( disable : 4503 4355 4786 4290 )
27 #endif
28 
29 #include <map>
30 #include <string>
31 #include "Exceptions.h"
32 
33 namespace FIX
34 {
36 class Dictionary
37 {
38 public:
39  Dictionary( const std::string& name ) : m_name( name ) {}
40  Dictionary() {}
41  virtual ~Dictionary() {}
42 
43  typedef std::map < std::string, std::string > Data;
44  typedef Data::const_iterator iterator;
45  typedef iterator const_iterator;
46 
48  std::string getName() const { return m_name; }
50  size_t size() const { return m_data.size(); }
51 
53  std::string getString( const std::string&, bool capitalize = false ) const
56  int getInt( const std::string& ) const
59  double getDouble( const std::string& ) const
62  bool getBool( const std::string& ) const
65  int getDay( const std::string& ) const
67 
69  void setString( const std::string&, const std::string& );
71  void setInt( const std::string&, int );
73  void setDouble( const std::string&, double );
75  void setBool( const std::string&, bool );
77  void setDay( const std::string&, int );
78 
80  bool has( const std::string& ) const;
82  void merge( const Dictionary& );
83 
84  iterator begin() const { return m_data.begin(); }
85  iterator end() const { return m_data.end(); }
86 
87 private:
88  Data m_data;
89  std::string m_name;
90 };
92 }
93 
94 #endif //FIX_DICTIONARY_H
FIX::Dictionary::~Dictionary
virtual ~Dictionary()
Definition: Dictionary.h:75
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::getInt
int getInt(const std::string &) const
Get a value as a int.
Definition: Dictionary.cpp:62
FIX::Dictionary::size
size_t size() const
Return the number of key/value pairs.
Definition: Dictionary.h:84
FIX::Dictionary::iterator
Data::const_iterator iterator
Definition: Dictionary.h:78
FIX::Dictionary::m_data
Data m_data
Definition: Dictionary.h:122
FIX::Dictionary::setDouble
void setDouble(const std::string &, double)
Set a value from a double.
Definition: Dictionary.cpp:135
FIX::ConfigError
Application is not configured correctly
Definition: Exceptions.h:104
FIX::Dictionary::end
iterator end() const
Definition: Dictionary.h:119
FIX::FieldConvertError
Unable to convert field into its native format.
Definition: Exceptions.h:83
FIX::Dictionary::getName
std::string getName() const
Get the name of the dictionary.
Definition: Dictionary.h:82
FIX::Dictionary::setDay
void setDay(const std::string &, int)
Set a value from a day.
Definition: Dictionary.cpp:145
FIX::Dictionary::getDouble
double getDouble(const std::string &) const
Get a value as a double.
Definition: Dictionary.cpp:75
FIX::Dictionary::has
bool has(const std::string &) const
Check if the dictionary contains a value for key.
Definition: Dictionary.cpp:166
FIX::Dictionary::m_name
std::string m_name
Definition: Dictionary.h:123
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
Definition: Acceptor.cpp:34
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::Dictionary::begin
iterator begin() const
Definition: Dictionary.h:118
Exceptions.h
FIX::Dictionary
For storage and retrieval of key/value pairs.
Definition: Dictionary.h:53
FIX::Dictionary::const_iterator
iterator const_iterator
Definition: Dictionary.h:79
FIX::Dictionary::setInt
void setInt(const std::string &, int)
Set a value from a int.
Definition: Dictionary.cpp:130
FIX::Dictionary::Data
std::map< std::string, std::string > Data
Definition: Dictionary.h:77

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