00001
00002
00003
00004
00005 #ifndef Message_h
00006 #define Message_h
00007
00008 #include <iosfwd>
00009 #include <string>
00010
00011 #include "FIXEngineDefines.h"
00012 #include "EngineException.h"
00013 #include "Session.h"
00014 #include "FIXEngine.h"
00015
00016 namespace FIXForge{
00017 namespace FIX{
00018
00019 namespace FAST_1_1{
00020 class Encoder;
00021 class Decoder;
00022 };
00023
00024 class FF_API Group;
00025
00026
00027 class FF_API Message{
00028 public:
00029
00030 enum ValidationOptions
00031 {
00032 CHECK_LENGTH = 2,
00033 CHECK_CHECK_SUM = 4
00034 };
00035
00036
00037 Message(const std::string& nativeFixMessage);
00038
00039
00040
00041
00042
00043
00044
00045 Message(const std::string& nativeFixMessage, int validationOptions);
00046
00047
00048 Message(const std::string& type, Version version);
00049
00050
00051 Message(const char* type, Version version);
00052
00053
00054 Message(const Message& msg);
00055
00056
00057 ~Message();
00058
00059 bool operator == (const Message& rh);
00060 bool operator != (const Message& rh);
00061
00062 friend FF_API std::ostream& operator<< (std::ostream& os, const Message& msg);
00063
00064
00065 void updateCheckSum();
00066
00067
00068 bool contain(int tag) const;
00069
00070
00071 const std::string& get(int tag) const;
00072
00073
00074
00075
00076
00077
00078 double getDouble(int tag) const;
00079
00080
00081
00082
00083
00084
00085
00086
00087 Group* getGroup(int numberOfInstancesTag) const;
00088
00089
00090
00091
00092
00093
00094 int getInteger(int tag) const;
00095
00096
00097 const std::string& getSenderCompID() const;
00098
00099
00100 int getSeqNum() const;
00101
00102
00103 const std::string& getTargetCompID() const;
00104
00105
00106 const std::string& getType() const;
00107
00108
00109 Version getVersion() const;
00110
00111
00112 bool hasFlag(int tag) const;
00113
00114
00115 bool remove(int tag);
00116
00117
00118 bool set(int tag, int value);
00119
00120
00121 bool set(int tag, double value);
00122
00123
00124 bool set(int tag, const std::string& value);
00125
00126
00127
00128
00129
00130
00131 void setFlag(int tag, bool value);
00132
00133
00134
00135
00136
00137
00138
00139
00140 Group* setGroup(int numberOfInstancesTag, int numberOfIntances);
00141
00142
00143 void setSenderCompID(const std::string& value);
00144
00145
00146 void setSeqNum(int value);
00147
00148
00149 void setTargetCompID(const std::string& value);
00150
00151
00152 const std::string& toString() const;
00153
00154
00155 const std::string& toString(char delimiter) const;
00156
00157
00158 enum FORMAT{
00159 TAG_NUMBER = 1,
00160 TAG_NAME = 2
00161 };
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171 const std::string& toString(int format, char delimiter = ' ') const;
00172
00173
00174 void validate() const;
00175
00176 private:
00177 Message(void* native, bool isOwner = false);
00178 Message& operator = (const Message&);
00179
00180 void init(const char* type, Version version);
00181
00182 struct Impl;
00183 Impl* impl_;
00184
00185 void* native_;
00186
00187 friend class Session;
00188 friend struct Session::Impl;
00189 friend struct Engine::Impl;
00190 friend class FAST_1_1::Encoder;
00191 friend class FAST_1_1::Decoder;
00192 };
00193
00194 }};
00195
00196 #endif