OnixS C++ Eurex T7 Market and Reference Data Interface (EMDI, RDI, EOBI) Handlers  8.0.0
API documentation
Formatting.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 
26 
27 #include <util/TextBuilder.h>
28 #include <util/Base64Encoding.h>
29 
30 #include <OnixS/FIX/Core/Messaging.h>
31 
32 #include "HandlerLogger.h"
33 #include "Formatting.Helpers.h"
35 #include "EOBI/Heartbeat.h"
36 
37 #include <boost/foreach.hpp>
38 
39 namespace OnixS {
40 namespace Eurex {
41 namespace MarketData {
42 
44 
45 /////////////////////////////////////////////////////////////////////////////////////////
46 // Forwards
47 
48 
49 /////////////////////////////////////////////////////////////////////////////////////////
50 // Formatting declarations
51 
52 inline
53 TextBuilder & operator<<(TextBuilder & o, const StringRef & ref) {
54  return o << ref.toString();
55 }
56 
57 inline
58 TextBuilder & operator<<(TextBuilder & o, const Decimal & value) {
59  return o << value.toString();
60 }
61 
65 
66 
67 inline
68 TextBuilder & operator<<(TextBuilder & o, const EmdiDescriptor & var)
69 {
70  o << "EMDI Descriptor:" << '\n';
71  o << Util::indent(4);
72 
73  o << "Feeds:" << (InterfaceDescriptor&)var << '\n';
74  BOOST_FOREACH(const ProductInfo& productInfo, var.productInfos)
75  {
76  o << '\n' << productInfo.marketSegment << ": id=" << productInfo.marketSegmentId << ", partId=" << productInfo.partitionId << ", depth=" << productInfo.marketDepth;
77  }
78 
79  return o << '\n' << Util::indent(-4);
80 }
81 
82 inline
83 TextBuilder & operator<<(TextBuilder & o, const MdiDescriptor & var)
84 {
85  o << "MDI Descriptor:" << '\n';
86  o << Util::indent(4);
87 
88  o << "Feeds:" << (InterfaceDescriptor&)var << '\n';
89  BOOST_FOREACH(const ProductInfo& productInfo, var.productInfos)
90  {
91  o << '\n' << productInfo.marketSegment << ": id=" << productInfo.marketSegmentId << ", partId=" << productInfo.partitionId << ", depth=" << productInfo.marketDepth;
92  }
93 
94  return o << '\n' << Util::indent(-4);
95 }
96 
97 inline
98 TextBuilder & operator<<(TextBuilder & o, const EobiDescriptor & var)
99 {
100  o << "EOBI Descriptor:" << '\n';
101  o << Util::indent(4);
102 
103  o << "Feeds:" << (InterfaceDescriptor&)var << '\n';
104  BOOST_FOREACH(const ProductInfo& productInfo, var.productInfos)
105  {
106  o << '\n' << productInfo.marketSegment << ": id=" << productInfo.marketSegmentId << ", partId=" << productInfo.partitionId;
107  }
108 
109  return o << '\n' << Util::indent(-4);
110 }
111 
112 namespace EOBI
113 {
114 
115 #define DECLARE_EOBI_MESSAGE_FORMAT(MessageName)\
116 inline \
117 TextBuilder & operator<<(TextBuilder & o, const MessageName & msg)\
118 {\
119  msg.toString(o.buffer());\
120  return o;\
121 }\
122 
123 
125 
129 
149 
150 std::string messageName(UInt16 templateId);
151 
152 namespace Implementation
153 {
154 
155 inline TextBuilder & operator<<(TextBuilder & o, const BaseMsgData &msg)
156 {
158  return o << messageName(msg.TemplateID);
159  else
160  return o << messageName(msg.TemplateID)
161  << " [" << msg.MsgSeqNum << "]";
162 }
163 
164 } // Implementation
165 } // EOBI
166 
167 namespace Implementation {
168 
170  const char * const data;
171  size_t const size;
172 
173  Base64Wrapper(const char * aData, size_t aSize)
174  : data(aData), size(aSize){}
175 
176  Base64Wrapper(const unsigned char * aData, size_t aSize)
177  : data((const char *)aData), size(aSize) {}
178 };
179 
180 inline
181 TextBuilder & operator<<(TextBuilder & o, const Base64Wrapper & var)
182 {
183  return o << Base64Encoding::encode(var.data, var.size);
184 }
185 
186 }
187 
188 
189 inline
190 TextBuilder & operator<<(TextBuilder & o, const SnapshotTrade & trade)
191 {
192  trade.toString(o.buffer());
193  return o;
194 }
195 
196 inline
197 TextBuilder & operator<<(TextBuilder & o, const IncrementalTrade & trade)
198 {
199  trade.toString(o.buffer());
200  return o;
201 }
202 
203 
204 }}} // OnixS::Eurex::MarketData
205 
206 
207 /////////////////////////////////////////////////////////////////////////////////////
208 // Declare formatting of non-Eurex types in Logging namespace
209 namespace OnixS {
210 namespace Util {
211 
212 namespace {
213 
214 const OnixS::FIX::Core::Messaging::Extras::Stringing::FieldDelimiter fieldDelimiterPresenter('|');
215 
216 }
217 
218 inline
219 TextBuilder & operator<<(TextBuilder& o, const FIX::Core::Messaging::Message& msg)
220 {
221  OnixS::FIX::Core::Messaging::Extras::toString(msg,
222  OnixS::FIX::Core::Messaging::Extras::Stringing::EnhancedNamedFieldPresenter(
223  msg.dictionary().fields()),
224  fieldDelimiterPresenter,
225  o.buffer());
226  return o;
227 }
228 
229 inline
230 TextBuilder & operator<<(TextBuilder& o, const FIX::Core::Messaging::Message* msg)
231 {
232  return o << *msg;
233 }
234 
235 }} // OnixS::Util
236 
237 
#define DECLARE_EOBI_MESSAGE_FORMAT(MessageName)
Definition: Formatting.h:115
Base64Wrapper(const unsigned char *aData, size_t aSize)
Definition: Formatting.h:176
void toString(std::string &) const ONIXS_EUREX_EMDI_OVERRIDE
Appends text presentation.
Definition: Trade.cpp:73
Util::TextBuilder TextBuilder
Definition: Formatting.h:43
UInt32 marketDepth
Maximum number of price levels for the product in EMDI.
void toString(std::string &) const ONIXS_EUREX_EMDI_OVERRIDE
Appends text presentation.
Definition: Trade.cpp:37
Definition: Defines.h:30
Decimal type for better precision.
Definition: Numeric.h:63
ProductInfos productInfos
Contains information about all products for the interface.
std::string messageName(UInt16 templateId)
Definition: Formatting.cpp:41
#define DECL_FORMAT(ftype)
Definition: HandlerLogger.h:54
TextBuilder & operator<<(TextBuilder &o, const BaseMsgData &msg)
Definition: Formatting.h:155
MarketSegmentId marketSegmentId
Market segment id.
unsigned short UInt16
Definition: Numeric.h:38
ProductInfos productInfos
Contains information about all products for the interface.
void toString(std::string &) const
Appends text presentation to given string.
Definition: Decimal.cpp:217
Service endpoint description.
ONIXS_EUREX_EMDI_API std::ostream & operator<<(std::ostream &stream, const FeedEngineSettings &settings)
void toString(std::string &str) const
Definition: StringRef.h:175
MarketSegment marketSegment
Market segment (product name).
ProductInfos productInfos
Contains information about all products for the interface.
Base64Wrapper(const char *aData, size_t aSize)
Definition: Formatting.h:173