HttpMessage.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_HTTPMESSAGE
23#define FIX_HTTPMESSAGE
24
25#ifdef _MSC_VER
26#pragma warning( disable: 4786 )
27#endif
28
29#include "Exceptions.h"
30#include <map>
31
32namespace FIX
33{
38{
39public:
40 typedef std::map<std::string, std::string> Parameters;
41
43
45 HttpMessage( const std::string& string )
46 throw( InvalidMessage );
47
48 HttpMessage( const HttpMessage& copy )
49 {
50 m_root = copy.m_root;
52 }
53
54public:
56 std::string toString() const;
58 std::string& toString( std::string& ) const;
59
60 void setString( const std::string& string )
61 throw( InvalidMessage );
62
63 void clear()
64 {
65#if defined(_MSC_VER) && _MSC_VER < 1300
66 m_root = "";
67#else
68 m_root.clear();
69#endif
70 m_parameters.clear();
71 }
72
73 const std::string& getRootString() const
74 { return m_root; }
75
76 const std::string getParameterString() const
77 {
78 std::string result;
79 Parameters::const_iterator i;
80 for( i = m_parameters.begin(); i != m_parameters.end(); ++i )
81 {
82 result += (i == m_parameters.begin()) ? "?" : "&";
83 result += i->first + "=" + i->second;
84 }
85 return result;
86 }
87
89 { return m_parameters; }
90
91 bool hasParameter( const std::string& key ) const
92 {
93 Parameters::const_iterator find = m_parameters.find( key );
94 return find != m_parameters.end();
95 }
96
97 const std::string& getParameter( const std::string& key ) const
98 throw( std::logic_error )
99 {
100 Parameters::const_iterator find = m_parameters.find( key );
101 if( find == m_parameters.end() )
102 throw std::logic_error( "Parameter " + key + " not found" );
103 return find->second;
104 }
105
106 void addParameter( const std::string& key, const std::string& value )
107 {
108 m_parameters[key] = value;
109 }
110
111 void removeParameter( const std::string& key )
112 {
113 m_parameters.erase( key );
114 }
115
116 static std::string createResponse( int error = 0, const std::string& text = "" );
117
118private:
119 std::string m_root;
121};
124inline std::ostream& operator <<
125( std::ostream& stream, const HttpMessage& message )
126{
127 std::string str;
128 stream << message.toString( str );
129 return stream;
130}
131}
132
133#endif //FIX_HTTPMESSAGE
HTTP Message that implemented GET functionality.
Definition HttpMessage.h:38
const Parameters & getParameters() const
Definition HttpMessage.h:88
void addParameter(const std::string &key, const std::string &value)
const std::string & getRootString() const
Definition HttpMessage.h:73
const std::string & getParameter(const std::string &key) const
Definition HttpMessage.h:97
std::string toString() const
Get a string representation of the message.
bool hasParameter(const std::string &key) const
Definition HttpMessage.h:91
std::map< std::string, std::string > Parameters
Definition HttpMessage.h:40
Parameters m_parameters
static std::string createResponse(int error=0, const std::string &text="")
std::string m_root
const std::string getParameterString() const
Definition HttpMessage.h:76
void removeParameter(const std::string &key)
HttpMessage(const HttpMessage &copy)
Definition HttpMessage.h:48
void setString(const std::string &string)
Not a recognizable message.
Definition Exceptions.h:81

Generated on Thu May 22 2025 08:23:50 for QuickFIX by doxygen 1.9.8 written by Dimitri van Heesch, © 1997-2001