OnixS C++ FIX Engine 4.13.0
API Documentation
Loading...
Searching...
No Matches
Message.h
Go to the documentation of this file.
1/*
2* Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3*
4* This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5* and international copyright treaties.
6*
7* Access to and use of the software is governed by the terms of the applicable OnixS Software
8* Services Agreement (the Agreement) and Customer end user license agreements granting
9* a non-assignable, non-transferable and non-exclusive license to use the software
10* for it's own data processing purposes under the terms defined in the Agreement.
11*
12* Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13* of this source code or associated reference material to any other location for further reproduction
14* or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15*
16* Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17* the terms of the Agreement is a violation of copyright law.
18*/
19
20#pragma once
21
22#include <iosfwd>
23#include <string>
24
26
29
33
35
36namespace OnixS {
37namespace FIX {
49class
51 Message : public FieldSet
52{
53public:
65 explicit Message(size_t expectedMessageSize = DefaultExpectedMessageSize);
66
82 Message(const char * type, const Dictionary & dictionary, size_t expectedMessageSize = DefaultExpectedMessageSize);
83
87 Message(const Message & other);
88
89#ifdef ONIXS_FIXENGINE_CXX11
90
97
98#endif
99
105 virtual ~Message();
106
110
113
117
121
125
128 void senderCompId(const std::string &);
129
133
136 void targetCompId(const std::string &);
137
142 void * userData() const;
143
145 void userData(void * data);
146
149 bool operator == (const Message &) const;
150
153 bool operator != (const Message &) const;
154
160 void validate() const;
161
169 void validate(MessageValidationFlags validationFlags) const;
170
178 bool tryValidate(MessageValidationFlags validationFlags, std::string & errorDescription) const;
179
186 void clear();
187
189 void toRaw(RawMessage &) const;
190
196 std::string
197 toString(
198 char delimiter = 0x1,
201
208 void
210 std::string & str,
211 char delimiter = 0x1,
214
219 std::string
220 toXml(const std::string & indent = " ", const std::string & endOfLineDelimiter = "\n") const;
221
227 void
228 toXml(std::string & str, const std::string & indent = " ", const std::string & endOfLineDelimiter = "\n") const;
229
234 std::string
235 toJson(const std::string & indent = " ", const std::string & endOfLineDelimiter = "\n") const;
236
242 void
243 toJson(std::string & str, const std::string & indent = " ", const std::string & endOfLineDelimiter = "\n") const;
244
247
250
251 // Reassigns the message as a copy of other one.
252 Message & operator = (const Message &);
253
254#ifdef ONIXS_FIXENGINE_CXX11
255
259 Message & operator = (Message &&) ONIXS_FIXENGINE_NOTHROW;
260
261#endif
262
263 // Copies all message fields (except the protocol version) from another message object.
264 void copyFields(const Message &);
265
273 static
274 void
276 const char * rawMessage,
277 size_t rawMessageSize,
278 Message & message);
279
288 static
289 void
291 const char * rawMessage,
292 size_t rawMessageSize,
293 MessageParsingFlags parsingFlags,
294 Message & message);
295
305 static
306 void
308 const char * rawMessage,
309 size_t rawMessageSize,
310 const Dictionary & dictionary,
311 MessageParsingFlags parsingFlags,
312 Message & message);
313
322 static
323 bool
325 const char * rawMessage,
326 size_t rawMessageSize,
327 Message & message);
328
338 static
339 bool
341 const char * rawMessage,
342 size_t rawMessageSize,
343 const Dictionary & dictionary,
344 Message & message);
345
347
348protected:
353
354private:
355 friend class MessageWrapper;
356 friend class MessageOperator;
357
358 Message(const void *);
359
360private:
361
362 virtual void userDataImpl(void * data);
363
364 unsigned char impl_[6 * sizeof(size_t)];
365 unsigned char allocator_[4 * sizeof(size_t)];
366
367 static const size_t DefaultExpectedMessageSize = 10240;
368
369 void construct(size_t expectedMessageSize = DefaultExpectedMessageSize);
370 void destruct();
371};
372
373inline
374std::string
376 char delimiter,
377 MessageStringingFlags flags) const
378{
379 std::string str;
380
381 toString(str, delimiter, flags);
382
383 return str;
384}
385
388std::ostream & operator << (std::ostream & os, const Message & message);
389}
390}
#define ONIXS_FIXENGINE_API
Definition ABI.h:45
#define ONIXS_FIXENGINE_NOTHROW
Definition Compiler.h:186
Identifies the FIX messages dictionary.
Definition Dictionary.h:74
Implements a concept of a read-only reference to a FIX field value.
Encapsulates operations over a FIX Message.
Definition Message.h:52
FieldValueRef type() const
Returns the message type (MsgType(35) field value).
static void parse(const char *rawMessage, size_t rawMessageSize, const Dictionary &dictionary, MessageParsingFlags parsingFlags, Message &message)
De-serializes the FIX message from its raw (tag=value) presentation.
void toString(std::string &str, char delimiter=0x1, MessageStringingFlags flags=MessageStringingFlag::IncludeFieldTagNumber) const
Appends the string representation of the message using the given delimiter and additional control fla...
FieldValueRef targetCompId() const
Returns the assigned value used to identify the receiving firm (TargetCompID(56) field value).
SequenceNumber seqNum() const
Returns the message sequence number (the MsgSeqNum (tag=34) field value).
void seqNum(SequenceNumber value)
Sets the message sequence number (the MsgSeqNum (tag=34) field value).
void toRaw(RawMessage &) const
Builds the FIX-compliant 'tag=value' presentation of the message.
bool tryValidate(MessageValidationFlags validationFlags, std::string &errorDescription) const
Tries to validate the message according to specified criteria.
static bool parsePartial(const char *rawMessage, size_t rawMessageSize, Message &message)
De-serializes the FIX message from its raw (tag=value) presentation which may be truncated.
Dictionary dictionary() const
An instance of the FIX dictionary or standard FIX messages dictionary to which the message belongs to...
static bool parsePartial(const char *rawMessage, size_t rawMessageSize, const Dictionary &dictionary, Message &message)
De-serializes the FIX message from its raw (tag=value) presentation which may be truncated.
static void parse(const char *rawMessage, size_t rawMessageSize, Message &message)
De-serializes the FIX message from its raw (tag=value) presentation.
void senderCompId(const std::string &)
Sets the assigned value used to identify the firm sending message (SenderCompID (49) field value).
void toJson(std::string &str, const std::string &indent=" ", const std::string &endOfLineDelimiter="\n") const
Appends the JSON representation of the message.
Message(size_t expectedMessageSize=DefaultExpectedMessageSize)
Initializes a message in the unconstructed state.
void * userData() const
A user data associated with the message.
void userData(void *data)
Attaches a user data to the message.
std::string toJson(const std::string &indent=" ", const std::string &endOfLineDelimiter="\n") const
Returns the JSON representation of the message.
friend class MessageOperator
Definition Message.h:356
FieldValueRef senderCompId() const
Returns the assigned value used to identify the firm sending message (SenderCompID (49) field value).
std::string toString(char delimiter=0x1, MessageStringingFlags flags=MessageStringingFlag::IncludeFieldTagNumber) const
Returns the string representation of the message using the given delimiter and additional control fla...
Definition Message.h:375
friend class MessageWrapper
Definition Message.h:355
Message(const Message &other, MakeShallowCopy)
Initializes an instance as a shallow copy of other one.
void swap(Message &other) ONIXS_FIXENGINE_NOTHROW
Swaps the content with another instance.
void updateBodyLengthAndCheckSum()
Calculates the message body length and checkSum and updates corresponding fields.
Message(const char *type, const Dictionary &dictionary, size_t expectedMessageSize=DefaultExpectedMessageSize)
Constructs a FIX message of the given type which belongs to the given dictionary of the FIX protocol ...
static void parse(const char *rawMessage, size_t rawMessageSize, MessageParsingFlags parsingFlags, Message &message)
De-serializes the FIX message from its raw (tag=value) presentation.
void validate() const
Ensures the message satisfies basic FIX Specification requirements.
void validate(MessageValidationFlags validationFlags) const
Validates the message according to specified criteria.
std::string toXml(const std::string &indent=" ", const std::string &endOfLineDelimiter="\n") const
Returns the XML representation of the message.
void targetCompId(const std::string &)
Sets the assigned value used to identify the receiving firm (TargetCompID(56) field value).
Message(const Message &other)
Initializes an instance as a deep copy of other one.
void clear()
Brings the message to the 'blank' state as it was just constructed.
void toXml(std::string &str, const std::string &indent=" ", const std::string &endOfLineDelimiter="\n") const
Appends the XML representation of the message.
virtual ~Message()
Disposes all internal data structures.
void copyFields(const Message &)
The helper class to represent a raw FIX message.
Definition RawMessage.h:30
ONIXS_FIXENGINE_API std::ostream & operator<<(std::ostream &os, const Group &group)
Stream output.
bool operator==(const FieldValueRef &ref, const std::string &str)
unsigned MessageParsingFlags
The collection of message parsing flags.
unsigned MessageValidationFlags
The collection of message validation flags.
unsigned int SequenceNumber
Alias for the sequence number.
bool operator!=(const FieldValueRef &ref, const std::string &str)
unsigned MessageStringingFlags
The collection of message stringing flags.
@ IncludeFieldTagNumber
Field tag numbers are included during the serialization.