Dictionary.h
Go to the documentation of this file.
/* -*- C++ -*- */
/****************************************************************************
** Copyright (c) 2001-2014
**
** This file is part of the QuickFIX FIX Engine
**
** This file may be distributed under the terms of the quickfixengine.org
** license as defined by quickfixengine.org and appearing in the file
** LICENSE included in the packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.quickfixengine.org/LICENSE for licensing information.
**
** Contact ask@quickfixengine.org if any conditions of this licensing are
** not clear to you.
**
****************************************************************************/
#ifndef FIX_DICTIONARY_H
#define FIX_DICTIONARY_H
#ifdef _MSC_VER
#pragma warning( disable : 4503 4355 4786 4290 )
#endif
#include <map>
#include <string>
#include "Exceptions.h"
namespace FIX
{
class Dictionary
{
public:
Dictionary( const std::string& name ) : m_name( name ) {}
Dictionary() {}
virtual ~Dictionary() {}
typedef std::map < std::string, std::string > Data;
typedef Data::const_iterator iterator;
typedef iterator const_iterator;
std::string getName() const { return m_name; }
size_t size() const { return m_data.size(); }
std::string getString( const std::string&, bool capitalize = false ) const
throw( ConfigError, FieldConvertError );
int getInt( const std::string& ) const
throw( ConfigError, FieldConvertError );
double getDouble( const std::string& ) const
throw( ConfigError, FieldConvertError );
bool getBool( const std::string& ) const
throw( ConfigError, FieldConvertError );
int getDay( const std::string& ) const
throw( ConfigError, FieldConvertError );
void setString( const std::string&, const std::string& );
void setInt( const std::string&, int );
void setDouble( const std::string&, double );
void setBool( const std::string&, bool );
void setDay( const std::string&, int );
bool has( const std::string& ) const;
void merge( const Dictionary& );
iterator begin() const { return m_data.begin(); }
iterator end() const { return m_data.end(); }
private:
Data m_data;
std::string m_name;
};
}
#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