OnixS C++ Eurex T7 Market and Reference Data Interface (EMDI, RDI, EOBI) Handlers  7.2.2
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 
25 
26 #include <util/TextBuilder.h>
27 #include <util/Base64Encoding.h>
28 
29 #include <OnixS/FIX/Core/Messaging.h>
30 
31 #include "HandlerLogger.h"
32 #include "Formatting.Helpers.h"
34 #include "EOBI/Heartbeat.h"
35 
36 #include <boost/foreach.hpp>
37 
38 namespace OnixS {
39 namespace Eurex {
40 namespace MarketData {
41 
43 
44 /////////////////////////////////////////////////////////////////////////////////////////
45 // Forwards
46 
47 
48 /////////////////////////////////////////////////////////////////////////////////////////
49 // Formatting declarations
50 
51 inline
52 TextBuilder & operator<<(TextBuilder & o, const StringRef & ref) {
53  return o << ref.toString();
54 }
55 
56 inline
57 TextBuilder & operator<<(TextBuilder & o, const Decimal & value) {
58  return o << value.toString();
59 }
60 
64 
65 
66 inline
67 TextBuilder & operator<<(TextBuilder & o, const EmdiDescriptor & var)
68 {
69  o << "EMDI Descriptor:" << '\n';
70  o << Util::indent(4);
71 
72  o << "Feeds:" << (InterfaceDescriptor&)var << '\n';
73  BOOST_FOREACH(const ProductInfo& productInfo, var.productInfos)
74  {
75  o << '\n' << productInfo.marketSegment << ": id=" << productInfo.marketSegmentId << ", partId=" << productInfo.partitionId << ", depth=" << productInfo.marketDepth;
76  }
77 
78  return o << '\n' << Util::indent(-4);
79 }
80 
81 inline
82 TextBuilder & operator<<(TextBuilder & o, const EobiDescriptor & var)
83 {
84  o << "EOBI Descriptor:" << '\n';
85  o << Util::indent(4);
86 
87  o << "Feeds:" << (InterfaceDescriptor&)var << '\n';
88  BOOST_FOREACH(const ProductInfo& productInfo, var.productInfos)
89  {
90  o << '\n' << productInfo.marketSegment << ": id=" << productInfo.marketSegmentId << ", partId=" << productInfo.partitionId;
91  }
92 
93  return o << '\n' << Util::indent(-4);
94 }
95 
96 namespace EOBI
97 {
98 
99 #define DECLARE_EOBI_MESSAGE_FORMAT(MessageName)\
100 inline \
101 TextBuilder & operator<<(TextBuilder & o, const MessageName & msg)\
102 {\
103  msg.toString(o.buffer());\
104  return o;\
105 }\
106 
107 
109 
113 
133 
134 std::string messageName(UInt16 templateId);
135 
136 namespace Implementation
137 {
138 
139 inline TextBuilder & operator<<(TextBuilder & o, const BaseMsgData &msg)
140 {
142  return o << messageName(msg.TemplateID);
143  else
144  return o << messageName(msg.TemplateID)
145  << " [" << msg.MsgSeqNum << "]";
146 }
147 
148 } // Implementation
149 } // EOBI
150 
151 namespace Implementation {
152 
154  const char * const data;
155  size_t const size;
156 
157  Base64Wrapper(const char * aData, size_t aSize)
158  : data(aData), size(aSize){}
159 
160  Base64Wrapper(const unsigned char * aData, size_t aSize)
161  : data((const char *)aData), size(aSize) {}
162 };
163 
164 inline
165 TextBuilder & operator<<(TextBuilder & o, const Base64Wrapper & var)
166 {
167  return o << Base64Encoding::encode(var.data, var.size);
168 }
169 
170 }
171 
172 
173 }}} // OnixS::Eurex::MarketData
174 
175 
176 /////////////////////////////////////////////////////////////////////////////////////
177 // Declare formatting of non-Eurex types in Logging namespace
178 namespace OnixS {
179 namespace Util {
180 
181 namespace {
182 
183 const OnixS::FIX::Core::Messaging::Extras::Stringing::FieldDelimiter fieldDelimiterPresenter('|');
184 
185 }
186 
187 inline
188 TextBuilder & operator<<(TextBuilder& o, const FIX::Core::Messaging::Message& msg)
189 {
190  OnixS::FIX::Core::Messaging::Extras::toString(msg,
191  OnixS::FIX::Core::Messaging::Extras::Stringing::EnhancedNamedFieldPresenter(
192  msg.dictionary().fields()),
193  fieldDelimiterPresenter,
194  o.buffer());
195  return o;
196 }
197 
198 inline
199 TextBuilder & operator<<(TextBuilder& o, const FIX::Core::Messaging::Message* msg)
200 {
201  return o << *msg;
202 }
203 
204 }} // OnixS::Util
205 
206 
#define DECLARE_EOBI_MESSAGE_FORMAT(MessageName)
Definition: Formatting.h:99
Base64Wrapper(const unsigned char *aData, size_t aSize)
Definition: Formatting.h:160
Util::TextBuilder TextBuilder
Definition: Formatting.h:42
UInt32 marketDepth
Maximum number of price levels for the product.
Definition: Defines.h:30
Decimal type for better precision.
Definition: Numeric.h:63
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:139
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:157