OnixS C++ FIX Engine 4.13.0
API Documentation
Loading...
Searching...
No Matches
FlatMessage.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 <iterator>
23
28
31
33
34namespace OnixS {
35namespace FIX {
38
39namespace Core {
40namespace Messaging {
41namespace Extras {
42class FlatMessage;
43}
44}
45}
46
49{
50 enum Enum
51 {
54
57 };
58};
59
62{
63public:
64
67 : tag_(0), value_(ONIXS_FIXENGINE_NULLPTR), size_(0) {}
68
71 Tag fieldTag,
72 const StringRef & fieldValue)
73 : tag_(fieldTag), value_(fieldValue.data()), size_(fieldValue.size()) {}
74
76 Tag tag() const { return tag_; }
77
79 StringRef value() const { return StringRef(value_, size_); }
80
81private:
82
84 Tag tag_;
85
87 const char * value_;
88
90 size_t size_;
91};
92
110{
111public:
116
120 FlatMessage(OnixS::FIX::ProtocolVersion::Enum protocolVersion, const char * msgType);
121
123 FlatMessage(const char * rawMessage, size_t rawMessageSize, bool useZeroCopyBuffer = true);
124
128 OnixS::FIX::ProtocolVersion::Enum protocolVersion,
129 const char * msgType,
130 const char * senderCompId,
131 const char * targetCompId,
132 const char * rawMessageWithoutHeaderTrailer,
133 size_t rawMessageWithoutHeaderTrailerSize,
134 bool useZeroCopyBuffer = true);
135
137 FlatMessage(const OnixS::FIX::Message & message, bool useZeroCopyBuffer = true);
138
140 FlatMessage(const FlatMessage & other);
141
142#ifdef ONIXS_FIXENGINE_CXX11
143
150
151#endif
152
155
160 bool valid() const;
161
163 const char * chars() const;
164
166 size_t size() const;
167
169 std::string toString() const;
170
173 FlatFieldRef find(Tag) const;
174
183
186
189
192
195
203 FlatGroup getGroup(const FlatFieldRef & numberOfInstancesRef) const;
204
207
213
218
223
228
233
238
243
248
253
258
263
268
273
278
283
288
293
298
303
308
313
318
323
328
333
338
343
348
353
359
365
371
377
383
389
395
401
407
415
417 void adjust();
418
422 void reset(const char * rawMessage, size_t rawMessageSize);
423
427 void reset();
428
429 // Returns the `ProtocolVersion`, which corresponds to `BeginString` and 'ApplVerID' tag values.
431
436 void * userData() const;
437
439 void userData(void * data);
440
443
445 FlatMessage & operator = (const FlatMessage &);
446
447#ifdef ONIXS_FIXENGINE_CXX11
448
453
454#endif
455
458 {
459 public:
460
461 typedef std::forward_iterator_tag iterator_category;
463 typedef std::ptrdiff_t difference_type;
466
469
470 const FlatField & operator*() const {
471 return currentField_;
472 }
473
474 const FlatField * operator->() const {
475 return &currentField_;
476 }
477
478 bool operator == (const ConstIterator &) const;
479 bool operator != (const ConstIterator &) const;
480
481 ConstIterator & operator ++();
482
483 private:
485 const FlatMessage * container_;
486
488 FlatField currentField_;
489 };
490
493
496
497private:
498 friend class MessageOperator;
499 friend class FlatMessageWrapper;
500
501 FlatMessage(const OnixS::FIX::Core::Messaging::Extras::FlatMessage & other);
502
503 OnixS::FIX::Core::Messaging::Extras::FlatMessage * impl_;
504 bool isOwned_;
505};
506
508
509inline
512{
513 return find(tag, FlatFieldRef());
514}
515
518std::ostream & operator << (std::ostream & os, const FlatMessage & message);
519}
520}
#define ONIXS_FIXENGINE_API_DECL(typeKind, typeName)
Definition ABI.h:57
#define ONIXS_FIXENGINE_API
Definition ABI.h:45
#define ONIXS_FIXENGINE_NULLPTR
Definition Compiler.h:200
#define ONIXS_FIXENGINE_NOTHROW
Definition Compiler.h:186
The Decimal type for a better precision.
Definition Numeric.h:48
Implements a concept of a read-only reference to a FIX field value.
Key to a serialized field - represents another way of accessing fields in an editable serialized mess...
Represents a temporary reference to a field in an editable serialized message.
Field primary attributes (a tag and a reference to a value).
Definition FlatMessage.h:62
Tag tag() const
Gets the field tag.
Definition FlatMessage.h:76
FlatField()
Initializes the field which refers to nothing.
Definition FlatMessage.h:66
FlatField(Tag fieldTag, const StringRef &fieldValue)
Initializes all members.
Definition FlatMessage.h:70
StringRef value() const
Gets the field value reference.
Definition FlatMessage.h:79
Encapsulates operations over the FIX Repeating Group.
Definition FlatGroup.h:76
The constant iterator to iterate over all fields in the given FlatMessage instance.
const FlatField & operator*() const
std::forward_iterator_tag iterator_category
const FlatField * operator->() const
ConstIterator(const FlatMessage *, Tag)
Initializes an iterator by a first field from which you need to iterate.
Provides an access to FIX fields from a flat (tag=value) message.
FlatMessage & insert(Tag, Int64, Tag, InsertMode::Enum=InsertMode::Before)
Inserts the tag/value pair to the message before or after the position field.
FlatMessage & insert(Tag, const Timestamp &, TimestampFormat::Enum, Tag, InsertMode::Enum=InsertMode::Before)
Inserts the tag/value pair to the message before or after the position field.
FlatMessage & insert(Tag, Int32, Tag, InsertMode::Enum=InsertMode::Before)
Inserts the tag/value pair to the message before or after the position field.
FlatMessage & set(FlatFieldRef &, UInt64)
Updates the field value.
StringRef operator[](FlatFieldKey) const
Provides an access to a field value by the given field key.
FlatMessage(OnixS::FIX::ProtocolVersion::Enum protocolVersion, const char *msgType, const char *senderCompId, const char *targetCompId, const char *rawMessageWithoutHeaderTrailer, size_t rawMessageWithoutHeaderTrailerSize, bool useZeroCopyBuffer=true)
Constructs an instance from the tag=value form without session-level fields.
FlatFieldRef find(Tag, const FlatFieldRef &) const
Looks for a field with assumption the field is located after the given field using its tag number.
FlatMessage & insert(Tag, UInt64, Tag, InsertMode::Enum=InsertMode::Before)
Inserts the tag/value pair to the message before or after the position field.
std::string toString() const
Returns a string that represents the flat message.
FlatMessage & remove(Tag)
Removes the field value.
FlatMessage & add(Tag, Char)
Adds the tag/value pair to the end of the message.
FlatMessage & add(Tag, UInt64)
Adds the tag/value pair to the end of the message.
FlatMessage & add(Tag, const Decimal &)
Adds the tag/value pair to the end of the message.
size_t size() const
The size of the flat content.
FlatFieldRef find(Tag) const
Looks for a field using the given tag number.
FlatMessage(const char *rawMessage, size_t rawMessageSize, bool useZeroCopyBuffer=true)
Constructs an instance from the tag=value form.
FlatMessage & add(Tag, Int64)
Adds the tag/value pair to the end of the message.
FlatMessage & add(Tag, const TimeSpan &, TimeSpanFormat::Enum)
Adds the tag/value pair to the end of the message.
FlatMessage & set(FlatFieldKey, UInt64)
Updates the field value.
void reset(const char *rawMessage, size_t rawMessageSize)
Resets the instance to the new tag=value form.
bool valid() const
Indicates whether an instance refers to a valid set of fields.
FlatMessage & insert(Tag, const TimeSpan &, TimeSpanFormat::Enum, Tag, InsertMode::Enum=InsertMode::Before)
Inserts the tag/value pair to the message before or after the position field.
FlatMessage & set(FlatFieldRef &, const Decimal &)
Updates the field value.
FlatMessage & set(FlatFieldKey, UInt32)
Updates the field value.
FlatFieldKey allocateKey(const FlatFieldRef &)
Allocates a key to the requested field for the further access.
FlatMessage(OnixS::FIX::ProtocolVersion::Enum protocolVersion, const char *msgType)
Constructs an instance with empty required message header fields.
FlatMessage & add(Tag, const StringRef &)
Adds the tag/value pair to the end of the message.
FlatMessage & set(FlatFieldKey, const Decimal &)
Updates the field value.
FlatMessage & add(Tag, UInt32)
Adds the tag/value pair to the end of the message.
FlatMessage & set(FlatFieldRef &, const FieldValueRef &)
Updates the field value.
StringRef operator[](const FlatFieldRef &) const
Provides an access to a field value by the given temporary reference.
FlatMessage & insert(Tag, const Decimal &, Tag, InsertMode::Enum=InsertMode::Before)
Inserts the tag/value pair to the message before or after the position field.
ConstIterator end() const
Returns the constant iterator to the field after the last one in the FlatMessage instance.
void * userData() const
A user data associated with the message.
void adjust()
Updates BodyLength and CheckSum fields.
void userData(void *data)
Attaches a user data to the message.
FlatMessage & set(FlatFieldKey, const StringRef &)
Updates the field value.
FlatMessage & insert(Tag, UInt32, Tag, InsertMode::Enum=InsertMode::Before)
Inserts the tag/value pair to the message before or after the position field.
FlatMessage & set(FlatFieldKey, const TimeSpan &, TimeSpanFormat::Enum)
Updates the field value.
friend class MessageOperator
void swap(FlatMessage &other) ONIXS_FIXENGINE_NOTHROW
Swaps the content with another instance.
FlatMessage & set(FlatFieldKey, const FieldValueRef &)
Updates the field value.
~FlatMessage()
Utilizes internal resources.
FlatMessage & set(FlatFieldKey, Int64)
Updates the field value.
FlatMessage & set(FlatFieldRef &, Char)
Updates the field value.
FlatMessage & set(FlatFieldKey, const Timestamp &, TimestampFormat::Enum)
Updates the field value.
FlatMessage & set(FlatFieldKey, Char)
Updates the field value.
FlatFieldKey allocateKey(Tag)
Finds and allocates a key to the requested field for the further access.
FlatMessage & insert(Tag, Char, Tag, InsertMode::Enum=InsertMode::Before)
Inserts the tag/value pair to the message before or after the position field.
FlatFieldRef getFlatFieldRef(const StringRef &value) const
Converts the StringRef value of the given FlatMessage to the FlatFieldRef object.
FlatGroup getGroup(const FlatFieldRef &numberOfInstancesRef) const
Returns the reference to a repeating group - if exists.
FlatMessage(const FlatMessage &other)
Initializes as a copy of the given instance.
FlatMessage & set(FlatFieldRef &, Int64)
Updates the field value.
FlatMessage()
Constructs the blank instance.
FlatMessage & add(Tag, Int32)
Adds the tag/value pair to the end of the message.
FlatMessage & set(FlatFieldRef &, const TimeSpan &, TimeSpanFormat::Enum)
Updates the field value.
FlatMessage & add(Tag, const Timestamp &, TimestampFormat::Enum)
Adds the tag/value pair to the end of the message.
FlatMessage & set(FlatFieldRef &, const StringRef &)
Updates the field value.
friend class FlatMessageWrapper
void reset()
Resets the instance to the blank state.
FlatMessage(const OnixS::FIX::Message &message, bool useZeroCopyBuffer=true)
Constructs an instance from the given Message object.
ConstIterator begin() const
Returns the constant iterator to the first field in the FlatMessage instance.
FlatMessage & set(FlatFieldRef &, Int32)
Updates the field value.
FlatMessage & set(FlatFieldKey, Int32)
Updates the field value.
FlatMessage & insert(Tag, const StringRef &, Tag, InsertMode::Enum=InsertMode::Before)
Inserts the tag/value pair to the message before or after the position field.
FlatMessage & set(FlatFieldRef &, const Timestamp &, TimestampFormat::Enum)
Updates the field value.
const char * chars() const
Returns the content of the flat message.
FlatMessage & set(FlatFieldRef &, UInt32)
Updates the field value.
ProtocolVersion::Enum version() const
Encapsulates operations over a FIX Message.
Definition Message.h:52
Provides an efficient way of accessing text-based FIX field values.
Definition StringRef.h:62
The time span related functionality.
Definition TimeSpan.h:94
The timestamps related functionality.
Definition Timestamp.h:92
FlatMessage SerializedMessage
unsigned int UInt32
Definition Numeric.h:36
long long Int64
Definition Numeric.h:38
ONIXS_FIXENGINE_API std::ostream & operator<<(std::ostream &os, const Group &group)
Stream output.
char Char
Definition Numeric.h:30
unsigned long long UInt64
Definition Numeric.h:39
int Int32
Definition Numeric.h:35
unsigned Tag
Alias for tag numbers.
Definition Tag.h:28
The insert mode of FlatMessage::insert() methods.
Definition FlatMessage.h:49
@ After
The new field will be inserted after the position tag.
Definition FlatMessage.h:56
@ Before
The new field will be inserted before the position tag.
Definition FlatMessage.h:53