OnixS C++ Eurex T7 Market and Reference Data Interface (EMDI, RDI, EOBI) Handlers  7.4.3
API documentation
FieldValueRef.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 <OnixS/HandlerCore/Compiler.h>
20 
21 #include "MessageOperator.h"
22 #include "Utils.h"
23 
24 namespace OnixS {
25 namespace Eurex {
26 namespace MarketData {
27 
29 
30 FieldValueRef::FieldValueRef(const Message* container, const void* impl) :
31  impl_(impl),
32  container_(container)
33 {
34 }
35 
37  impl_(other.impl_),
38  container_(other.container_)
39 {
40 }
41 
43  impl_(&CORE::FieldValue::Null),
44  container_(nullptr)
45 {
46 }
47 
48 void
50 {
51  std::swap(impl_, other.impl_);
52  std::swap(container_, other.container_);
53 }
54 
57  const FieldValueRef& other)
58 {
59  if (&other == this)
60  return *this;
61 
62  FieldValueRef tmp(other);
63 
64  tmp.swap(*this);
65 
66  return *this;
67 }
68 
69 FieldValueRef::operator bool() const
70 {
71  return CORE::DataTypes::Null !=
72  MessageOperator::getCore(*this).type();
73 }
74 
75 bool
77 {
78  return MessageOperator::getCore(*this).convertTo(number);
79 }
80 
81 bool
83 {
84  return MessageOperator::getCore(*this).convertTo(number);
85 }
86 
87 bool
88 FieldValueRef::toNumber(Int64& number) const
89 {
90  OnixS::Int64 converted;
91 
92  if (MessageOperator::getCore(*this).convertTo(converted))
93  {
94  number = converted;
95 
96  return true;
97  }
98 
99  return false;
100 }
101 
102 bool
103 FieldValueRef::toNumber(UInt64& number) const
104 {
105  OnixS::UInt64 converted;
106 
107  if (MessageOperator::getCore(*this).convertTo(converted))
108  {
109  number = converted;
110 
111  return true;
112  }
113 
114  return false;
115 }
116 
117 bool
120 {
121  CORE::Decimal converted;
122 
123  if (MessageOperator::getCore(*this).convertTo(converted))
124  {
125  number.mantissa(converted.mantissa());
126  number.exponent(converted.exponent());
127 
128  return true;
129  }
130 
131  return false;
132 }
133 
134 bool
136  Timestamp& timestamp,
137  TimestampFormat::Enum timestampFormat) const
138 {
139  switch (timestampFormat)
140  {
142  {
143  CORE::YYYYMMDD converted;
144 
145  return
146  MessageOperator::getCore(*this).convertTo(converted)
147  ? (timestamp = TimeManager::convert(converted), true)
148  : false;
149  }
150 
152  {
153  CORE::YYYYMMDDHHMMSS converted;
154 
155  return
156  MessageOperator::getCore(*this).convertTo(converted)
157  ? (timestamp = TimeManager::convert(converted), true)
158  : false;
159  }
160 
162  {
163  CORE::YYYYMMDDHHMMSSMsec converted;
164 
165  return
166  MessageOperator::getCore(*this).convertTo(converted)
167  ? (timestamp = TimeManager::convert(converted), true)
168  : false;
169  }
170 
172  {
173  CORE::YYYYMMDDHHMMSSNsec converted;
174 
175  return
176  MessageOperator::getCore(*this).convertTo(converted)
177  ? (timestamp = TimeManager::convert(converted), true)
178  : false;
179  }
180 
181  default:
182  return false;
183  }
184 }
185 
186 bool
188 toStringRef(StringRef& value) const
189 {
190  OnixS::ConstStringRef strRef;
191 
192  if (MessageOperator::getCore(*this).convertTo(strRef))
193  {
194  value.reset(strRef.chars(), strRef.size());
195 
196  return true;
197  }
198 
199  return false;
200 }
201 
202 bool
203 FieldValueRef::toChar(char& value) const
204 {
205  return MessageOperator::getCore(*this).convertTo(value);
206 }
207 
208 bool
210 {
211  const CORE::RepeatingGroup* groupImpl;
212 
213  if (MessageOperator::getCore(*this).convertTo(groupImpl))
214  {
216  *container_, const_cast<CORE::RepeatingGroup&>(*groupImpl));
217 
218  return true;
219  }
220 
221  return false;
222 }
223 
224 void
225 FieldValueRef::toString(std::string& str) const
226 {
227  MessageOperator::getCore(*this).toString(str);
228 }
229 
230 bool
232  const FieldValueRef& other) const
233 {
234  return MessageOperator::getCore(*this) ==
236 }
237 
238 bool
240  const FieldValueRef& other) const
241 {
242  return MessageOperator::getCore(*this) !=
244 }
245 
246 bool
248 operator ==(const StringRef& other) const
249 {
250  return MessageOperator::getCore(*this) ==
251  OnixS::ConstStringRef(other.data(), other.size());
252 }
253 
254 bool
256 operator !=(const StringRef& other) const
257 {
258  return MessageOperator::getCore(*this) !=
259  OnixS::ConstStringRef(other.data(), other.size());
260 }
261 
262 
263 }}}
264 
void reset()
Resets reference to nothing.
Definition: StringRef.h:130
Indicates timestamp in "YYYYMMDD-HH:MM:SS.sss" format.
Definition: Timestamp.h:72
const char * data() const
Read-only content.
Definition: StringRef.h:106
DecimalMantissa mantissa() const
Returns mantissa part of decimal.
Definition: Numeric.h:199
unsigned int UInt32
Definition: Numeric.h:41
Definition: Defines.h:30
Decimal type for better precision.
Definition: Numeric.h:63
bool toTimestamp(Timestamp &, TimestampFormat::Enum=TimestampFormat::YYYYMMDDHHMMSSNsec) const
Indicates timestamp in "YYYYMMDD" format.
Definition: Timestamp.h:66
DecimalExponent exponent() const
Returns exponent part of decimal.
Definition: Numeric.h:214
static Group constructGroup(const FieldSet &fieldSet, OnixS::FIX::Core::Messaging::RepeatingGroup &group)
Represents timestamp without time-zone information.
Definition: Timestamp.h:80
Indicates timestamp in "YYYYMMDD-HH:MM:SS" format.
Definition: Timestamp.h:69
std::string toString() const
Return string presentation of field value.
FieldValueRef & operator=(const FieldValueRef &)
bool operator==(const FieldValueRef &) const
Compares with another instance for equality.
static const OnixS::FIX::Core::Messaging::FieldValue & getCore(const FieldValueRef &value)
Indicates timestamp in "YYYYMMDD-HH:MM:SS.sssssssss" format.
Definition: Timestamp.h:75
bool operator!=(const FieldValueRef &) const
Compares with another instance for inequality.
static Timestamp convert(const OnixS::Time::DateTime &time)
Definition: Utils.cpp:169
size_t size() const
Number of chars.
Definition: StringRef.h:124