OnixS C++ CME iLink 3 Binary Order Entry Handler  1.18.0
API Documentation
Composites.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 
23 #include <OnixS/CME/iLink3/ABI.h>
24 
28 
30 ONIXS_ILINK3_DATA_PACKING_BEGIN(1)
31 
32 /// DATA Field.
33 /// FIX type: data.
35 {
36 public:
37  /// Size of the composite.
38  enum { Size = 2 };
39 
40  /// Length type.
41  typedef UInt16 Length;
42 
43  /// VarData type.
44  typedef Char VarData;
45 
46  /// \return length.
48  Length length() const
50  {
51  return length_;
52  }
53 
54  /// Sets the length.
55  void length(Length value)
57  {
58  length_ = value;
59  }
60 
61  /// \return the varData field.
63  StrRef varData() const
65  {
66  return StrRef(reinterpret_cast<const Char*>(this) + Size, length());
67  }
68 
69  /// Sets the varData field.
70  void varData(StrRef value)
72  {
73  length(static_cast<Length>(value.size()));
74  if(value.data())
75  std::memcpy(reinterpret_cast<Char*>(this) + Size, value.data(), value.size());
76  }
77 
78  /// \return Size of SBE-encoded data representing the field.
80  Length binarySize() const
82  {
83  return Size + length();
84  }
85 
86 private:
87  Length length_;
88 };
89 
90 
91 /// Repeating group dimensions.
92 ///
93 /// FIX type: NumInGroup.
95 {
96 public:
97  /// Size of the composite.
98  enum { Size = 3 };
99 
100  /// Type alias for the `BlockLength`.
102 
103  /// Type alias for the `NumInGroup`.
104  typedef UInt8 NumInGroup;
105 
106  /// \return the `blockLength` field.
108  BlockLength blockLength() const
110  {
111  return blockLength_;
112  }
113 
114  /// Sets the `blockLength` field.
115  void setBlockLength(BlockLength value)
117  {
118  blockLength_ = value;
119  }
120 
121  /// \return the `numInGroup` field.
123  NumInGroup numInGroup() const
125  {
126  return numInGroup_;
127  }
128 
129  /// Sets the `numInGroup` field.
130  void setNumInGroup(NumInGroup value)
132  {
133  numInGroup_ = value;
134  }
135 
136 private:
137  BlockLength blockLength_;
138  NumInGroup numInGroup_;
139 };
140 
141 
142 /// Repeating group dimensions.
144 {
145 public:
146  /// Size of the composite.
147  enum { Size = 4 };
148 
149  /// Type alias for the `BlockLength`.
150  ///
151  /// FIX type: Length.
153 
154  /// Type alias for the `NumInGroup`.
155  ///
156  /// FIX type: NumInGroup.
158 
159  /// \return the `blockLength` field.
160  ///
161  /// FIX type: Length.
163  BlockLength blockLength() const
165  {
166  return blockLength_;
167  }
168 
169  /// Sets the `blockLength` field.
170  ///
171  /// FIX type: Length.
172  void setBlockLength(BlockLength value)
174  {
175  blockLength_ = value;
176  }
177 
178  /// \return the `numInGroup` field.
179  ///
180  /// FIX type: NumInGroup.
182  NumInGroup numInGroup() const
184  {
185  return numInGroup_;
186  }
187 
188  /// Sets the `numInGroup` field.
189  ///
190  /// FIX type: NumInGroup.
191  void setNumInGroup(NumInGroup value)
193  {
194  numInGroup_ = value;
195  }
196 
197 private:
198  BlockLength blockLength_;
199  NumInGroup numInGroup_;
200 };
201 
202 
203 /// Template ID and length of message root.
205 {
206 public:
207  /// Size of the composite.
208  enum { Size = 8 };
209 
210  /// Type alias for the `BlockLength`.
212 
213  /// Type alias for the `TemplateId`.
215 
216  /// Type alias for the `SchemaId`.
217  typedef UInt16 SchemaId;
218 
219  /// Type alias for the `Version`.
220  typedef UInt16 Version;
221 
222  /// \return the `blockLength` field.
224  BlockLength blockLength() const
226  {
227  return blockLength_;
228  }
229 
230  /// Sets the `blockLength` field.
231  void setBlockLength(BlockLength value)
233  {
234  blockLength_ = value;
235  }
236 
237  /// \return the `templateId` field.
239  TemplateId templateId() const
241  {
242  return templateId_;
243  }
244 
245  /// Sets the `templateId` field.
246  void setTemplateId(TemplateId value)
248  {
249  templateId_ = value;
250  }
251 
252  /// \return the `schemaId` field.
254  SchemaId schemaId() const
256  {
257  return schemaId_;
258  }
259 
260  /// Sets the `schemaId` field.
261  void setSchemaId(SchemaId value)
263  {
264  schemaId_ = value;
265  }
266 
267  /// \return the `version` field.
269  Version version() const
271  {
272  return version_;
273  }
274 
275  /// Sets the `version` field.
276  void setVersion(Version value)
278  {
279  version_ = value;
280  }
281 
282 private:
283  BlockLength blockLength_;
284  TemplateId templateId_;
285  SchemaId schemaId_;
286  Version version_;
287 };
288 
289 
291 
292 ONIXS_ILINK3_DATA_PACKING_END
293 
294 /// Optional floating point decimal with int32 mantissa and int8 exponent.
295 typedef
297 <
298  Int32,
299  Int8
300 >
302 
303 /// Null values definition for optional Decimal32NULL field.
305 {
306  /// Aliases the type whose null value
307  /// traits are exposed by the given class.
309 
310  /// Null value for an optional Mantissa field.
311  typedef
314 
315 
316  /// Compares encoded data to NULL.
318  bool operator ==(const Value& other) const
320  {
321  return (
322  NullMantissa() ==
323  other.mantissa());
324  }
325 
326  /// Compares encoded data to NULL.
328  bool operator !=(const Value& other) const
330  {
331  return !(*this == other);
332  }
333 
334  /// \return the value of the constant.
336  operator Value() const
338  {
339  return Value(NullMantissa(), 0);
340  }
341 
342  /// \return the value of the constant.
344  Value operator()() const
346  {
347  return Value(NullMantissa(), 0);
348  }
349 
350  /// \return the value of the constant.
352  static Value value()
354  {
355  return Value(NullMantissa(), 0);
356  }
357 };
358 
359 /// \return whether the given value is Null.
361 inline
362 bool
364  const Decimal32NULL& value)
366 {
367  return NullDecimal32NULL() == value;
368 }
369 
370 
371 /// Optional floating point decimal.
372 typedef
374 <
375  Int64,
376  Int8
377 >
379 
380 /// Null values definition for optional Decimal64NULL field.
382 {
383  /// Aliases the type whose null value
384  /// traits are exposed by the given class.
386 
387  /// Null value for an optional Mantissa field.
388  typedef
391 
392 
393  /// Compares encoded data to NULL.
395  bool operator ==(const Value& other) const
397  {
398  return (
399  NullMantissa() ==
400  other.mantissa());
401  }
402 
403  /// Compares encoded data to NULL.
405  bool operator !=(const Value& other) const
407  {
408  return !(*this == other);
409  }
410 
411  /// \return the value of the constant.
413  operator Value() const
415  {
416  return Value(NullMantissa(), 0);
417  }
418 
419  /// \return the value of the constant.
421  Value operator()() const
423  {
424  return Value(NullMantissa(), 0);
425  }
426 
427  /// \return the value of the constant.
429  static Value value()
431  {
432  return Value(NullMantissa(), 0);
433  }
434 };
435 
436 /// \return whether the given value is Null.
438 inline
439 bool
441  const Decimal64NULL& value)
443 {
444  return NullDecimal64NULL() == value;
445 }
446 
447 
448 /// Year, Month and Date.
449 ///
450 /// FIX type: MonthYear.
452 {
453 public:
454  /// Size of the composite.
455  enum { Size = 5 };
456 
457  /// YYYY.
458  typedef UInt16 Year;
459 
460  /// Null value for an optional Year field.
461  typedef
464 
465  /// MM.
466  typedef UInt8 Month;
467 
468  /// Null value for an optional Month field.
469  typedef
472 
473  /// DD.
474  typedef UInt8 Day;
475 
476  /// Null value for an optional Day field.
477  typedef
480 
481  /// WW.
482  typedef UInt8 Week;
483 
484  /// Null value for an optional Week field.
485  typedef
488 
489  /// Default constructor.
490  ///
491  /// Initializes fields with appropriate null values.
495  : year_(NullYear::value()),
496  month_(NullMonth::value()),
497  day_(NullDay::value()),
498  week_(NullWeek::value())
499  {
500  }
501 
502  /// Initializes fields with provided values
505  Year year,
506  Month month,
507  Day day,
508  Week week)
510  : year_(year),
511  month_(month),
512  day_(day),
513  week_(week)
514  {
515  }
516 
517  /// \return a human-readable presentation.
519  std::string
520  toString() const;
521 
522  /// \private
523  /// Init traits.
524  struct MemberTraits
525  {
526  enum { Count = 4 };
527 
528  typedef Year FirstArgType;
529 
530  typedef Month SecondArgType;
531 
532  typedef Day ThirdArgType;
533 
534  typedef Week FourthArgType;
535  };
536 
537  /// Serializes to a data buffer
538  void serialize(void* addr) const
540  {
541  assert(addr);
542 
543  std::memcpy(addr, &year_, sizeof(year_));
544  addr = advanceByBytes(addr, sizeof(year_));
545 
546  std::memcpy(addr, &month_, sizeof(month_));
547  addr = advanceByBytes(addr, sizeof(month_));
548 
549  std::memcpy(addr, &day_, sizeof(day_));
550  addr = advanceByBytes(addr, sizeof(day_));
551 
552  std::memcpy(addr, &week_, sizeof(week_));
553  }
554 
555  /// YYYY.
557  Year year() const
559  {
560  return year_;
561  }
562 
563  /// YYYY.
564  void setYear(Year value)
566  {
567  year_ = value;
568  }
569 
572  {
573  year_ = NullYear();
574  }
575 
576  /// MM.
578  bool month(Month& value) const
580  {
581  value = month_;
582  return NullMonth() != month_;
583  }
584 
585  /// MM.
586  void setMonth(Month value)
588  {
589  month_ = value;
590  }
591 
594  {
595  month_ = NullMonth();
596  }
597 
598  /// DD.
600  bool day(Day& value) const
602  {
603  value = day_;
604  return NullDay() != day_;
605  }
606 
607  /// DD.
608  void setDay(Day value)
610  {
611  day_ = value;
612  }
613 
616  {
617  day_ = NullDay();
618  }
619 
620  /// WW.
622  bool week(Week& value) const
624  {
625  value = week_;
626  return NullWeek() != week_;
627  }
628 
629  /// WW.
630  void setWeek(Week value)
632  {
633  week_ = value;
634  }
635 
638  {
639  week_ = NullWeek();
640  }
641 
642  /// Compares encoded data
644  bool
645  operator==(
646  const MaturityMonthYear& other) const
648 
649  /// Compares encoded data
651  bool
653  const MaturityMonthYear& other) const
654  ONIXS_ILINK3_NOTHROW
655  {
656  return !(*this == other);
657  }
658 
659 private:
660  Year year_;
661  Month month_;
662  Day day_;
663  Week week_;
664 };
665 
666 
667 /// Null values definition for optional MaturityMonthYear field.
669 {
670  /// Aliases the type whose null value
671  /// traits are exposed by the given class.
673 
674  /// Compares encoded data to NULL.
676  bool operator ==(const Value& other) const
678  {
679  return (
681  other.year());
682  }
683 
684  /// Compares encoded data to NULL.
686  bool operator !=(const Value& other) const
688  {
689  return !(*this == other);
690  }
691 
692  /// \return the value of the constant.
694  operator Value() const
696  {
697  return Value();
698  }
699 
700  /// \return the value of the constant.
702  Value operator()() const
704  {
705  return Value();
706  }
707 
708  /// \return the value of the constant.
710  static Value value()
712  {
713  return Value();
714  }
715 };
716 
717 inline
718 bool
719 MaturityMonthYear::operator==(
720  const MaturityMonthYear& other) const
722 {
723  if((NullMaturityMonthYear() == *this) &&
724  (NullMaturityMonthYear() == other))
725  return true;
726 
727  return
728  (this->year_ == other.year_) &&
729  (this->month_ == other.month_) &&
730  (this->day_ == other.day_) &&
731  (this->week_ == other.week_);
732 }
733 
734 /// Price with constant exponent -9.
735 typedef
737 <
738  Int64,
739  IntegralConstant<Int8, -9>
740 >
742 
743 /// Null values definition for optional PRICE9 field.
745 {
746  /// Aliases the type whose null value
747  /// traits are exposed by the given class.
748  typedef PRICE9 Value;
749 
750  /// Null value for an optional Mantissa field.
751  typedef
754 
755 
756  /// Compares encoded data to NULL.
758  bool operator ==(const Value& other) const
760  {
761  return (
762  NullMantissa() ==
763  other.mantissa());
764  }
765 
766  /// Compares encoded data to NULL.
768  bool operator !=(const Value& other) const
770  {
771  return !(*this == other);
772  }
773 
774  /// \return the value of the constant.
776  operator Value() const
778  {
779  return Value(NullMantissa());
780  }
781 
782  /// \return the value of the constant.
784  Value operator()() const
786  {
787  return Value(NullMantissa());
788  }
789 
790  /// \return the value of the constant.
792  static Value value()
794  {
795  return Value(NullMantissa());
796  }
797 };
798 
799 /// \return whether the given value is Null.
801 inline bool isNull(const PRICE9& value)
803 {
804  return NullPRICE9() == value;
805 }
806 
807 
#define ONIXS_ILINK3_CONSTEXPR
Definition: Compiler.h:179
void setWeek(Week value) noexcept
WW.
Definition: Composites.h:630
FloatingPointDecimal< Int64, Int8 > Decimal64NULL
Optional floating point decimal.
Definition: Composites.h:378
MaturityMonthYear Value
Aliases the type whose null value traits are exposed by the given class.
Definition: Composites.h:672
bool isNull(const PRICE9 &value) noexcept
Definition: Composites.h:801
constexpr Value operator()() const noexcept
Definition: Composites.h:784
constexpr MaturityMonthYear(Year year, Month month, Day day, Week week) noexcept
Initializes fields with provided values.
Definition: Composites.h:504
bool day(Day &value) const noexcept
DD.
Definition: Composites.h:600
std::basic_string_view< Char > StrRef
Definition: StrRef.h:46
IntegralConstant< Int64, 9223372036854775807LL > NullMantissa
Null value for an optional Mantissa field.
Definition: Composites.h:753
BlockLength blockLength() const noexcept
Definition: Composites.h:163
char Char
Character type alias.
Definition: String.h:30
static constexpr Value value() noexcept
Definition: Composites.h:352
void varData(StrRef value) noexcept
Sets the varData field.
Definition: Composites.h:70
Length length() const noexcept
Definition: Composites.h:48
A real number with a floating exponent.
Definition: Decimal.h:32
bool month(Month &value) const noexcept
MM.
Definition: Composites.h:578
BlockLength blockLength() const noexcept
Definition: Composites.h:108
Template ID and length of message root.
Definition: Composites.h:204
void setNumInGroup(NumInGroup value) noexcept
Sets the numInGroup field.
Definition: Composites.h:130
PRICE9 Value
Aliases the type whose null value traits are exposed by the given class.
Definition: Composites.h:748
IntegralConstant< Int64, 9223372036854775807LL > NullMantissa
Null value for an optional Mantissa field.
Definition: Composites.h:390
MessageHeader MessageHeaderBuilder
Definition: Composites.h:290
Decimal32NULL Value
Aliases the type whose null value traits are exposed by the given class.
Definition: Composites.h:308
BlockLength blockLength() const noexcept
Definition: Composites.h:224
UInt16 BlockLength
Type alias for the BlockLength.
Definition: Composites.h:101
UInt16 UInt16
uInt16.
Definition: Fields.h:296
void serialize(void *addr) const noexcept
Serializes to a data buffer.
Definition: Composites.h:538
Null values definition for optional Decimal32NULL field.
Definition: Composites.h:304
void setSchemaId(SchemaId value) noexcept
Sets the schemaId field.
Definition: Composites.h:261
void setBlockLength(BlockLength value) noexcept
Sets the blockLength field.
Definition: Composites.h:115
Repeating group dimensions.
Definition: Composites.h:94
StrRef varData() const noexcept
Definition: Composites.h:63
IntegralConstant< UInt8, 255 > NullWeek
Null value for an optional Week field.
Definition: Composites.h:487
void setMonth(Month value) noexcept
MM.
Definition: Composites.h:586
void setVersion(Version value) noexcept
Sets the version field.
Definition: Composites.h:276
void setYear(Year value) noexcept
YYYY.
Definition: Composites.h:564
UInt16 NumInGroup
Type alias for the NumInGroup.
Definition: Composites.h:157
constexpr Value operator()() const noexcept
Definition: Composites.h:702
void setTemplateId(TemplateId value) noexcept
Sets the templateId field.
Definition: Composites.h:246
void setNumInGroup(NumInGroup value) noexcept
Sets the numInGroup field.
Definition: Composites.h:191
#define ONIXS_ILINK3_LTWT_CLASS
Definition: ABI.h:84
IntegralConstant< UInt8, 255 > NullDay
Null value for an optional Day field.
Definition: Composites.h:479
FixedPointDecimal< Int64, IntegralConstant< Int8,-9 >> PRICE9
Price with constant exponent -9.
Definition: Composites.h:741
UInt16 BlockLength
Type alias for the BlockLength.
Definition: Composites.h:211
bool week(Week &value) const noexcept
WW.
Definition: Composites.h:622
UInt16 SchemaId
Type alias for the SchemaId.
Definition: Composites.h:217
Null values definition for optional Decimal64NULL field.
Definition: Composites.h:381
UInt16 TemplateId
Type alias for the TemplateId.
Definition: Composites.h:214
IntegralConstant< Int32, 2147483647 > NullMantissa
Null value for an optional Mantissa field.
Definition: Composites.h:313
#define ONIXS_ILINK3_MESSAGING_NAMESPACE_END
Definition: ABI.h:144
static constexpr Value value() noexcept
Definition: Composites.h:792
void length(Length value) noexcept
Sets the length.
Definition: Composites.h:55
Null values definition for optional PRICE9 field.
Definition: Composites.h:744
IntegralConstant< UInt8, 255 > NullMonth
Null value for an optional Month field.
Definition: Composites.h:471
constexpr MaturityMonthYear() noexcept
Default constructor.
Definition: Composites.h:493
constexpr Value operator()() const noexcept
Definition: Composites.h:421
bool operator!=(const MaturityMonthYear &other) const noexcept
Compares encoded data.
Definition: Composites.h:652
static constexpr Value value() noexcept
Definition: Composites.h:429
void setBlockLength(BlockLength value) noexcept
Sets the blockLength field.
Definition: Composites.h:231
Null values definition for optional MaturityMonthYear field.
Definition: Composites.h:668
Length binarySize() const noexcept
Definition: Composites.h:80
#define ONIXS_ILINK3_MESSAGING_NAMESPACE_BEGIN
Definition: ABI.h:140
void setBlockLength(BlockLength value) noexcept
Sets the blockLength field.
Definition: Composites.h:172
UInt8 NumInGroup
Type alias for the NumInGroup.
Definition: Composites.h:104
NumInGroup numInGroup() const noexcept
Definition: Composites.h:123
ONIXS_ILINK3_DATA_PACKING_END typedef FloatingPointDecimal< Int32, Int8 > Decimal32NULL
Optional floating point decimal with int32 mantissa and int8 exponent.
Definition: Composites.h:301
UInt16 BlockLength
Type alias for the BlockLength.
Definition: Composites.h:152
static constexpr Value value() noexcept
Definition: Composites.h:710
Decimal64NULL Value
Aliases the type whose null value traits are exposed by the given class.
Definition: Composites.h:385
IntegralConstant< UInt16, 65535 > NullYear
Null value for an optional Year field.
Definition: Composites.h:463
#define ONIXS_ILINK3_NODISCARD
Definition: Compiler.h:185
#define ONIXS_ILINK3_NOTHROW
Definition: Compiler.h:176
TemplateId templateId() const noexcept
Definition: Composites.h:239
#define ONIXS_ILINK3_LTWT_STRUCT
Definition: ABI.h:88
UInt16 Version
Type alias for the Version.
Definition: Composites.h:220
constexpr Value operator()() const noexcept
Definition: Composites.h:344