OnixS C++ FIX Engine 4.14.0
Users' manual and 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
94 Message(Message && moved) noexcept;
95
101 virtual ~Message();
102
106
109
113
117
121
124 void senderCompId(const std::string &);
125
129
132 void targetCompId(const std::string &);
133
138 void * userData() const;
139
141 void userData(void * data);
142
145 bool operator == (const Message &) const;
146
149 bool operator != (const Message &) const;
150
156 void validate() const;
157
163 void validateAll() const;
164
172 void validate(MessageValidationFlags validationFlags) const;
173
179 void validateAll(MessageValidationFlags validationFlags) const;
180
188 bool tryValidate(MessageValidationFlags validationFlags, std::string & errorDescription) const;
189
197 bool tryValidateAll(MessageValidationFlags validationFlags, std::string & errorDescription) const;
198
205 void clear();
206
208 void toRaw(RawMessage &) const;
209
215 std::string
216 toString(
217 char delimiter = 0x1,
220
227 void
229 std::string & str,
230 char delimiter = 0x1,
233
238 std::string
239 toXml(const std::string & indent = " ", const std::string & endOfLineDelimiter = "\n") const;
240
246 void
247 toXml(std::string & str, const std::string & indent = " ", const std::string & endOfLineDelimiter = "\n") const;
248
253 std::string
254 toJson(const std::string & indent = " ", const std::string & endOfLineDelimiter = "\n") const;
255
261 void
262 toJson(std::string & str, const std::string & indent = " ", const std::string & endOfLineDelimiter = "\n") const;
263
266
268 void swap(Message & other) noexcept;
269
270 // Reassigns the message as a copy of other one.
271 Message & operator = (const Message &);
272
276 Message & operator = (Message &&) noexcept;
277
278 // Copies all message fields (except the protocol version) from another message object.
279 void copyFields(const Message &);
280
288 static
289 void
291 const char * rawMessage,
292 size_t rawMessageSize,
293 Message & message);
294
303 static
304 void
306 const char * rawMessage,
307 size_t rawMessageSize,
308 MessageParsingFlags parsingFlags,
309 Message & message);
310
320 static
321 void
323 const char * rawMessage,
324 size_t rawMessageSize,
325 const Dictionary & dictionary,
326 MessageParsingFlags parsingFlags,
327 Message & message);
328
337 static
338 bool
340 const char * rawMessage,
341 size_t rawMessageSize,
342 Message & message);
343
353 static
354 bool
356 const char * rawMessage,
357 size_t rawMessageSize,
358 const Dictionary & dictionary,
359 Message & message);
360
362
363protected:
368
369private:
370 friend class MessageWrapper;
371 friend class MessageOperator;
372
373 Message(const void *);
374
375private:
376
377 virtual void userDataImpl(void * data);
378
379 unsigned char impl_[6 * sizeof(size_t)];
380 unsigned char allocator_[4 * sizeof(size_t)];
381
382 static const size_t DefaultExpectedMessageSize = 10240;
383
384 void construct(size_t expectedMessageSize = DefaultExpectedMessageSize);
385 void destruct();
386};
387
388inline
389std::string
391 char delimiter,
392 MessageStringingFlags flags) const
393{
394 std::string str;
395
396 toString(str, delimiter, flags);
397
398 return str;
399}
400
403std::ostream & operator << (std::ostream & os, const Message & message);
404}
405}
#define ONIXS_FIXENGINE_API
Definition ABI.h:45
Identifies the FIX messages dictionary.
Definition Dictionary.h:132
friend class Message
Definition FieldSet.h:785
FieldValueRef type() const
Returns the message type (MsgType(35) field value).
void toString(std::string &str, char delimiter=0x1, MessageStringingFlags flags=MessageStringingFlag::IncludeFieldTagNumber) const
FieldValueRef targetCompId() const
SequenceNumber seqNum() const
Message(Message &&moved) noexcept
void seqNum(SequenceNumber value)
void toRaw(RawMessage &) const
Builds the FIX-compliant 'tag=value' presentation of the message.
bool tryValidate(MessageValidationFlags validationFlags, std::string &errorDescription) const
static bool parsePartial(const char *rawMessage, size_t rawMessageSize, Message &message)
Dictionary dictionary() const
static void parse(const char *rawMessage, size_t rawMessageSize, Message &message)
void senderCompId(const std::string &)
void toJson(std::string &str, const std::string &indent=" ", const std::string &endOfLineDelimiter="\n") const
void validateAll(MessageValidationFlags validationFlags) const
Message(size_t expectedMessageSize=DefaultExpectedMessageSize)
void * userData() const
void userData(void *data)
Attaches a user data to the message.
void validateAll() const
std::string toJson(const std::string &indent=" ", const std::string &endOfLineDelimiter="\n") const
friend class MessageOperator
Definition Message.h:371
FieldValueRef senderCompId() const
std::string toString(char delimiter=0x1, MessageStringingFlags flags=MessageStringingFlag::IncludeFieldTagNumber) const
Definition Message.h:390
friend class MessageWrapper
Definition Message.h:370
Message(const Message &other, MakeShallowCopy)
void updateBodyLengthAndCheckSum()
Calculates the message body length and checkSum and updates corresponding fields.
Message(const char *type, const Dictionary &dictionary, size_t expectedMessageSize=DefaultExpectedMessageSize)
void validate() const
void validate(MessageValidationFlags validationFlags) const
std::string toXml(const std::string &indent=" ", const std::string &endOfLineDelimiter="\n") const
void targetCompId(const std::string &)
Message(const Message &other)
bool tryValidateAll(MessageValidationFlags validationFlags, std::string &errorDescription) const
void toXml(std::string &str, const std::string &indent=" ", const std::string &endOfLineDelimiter="\n") const
void swap(Message &other) noexcept
Swaps the content with another instance.
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 FlatMessage &message)
The 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.