OnixS C++ FIX Engine 4.14.0
Users' manual and 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_(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
114{
115public:
120
124 FlatMessage(OnixS::FIX::ProtocolVersion::Enum protocolVersion, const char * msgType);
125
127 FlatMessage(const char * rawMessage, size_t rawMessageSize, bool useZeroCopyBuffer = true);
128
132 OnixS::FIX::ProtocolVersion::Enum protocolVersion,
133 const char * msgType,
134 const char * senderCompId,
135 const char * targetCompId,
136 const char * rawMessageWithoutHeaderTrailer,
137 size_t rawMessageWithoutHeaderTrailerSize,
138 bool useZeroCopyBuffer = true);
139
141 FlatMessage(const OnixS::FIX::Message & message, bool useZeroCopyBuffer = true);
142
144 FlatMessage(const FlatMessage & other);
145
151 FlatMessage(FlatMessage && moved) noexcept;
152
155
162 bool valid() const;
163
165 const char * chars() const;
166
168 size_t size() const;
169
172 std::string toString(char delimiter = 0x1) const;
173
176 FlatFieldRef find(Tag) const;
177
186
189
192
195
198
206 FlatGroup getGroup(const FlatFieldRef & numberOfInstancesRef) const;
207
210
216
221
226
231
236
241
246
251
256
261
266
271
276
281
286
291
296
301
306
311
316
321
326
331
336
341
346
351
356
362
368
374
380
386
392
398
404
410
418
420 void adjust();
421
425 void reset(const char * rawMessage, size_t rawMessageSize);
426
430 void reset();
431
432 // Returns the `ProtocolVersion`, which corresponds to `BeginString` and 'ApplVerID' tag values.
434
439 void * userData() const;
440
442 void userData(void * data);
443
445 void swap(FlatMessage & other) noexcept;
446
448 FlatMessage & operator = (const FlatMessage &);
449
453 FlatMessage & operator = (FlatMessage &&) noexcept;
454
457 {
458 public:
459
460 typedef std::forward_iterator_tag iterator_category;
462 typedef std::ptrdiff_t difference_type;
463 typedef const FlatField * pointer;
464 typedef const FlatField & reference;
465
468
470 return currentField_;
471 }
472
474 return &currentField_;
475 }
476
477 bool operator == (const ConstIterator &) const;
478 bool operator != (const ConstIterator &) const;
479
480 ConstIterator & operator ++();
481
482 private:
484 const FlatMessage * container_;
485
487 FlatField currentField_;
488 };
489
491
494
497
498private:
499 friend class MessageOperator;
500 friend class FlatMessageWrapper;
501
502 FlatMessage(const OnixS::FIX::Core::Messaging::Extras::FlatMessage & other);
503
504 OnixS::FIX::Core::Messaging::Extras::FlatMessage * impl_;
505 bool isOwned_;
506};
507
509
510inline
513{
514 return find(tag, FlatFieldRef());
515}
516
519std::ostream & operator << (std::ostream & os, const FlatMessage & message);
520}
521}
#define ONIXS_FIXENGINE_API
Definition ABI.h:45
The Decimal type for a better precision.
Definition Numeric.h:48
FlatFieldRef()
Initializes as a references to nothing.
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
The constant iterator to iterate over all fields in the given FlatMessage instance.
std::forward_iterator_tag iterator_category
ConstIterator(const FlatMessage *, Tag)
Initializes an iterator by a first field from which you need to iterate.
FlatMessage & insert(Tag, Int64, Tag, InsertMode::Enum=InsertMode::Before)
FlatMessage & insert(Tag, const Timestamp &, TimestampFormat::Enum, Tag, InsertMode::Enum=InsertMode::Before)
FlatMessage & insert(Tag, Int32, Tag, InsertMode::Enum=InsertMode::Before)
FlatMessage & set(FlatFieldRef &, UInt64)
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)
FlatFieldRef find(Tag, const FlatFieldRef &) const
FlatMessage & insert(Tag, UInt64, Tag, InsertMode::Enum=InsertMode::Before)
FlatMessage & remove(Tag)
FlatMessage & add(Tag, Char)
FlatMessage & add(Tag, UInt64)
FlatMessage & add(Tag, const Decimal &)
size_t size() const
The size of the flat content.
FlatFieldRef find(Tag) const
FlatMessage(const char *rawMessage, size_t rawMessageSize, bool useZeroCopyBuffer=true)
Constructs an instance from the tag=value form.
FlatMessage & add(Tag, Int64)
FlatMessage & add(Tag, const TimeSpan &, TimeSpanFormat::Enum)
FlatMessage & set(FlatFieldKey, UInt64)
void reset(const char *rawMessage, size_t rawMessageSize)
FlatMessage & insert(Tag, const TimeSpan &, TimeSpanFormat::Enum, Tag, InsertMode::Enum=InsertMode::Before)
FlatMessage & set(FlatFieldRef &, const Decimal &)
FlatMessage & set(FlatFieldKey, UInt32)
FlatFieldKey allocateKey(const FlatFieldRef &)
Allocates a key to the requested field for the further access.
FlatMessage(OnixS::FIX::ProtocolVersion::Enum protocolVersion, const char *msgType)
FlatMessage & add(Tag, const StringRef &)
FlatMessage & set(FlatFieldKey, const Decimal &)
FlatMessage & add(Tag, UInt32)
ConstIterator const_iterator
FlatMessage & set(FlatFieldRef &, const FieldValueRef &)
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)
ConstIterator end() const
Returns the constant iterator to the field after the last one in the FlatMessage instance.
void * userData() const
void adjust()
Updates BodyLength and CheckSum fields.
void userData(void *data)
Attaches a user data to the message.
FlatMessage & set(FlatFieldKey, const StringRef &)
FlatMessage & insert(Tag, UInt32, Tag, InsertMode::Enum=InsertMode::Before)
FlatMessage & set(FlatFieldKey, const TimeSpan &, TimeSpanFormat::Enum)
friend class MessageOperator
FlatMessage & set(FlatFieldKey, const FieldValueRef &)
~FlatMessage()
Utilizes internal resources.
FlatMessage & set(FlatFieldKey, Int64)
FlatMessage & set(FlatFieldRef &, Char)
FlatMessage & set(FlatFieldKey, const Timestamp &, TimestampFormat::Enum)
FlatMessage & set(FlatFieldKey, Char)
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)
FlatFieldRef getFlatFieldRef(const StringRef &value) const
Converts the StringRef value of the given FlatMessage to the FlatFieldRef object.
FlatGroup getGroup(const FlatFieldRef &numberOfInstancesRef) const
FlatMessage(const FlatMessage &other)
Initializes as a copy of the given instance.
FlatMessage & set(FlatFieldRef &, Int64)
FlatMessage(FlatMessage &&moved) noexcept
FlatMessage & add(Tag, Int32)
FlatMessage & set(FlatFieldRef &, const TimeSpan &, TimeSpanFormat::Enum)
FlatMessage & add(Tag, const Timestamp &, TimestampFormat::Enum)
FlatMessage & set(FlatFieldRef &, const StringRef &)
friend class FlatMessageWrapper
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)
std::string toString(char delimiter=0x1) const
FlatMessage & set(FlatFieldKey, Int32)
void swap(FlatMessage &other) noexcept
Swaps the content with another instance.
FlatMessage & insert(Tag, const StringRef &, Tag, InsertMode::Enum=InsertMode::Before)
FlatMessage & set(FlatFieldRef &, const Timestamp &, TimestampFormat::Enum)
const char * chars() const
Returns the content of the flat message.
FlatMessage & set(FlatFieldRef &, UInt32)
ProtocolVersion::Enum version() const
The time span related functionality.
Definition TimeSpan.h:94
The timestamps related functionality.
Definition Timestamp.h:92
ONIXS_FIXENGINE_API std::ostream & operator<<(std::ostream &os, const FlatMessage &message)
The stream output.
ONIXS_FIXENGINE_API_DECL(class, IEngineListener)
FlatMessage SerializedMessage
unsigned int UInt32
Definition Numeric.h:36
long long Int64
Definition Numeric.h:38
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