00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #if !defined(__ONIXS_MESSAGE_H__)
00021 #define __ONIXS_MESSAGE_H__
00022
00023 #include <iosfwd>
00024 #include <string>
00025
00026 #include "OnixS/FIX/ABI.h"
00027 #include "OnixS/FIX/Definitions.h"
00028 #include "OnixS/FIX/EngineException.h"
00029 #include "OnixS/FIX/Session.h"
00030 #include "OnixS/FIX/Engine.h"
00031
00032 namespace OnixS
00033 {
00034 namespace FIX
00035 {
00036 namespace FAST
00037 {
00038 ONIXS_FIXENGINE_API_DECL(class, Encoder);
00039 ONIXS_FIXENGINE_API_DECL(class, Decoder);
00040 };
00041
00042 ONIXS_FIXENGINE_API_DECL(class, Group);
00043 ONIXS_FIXENGINE_API_DECL(class, Dialect);
00044
00045 struct
00046 ONIXS_FIXENGINE_API
00047 MessageStructurePolicies
00048 {
00049 enum Enum
00050 {
00051 SerializationOptimized,
00052 PreserveOriginalValues
00053 };
00054 };
00055
00056 typedef
00057 MessageStructurePolicies::Enum
00058 MessageStructurePolicy;
00059
00060 struct
00061 ONIXS_FIXENGINE_API
00062 MessageValidationFlags
00063 {
00064 enum Enum
00065 {
00066 VerifyBodyLength = 2,
00067 VerifyCheckSum = 4
00068 };
00069 };
00070
00071 typedef int MessageValidationOptions;
00072
00073 struct
00074 ONIXS_FIXENGINE_API
00075 MessageStringingFlags
00076 {
00078 enum Enum
00079 {
00080 IncludeTagNumber = 1,
00081 IncludeTagName = 2
00082 };
00083 };
00084
00085 typedef
00086 int
00087 MessageStringingOptions;
00088
00090 class ONIXS_FIXENGINE_API Message
00091 {
00092 public:
00096 enum ValidationOption
00097 {
00098 CHECK_LENGTH = MessageValidationFlags::VerifyBodyLength,
00099 CHECK_CHECK_SUM = MessageValidationFlags::VerifyCheckSum
00100 };
00101
00105 enum FORMAT
00106 {
00107 TAG_NUMBER = MessageStringingFlags::IncludeTagNumber,
00108 TAG_NAME = MessageStringingFlags::IncludeTagName
00109 };
00110
00112 Message(const std::string& nativeFixMessage);
00113
00118 Message(const std::string& nativeFixMessage, MessageValidationOptions validationOptions);
00119
00125 Message(const std::string& nativeFixMessage, const Dialect& dialect, MessageValidationOptions validationOptions);
00126
00133 Message(const char* type, Version version, MessageStructurePolicy policy = MessageStructurePolicies::SerializationOptimized);
00134
00141 Message(const char* type, const Dialect& dialect, MessageStructurePolicy policy = MessageStructurePolicies::SerializationOptimized);
00142
00149 Message(const std::string& type, Version version, MessageStructurePolicy policy = MessageStructurePolicies::SerializationOptimized);
00150
00157 Message(const std::string& type, const Dialect& dialect, MessageStructurePolicy policy = MessageStructurePolicies::SerializationOptimized);
00158
00162 Message(const Message& source);
00163
00167 Message& operator = (const Message& source);
00168
00170 ~Message();
00171
00173 const std::string& getType() const;
00174
00176 Version getVersion() const;
00177
00180 const Dialect& dialect() const;
00181
00184 const std::string& getSenderCompID() const;
00185
00188 void setSenderCompID(const std::string& value);
00189
00191 int getSeqNum() const;
00192
00194 void setSeqNum(int value);
00195
00198 const std::string& getTargetCompID() const;
00199
00202 void setTargetCompID(const std::string& value);
00203
00206 bool contain(int tag) const;
00207
00213 const std::string& get(int tag) const;
00214
00219 int getInteger(int tag) const;
00220
00224 int getInt32(int tag) const;
00225
00229 unsigned int getUInt32(int tag) const;
00230
00234 long long getInt64(int tag) const;
00235
00239 unsigned long long getUInt64(int tag) const;
00240
00244 double getDouble(int tag) const;
00245
00253 Group* getGroup(int numberOfInstancesTag) const;
00254
00257 bool hasFlag(int tag) const;
00258
00263 bool set(int tag, char value);
00264
00269 bool set(int tag, int value);
00270
00275 bool set(int tag, unsigned int value);
00276
00281 bool set(int tag, long long value);
00282
00287 bool set(int tag, unsigned long long value);
00288
00293 bool set(int tag, double value);
00294
00303 bool set(int tag, double value, size_t precision);
00304
00309 bool set(int tag, const std::string& value);
00310
00315 bool set(int tag, const char* value);
00316
00321 void setFlag(int tag, bool value);
00322
00332 Group* setGroup(int numberOfInstancesTag, int numberOfIntances);
00333
00335 bool remove(int tag);
00336
00339 const std::string& toString() const;
00340
00343 const std::string& toString(char delimiter) const;
00344
00353 const std::string& toString(MessageStringingOptions options, char delimiter = ' ') const;
00354
00356 void validate() const;
00357
00359 void updateCheckSum();
00360
00362 bool operator == (const Message& rh) const;
00363
00365 bool operator != (const Message& rh) const;
00366
00367 friend ONIXS_FIXENGINE_API std::ostream& operator<< (std::ostream& os, const Message& message);
00368
00369 private:
00370 struct Impl;
00371
00372 Message(Impl * impl);
00373 Message(void* native, bool isOwner = false);
00374
00375 void init(const void* dictionary, const char* type, MessageStructurePolicy policy);
00376 void init(const void* dictionary, const std::string& raw, int parsingOptions);
00377
00378 Impl* impl_;
00379
00380 void* native_;
00381
00382 friend class MessageProxy;
00383
00384 friend ONIXS_FIXENGINE_API_DECL(class, Dialect);
00385 friend ONIXS_FIXENGINE_API_DECL(class, Session);
00386 friend ONIXS_FIXENGINE_API_DECL(struct, Session::Impl);
00387 friend ONIXS_FIXENGINE_API_DECL(struct, Engine::Impl);
00388 friend ONIXS_FIXENGINE_API_DECL(class, FAST::Encoder);
00389 friend ONIXS_FIXENGINE_API_DECL(class, FAST::Decoder);
00390 };
00391 }
00392 }
00393
00394 #endif // __ONIXS_MESSAGE_H__