OnixS C++ Eurex T7 Market and Reference Data Interface (EMDI, RDI, EOBI) Handlers  8.0.0
API documentation
FieldSet.cpp
Go to the documentation of this file.
1 // Copyright Onix Solutions Limited [OnixS]. All rights reserved.
2 //
3 // This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
4 // and international copyright treaties.
5 //
6 // Access to and use of the software is governed by the terms of the applicable ONIXS Software
7 // Services Agreement (the Agreement) and Customer end user license agreements granting
8 // a non-assignable, non-transferable and non-exclusive license to use the software
9 // for it's own data processing purposes under the terms defined in the Agreement.
10 //
11 // Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
12 // of this source code or associated reference material to any other location for further reproduction
13 // or redistribution, and any amendments to this copyright notice, are expressly prohibited.
14 //
15 // Any reproduction or redistribution for sale or hiring of the Software not in accordance with
16 // the terms of the Agreement is a violation of copyright law.
17 //
18 
19 #include "MessageOperator.h"
20 #include "Utils.h"
21 //#include "Helpers.h"
22 
23 
24 
25 namespace OnixS {
26 namespace Eurex {
27 namespace MarketData {
28 
29 using namespace std;
30 
32 
33 #undef BEGIN_TRANSLATE_EXCEPTION
34 #define BEGIN_TRANSLATE_EXCEPTION \
35  try \
36  {
37 
38 #undef END_TRANSLATE_EXCEPTION
39 #define END_TRANSLATE_EXCEPTION \
40  } \
41  catch (const CORE::Exception& ex) \
42  { \
43  translateException(container_, ex); \
44  throw; \
45  }
46 
47 namespace
48 {
49  void
50  translateException(
51  const Message* message,
52  const CORE::Exception& ex)
53  {
54  if (!ex.source() && message)
55  {
56  string errorReason;
57 
58  ex.toString(errorReason);
59 
60  CORE::MessageInfo(
61  MessageOperator::getCore(*message)).
62  toString(errorReason);
63 
64  errorReason += ". ";
65 
66  throw OnixS::DomainException(errorReason);
67  }
68  }
69 }
70 
72 : container_(nullptr)
73 , impl_(nullptr)
74 {
75 }
76 
77 FieldSet::FieldSet(const Message* container, void* impl)
78 : container_(container)
79 , impl_(impl)
80 {
81 }
82 
84 : container_(other.container_)
85 , impl_(other.impl_)
86 {
87 }
88 
90 {
91 }
92 
93 void
94 FieldSet::swap(FieldSet& other) throw()
95 {
96  std::swap(impl_, other.impl_);
97  std::swap(container_, other.container_);
98 }
99 
100 FieldSet&
102  const FieldSet& other)
103 {
104  if (&other == this)
105  return *this;
106 
107  FieldSet tmp(other);
108 
109  tmp.swap(*this);
110 
111  return *this;
112 }
113 
114 FieldSet::operator bool() const
115 {
116  return (
117  nullptr != impl_ &&
118  MessageOperator::getCore(*this));
119 }
120 
122 FieldSet::get(Tag tag) const
123 {
125 
126  return MessageOperator::
128  *this,
129  tag);
130 
132 }
133 
134 Int32
136 {
138 
139  return CORE::
140  CompliantAccessor::getInt32(
141  MessageOperator::getCore(*this),
142  tag,
143  CORE::CompliantAccessPolicies::None);
144 
146 }
147 
148 UInt32
150 {
152 
153  return CORE::
154  CompliantAccessor::getUInt32(
155  MessageOperator::getCore(*this),
156  tag,
157  CORE::CompliantAccessPolicies::None);
158 
160 }
161 
162 Int64
164 {
166 
167  return CORE::
168  CompliantAccessor::getInt64(
169  MessageOperator::getCore(*this),
170  tag,
171  CORE::CompliantAccessPolicies::None);
172 
174 }
175 
176 UInt64
178 {
180 
181  return CORE::
182  CompliantAccessor::getUInt64(
184  tag,
185  CORE::CompliantAccessPolicies::None);
186 
188 }
189 
192 {
194 
195  CORE::Decimal decimal =
196  CORE::CompliantAccessor::getDecimal(
197  MessageOperator::getCore(*this),
198  tag,
199  CORE::CompliantAccessPolicies::None);
200 
202  decimal.mantissa(), decimal.exponent());
203 
205 }
206 
209 {
211 
212  OnixS::ConstStringRef str =
213  CORE::CompliantAccessor::getString(
214  MessageOperator::getCore(*this),
215  tag,
216  CORE::CompliantAccessPolicies::None);
217 
218  return StringRef(
219  str.chars(), str.size());
220 
222 }
223 
224 Timestamp
226  Tag tag,
227  TimestampFormat::Enum format) const
228 {
230 
231  switch (format)
232  {
234  {
235  return TimeManager::convert(
236  CORE::CompliantAccessor::getYYYYMMDD(
238  tag,
239  CORE::CompliantAccessPolicies::None));
240  }
241 
243  {
244  return TimeManager::convert(
245  CORE::CompliantAccessor::getYYYYMMDDHHMMSS(
247  tag,
248  CORE::CompliantAccessPolicies::None));
249  }
250 
252  {
253  return TimeManager::convert(
254  CORE::CompliantAccessor::getYYYYMMDDHHMMSSMsec(
256  tag,
257  CORE::CompliantAccessPolicies::None));
258  }
259 
261  {
262  return TimeManager::convert(
263  CORE::CompliantAccessor::getYYYYMMDDHHMMSSNsec(
265  tag,
266  CORE::CompliantAccessPolicies::None));
267  }
268 
269  default:
270  {
271  throw DomainException(
272  "Unknown timestamp format specified. ");
273  }
274  break;
275  }
276 
278 }
279 
280 Group
282  Tag numberOfInstancesTag) const
283 {
285 
286  return MessageOperator::
288  *this,
289  numberOfInstancesTag);
290 
292 }
293 
294 Group
296  Tag numberOfInstancesTag) const
297 {
299 
300  return MessageOperator::
302  *this,
303  numberOfInstancesTag);
304 
306 }
307 
308 bool
310 {
312 
313  return CORE::
314  CompliantAccessor::hasFlag(
315  MessageOperator::getCore(*this),
316  tag,
317  CORE::CompliantAccessPolicies::None);
318 
320 }
321 
322 size_t
324 {
326 
327  const CORE::FieldSet& fieldSet =
329 
330  dest.clear();
331 
332  for (
333  CORE::IndexedFieldsConstIterator
334  field = fieldSet.indexed().begin(),
335  endOfFields = fieldSet.indexed().end();
336  field != endOfFields;
337  ++field)
338  {
339  if (field->value().type() != CORE::DataTypes::Null)
340  {
341  dest.push_back(
342  Field(
343  field->tag(),
345  *this,
346  field->tag())));
347  }
348  }
349 
350  for (
351  CORE::LinkedFieldsConstIterator
352  field = fieldSet.undefined().begin(),
353  endOfFields = fieldSet.undefined().end();
354  field != endOfFields; ++field)
355  {
356  if (field->value().type() != CORE::DataTypes::Null)
357  {
358  dest.push_back(
359  Field(
360  field->tag(),
362  *this,
363  field->tag())));
364  }
365  }
366 
367  return dest.size();
368 
370 }
371 
372 
373 }}}
374 
Indicates timestamp in "YYYYMMDD-HH:MM:SS.sss" format.
Definition: Timestamp.h:72
Group getGroup(Tag numberOfInstancesTag) const
Definition: FieldSet.cpp:281
Decimal getDecimal(Tag tag) const
Definition: FieldSet.cpp:191
FieldSet & operator=(const FieldSet &)
Definition: FieldSet.cpp:101
StringRef getStringRef(Tag tag) const
Definition: FieldSet.cpp:208
STL namespace.
Group getOptionalGroup(Tag numberOfInstancesTag) const
Definition: FieldSet.cpp:295
size_t fields(Fields &fields) const
Definition: FieldSet.cpp:323
unsigned Tag
Alias for tag numbers.
Definition: Tag.h:29
unsigned int UInt32
Definition: Numeric.h:41
Definition: Defines.h:30
Decimal type for better precision.
Definition: Numeric.h:63
FieldValueRef get(Tag tag) const
Definition: FieldSet.cpp:122
Field primary attributes (tag and a reference to a value).
Definition: FieldSet.h:40
Indicates timestamp in "YYYYMMDD" format.
Definition: Timestamp.h:66
bool hasFlag(Tag tag) const
Definition: FieldSet.cpp:309
UInt32 getUInt32(Tag tag) const
Definition: FieldSet.cpp:149
#define BEGIN_TRANSLATE_EXCEPTION
Definition: FieldSet.cpp:34
static Group constructGroup(const FieldSet &fieldSet, OnixS::FIX::Core::Messaging::RepeatingGroup &group)
Int64 getInt64(Tag tag) const
Definition: FieldSet.cpp:163
Represents timestamp without time-zone information.
Definition: Timestamp.h:80
Indicates timestamp in "YYYYMMDD-HH:MM:SS" format.
Definition: Timestamp.h:69
std::vector< Field > Fields
Ordered collection of fields.
Definition: FieldSet.h:62
UInt64 getUInt64(Tag tag) const
Definition: FieldSet.cpp:177
static Group constructOptionalGroup(const FieldSet &fieldSet, Tag tag)
#define END_TRANSLATE_EXCEPTION
Definition: FieldSet.cpp:39
Int32 getInt32(Tag tag) const
Definition: FieldSet.cpp:135
static const OnixS::FIX::Core::Messaging::FieldValue & getCore(const FieldValueRef &value)
Indicates timestamp in "YYYYMMDD-HH:MM:SS.sssssssss" format.
Definition: Timestamp.h:75
static Timestamp convert(const OnixS::Time::DateTime &time)
Definition: Utils.cpp:168
Timestamp getTimestamp(Tag tag, TimestampFormat::Enum=TimestampFormat::YYYYMMDDHHMMSSNsec) const
Definition: FieldSet.cpp:225
static FieldValueRef constructField(const FieldSet &fieldSet, Tag tag)