OnixS C++ CME MDP Conflated UDP Handler 1.1.2
API documentation
Loading...
Searching...
No Matches
Field.h
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
4// protected by copyright law and international copyright treaties.
5//
6// Access to and use of the software is governed by the terms of the applicable
7// OnixS Software Services Agreement (the Agreement) and Customer end user license
8// agreements granting a non-assignable, non-transferable and non-exclusive license
9// to use the software for it's own data processing purposes under the terms defined
10// in the Agreement.
11//
12// Except as otherwise granted within the terms of the Agreement, copying or
13// reproduction of any part of this source code or associated reference material
14// to any other location for further reproduction or redistribution, and any
15// amendments to this copyright notice, are expressly prohibited.
16//
17// Any reproduction or redistribution for sale or hiring of the Software not in
18// accordance with the terms of the Agreement is a violation of copyright law.
19//
20
21#pragma once
22
25
27
33{
34 ValueContainer value_;
35 const ValueConverter* converter_;
36
37protected:
40 const
41 ValueConverter& converter)
42 : value_(), converter_(&converter)
43 {
44 }
45
47 const ValueContainer& value() const
48 {
49 return value_;
50 }
51
54 {
55 return value_;
56 }
57
58public:
61 : value_()
62 , converter_
63 (
65 self()
66 )
67 {
68 }
69
72 const Field& other)
73 : value_(other.value_)
74 , converter_(other.converter_)
75 {
76 }
77
80 operator bool() const
81 {
82 return (
83 converter_ !=
85 );
86 }
87
96 template
97 <
98 class Value
99 >
100 typename
102 cast() const
103 {
105
106 return
107 convert
108 (
109 *converter_,
110 value_
111 );
112 }
113
117 bool
119 StrRef& str) const
120 {
121 return
122 converter_->convert
123 (
124 str,
125 value_
126 );
127 }
128
132 bool
134 Char& value) const
135 {
136 return
137 converter_->convert
138 (
139 value,
140 value_
141 );
142 }
143
147 bool
149 Int8& value) const
150 {
151 return
152 converter_->convert
153 (
154 value,
155 value_
156 );
157 }
158
162 bool
164 UInt8& value) const
165 {
166 return
167 converter_->convert
168 (
169 value,
170 value_
171 );
172 }
173
177 bool
179 Int16& value) const
180 {
181 return
182 converter_->convert
183 (
184 value,
185 value_
186 );
187 }
188
192 bool
194 UInt16& value) const
195 {
196 return
197 converter_->convert
198 (
199 value,
200 value_
201 );
202 }
203
207 bool
209 Int32& value) const
210 {
211 return
212 converter_->convert
213 (
214 value,
215 value_
216 );
217 }
218
222 bool
224 UInt32& value) const
225 {
226 return
227 converter_->convert
228 (
229 value,
230 value_
231 );
232 }
233
237 bool
239 Int64& value) const
240 {
241 return
242 converter_->convert
243 (
244 value,
245 value_
246 );
247 }
248
252 bool
254 UInt64& value) const
255 {
256 return
257 converter_->convert
258 (
259 value,
260 value_
261 );
262 }
263
267 bool
269 Timestamp& value) const
270 {
271 return
272 converter_->convert
273 (
274 value,
275 value_
276 );
277 }
278
282 bool
285 {
286 return
287 converter_->convert
288 (
289 value,
290 value_
291 );
292 }
293
297 template
298 <
299 class Enumeration
300 >
301 bool
303 typename
304 Enumeration::Enum& value) const
305 {
306 typename
307 Enumeration::Base
308 integral;
309
310 if (converter_->
311 convert(
312 integral,
313 value_))
314 {
315 value =
316 static_cast
317 <
318 typename
319 Enumeration::Enum
320 >
321 (integral);
322
323 return true;
324 }
325
326 return false;
327 }
328
332 template
333 <
334 class BitSet
335 >
336 bool
338 BitSet& value,
339 typename BitSet::Bits* = NULL) const
340 {
341 typename BitSet::Bits bits;
342
343 if (converter_->
344 convert(
345 bits,
346 value_))
347 {
348 value = BitSet(bits);
349
350 return true;
351 }
352
353 return false;
354 }
355
357 std::string
358 toStr() const
359 {
360 std::string str;
361
362 toStr(str);
363
364 return str;
365 }
366
368 void
370 std::string& str) const
371 {
372 converter_->toStr
373 (
374 str,
375 value_
376 );
377 }
378
380 Field&
381 operator =(
382 const Field& other)
383 {
384 value_ = other.value_;
385 converter_ = other.converter_;
386
387 return *this;
388 }
389};
390
#define ONIXS_CONFLATEDUDP_LTWT_CLASS
Definition Bootstrap.h:95
#define ONIXS_CONFLATEDUDPFIX_NAMESPACE_BEGIN
Definition Bootstrap.h:161
#define ONIXS_CONFLATEDUDPFIX_NAMESPACE_END
Definition Bootstrap.h:165
const ValueContainer & value() const
Exposes value storage for further value manipulations.
Definition Field.h:47
bool tryCast(Int16 &value) const
Definition Field.h:178
bool tryCast(Int8 &value) const
Definition Field.h:148
bool tryCast(MaturityMonthYear &value) const
Definition Field.h:283
Field()
Initializes the field with no value.
Definition Field.h:60
Field(const Field &other)
Initializes as the copy of the other field.
Definition Field.h:71
bool tryCast(UInt64 &value) const
Definition Field.h:253
bool tryCast(Char &value) const
Definition Field.h:133
std::string toStr() const
Returns the text representation.
Definition Field.h:358
bool tryCast(StrRef &str) const
Definition Field.h:118
bool tryCast(UInt8 &value) const
Definition Field.h:163
bool tryCast(Timestamp &value) const
Definition Field.h:268
ValueContainer & value()
Exposes value storage for further value manipulations.
Definition Field.h:53
bool tryCast(UInt16 &value) const
Definition Field.h:193
bool tryCast(UInt32 &value) const
Definition Field.h:223
bool tryCast(Int64 &value) const
Definition Field.h:238
bool tryCast(typename Enumeration::Enum &value) const
Definition Field.h:302
void toStr(std::string &str) const
Outputs the text representation into the given string.
Definition Field.h:369
bool tryCast(BitSet &value, typename BitSet::Bits *=NULL) const
Definition Field.h:337
ValueConversion< Value >::Result cast() const
Definition Field.h:102
bool tryCast(Int32 &value) const
Definition Field.h:208
Field(const ValueConverter &converter)
Initializes the field.
Definition Field.h:39
Container for a value of any supported kinds.
Represents time point without time-zone information.
Definition Time.h:472
UInt64 UInt64
uInt64.
Definition Fields.h:265
Int32 Int32
int32.
Definition Fields.h:69
char Char
Character type alias.
Definition String.h:36
UInt32 UInt32
uInt32.
Definition Fields.h:261
Int16 Int16
int16.
Definition Fields.h:65
UInt16 UInt16
uInt16.
Definition Fields.h:257
Traits::Result Result
Conversion output type.