OnixS C++ CME iLink 3 Binary Order Entry Handler  1.9.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  /// Default constructor.
47  /// Initializes fields with zero values.
48  DATA()
50  : length_(0)
51  {
52  }
53 
54  /// \return length.
56  Length length() const
58  {
59  return length_;
60  }
61 
62  /// Sets the length.
63  void length(Length value)
65  {
66  length_ = value;
67  }
68 
69  /// \return the varData field.
71  StrRef varData() const
73  {
74  return StrRef(reinterpret_cast<const Char*>(this) + Size, length());
75  }
76 
77  /// Sets the varData field.
78  void varData(StrRef value)
80  {
81  length(static_cast<Length>(value.size()));
82  if(value.data())
83  std::memcpy(reinterpret_cast<Char*>(this) + Size, value.data(), value.size());
84  }
85 
86  /// \return Size of SBE-encoded data representing the field.
88  Length binarySize() const
90  {
91  return Size + length();
92  }
93 
94 private:
95  Length length_;
96 };
97 
98 
99 /// Repeating group dimensions.
100 ///
101 /// FIX type: NumInGroup.
103 {
104 public:
105  /// Size of the composite.
106  enum { Size = 3 };
107 
108  /// Type alias for the `BlockLength`.
110 
111  /// Type alias for the `NumInGroup`.
112  typedef UInt8 NumInGroup;
113 
114  /// Default constructor.
115  ///
116  /// Initializes fields with zero values.
118  : blockLength_(0),
119  numInGroup_(0)
120  {
121  }
122 
123  /// \return the `blockLength` field.
125  BlockLength blockLength() const
127  {
128  return blockLength_;
129  }
130 
131  /// Sets the `blockLength` field.
132  void setBlockLength(BlockLength value)
134  {
135  blockLength_ = value;
136  }
137 
138  /// \return the `numInGroup` field.
140  NumInGroup numInGroup() const
142  {
143  return numInGroup_;
144  }
145 
146  /// Sets the `numInGroup` field.
147  void setNumInGroup(NumInGroup value)
149  {
150  numInGroup_ = value;
151  }
152 
153 private:
154  BlockLength blockLength_;
155  NumInGroup numInGroup_;
156 };
157 
158 
159 /// Repeating group dimensions.
161 {
162 public:
163  /// Size of the composite.
164  enum { Size = 4 };
165 
166  /// Type alias for the `BlockLength`.
167  ///
168  /// FIX type: Length.
170 
171  /// Type alias for the `NumInGroup`.
172  ///
173  /// FIX type: NumInGroup.
175 
176  /// Default constructor.
177  ///
178  /// Initializes fields with zero values.
180  : blockLength_(0),
181  numInGroup_(0)
182  {
183  }
184 
185  /// \return the `blockLength` field.
186  ///
187  /// FIX type: Length.
189  BlockLength blockLength() const
191  {
192  return blockLength_;
193  }
194 
195  /// Sets the `blockLength` field.
196  ///
197  /// FIX type: Length.
198  void setBlockLength(BlockLength value)
200  {
201  blockLength_ = value;
202  }
203 
204  /// \return the `numInGroup` field.
205  ///
206  /// FIX type: NumInGroup.
208  NumInGroup numInGroup() const
210  {
211  return numInGroup_;
212  }
213 
214  /// Sets the `numInGroup` field.
215  ///
216  /// FIX type: NumInGroup.
217  void setNumInGroup(NumInGroup value)
219  {
220  numInGroup_ = value;
221  }
222 
223 private:
224  BlockLength blockLength_;
225  NumInGroup numInGroup_;
226 };
227 
228 
229 /// Template ID and length of message root.
231 {
232 public:
233  /// Size of the composite.
234  enum { Size = 8 };
235 
236  /// Type alias for the `BlockLength`.
238 
239  /// Type alias for the `TemplateId`.
241 
242  /// Type alias for the `SchemaId`.
243  typedef UInt16 SchemaId;
244 
245  /// Type alias for the `Version`.
246  typedef UInt16 Version;
247 
248  /// Default constructor.
249  ///
250  /// Initializes fields with zero values.
252  : blockLength_(0),
253  templateId_(0),
254  schemaId_(0),
255  version_(0)
256  {
257  }
258 
259  /// \return the `blockLength` field.
261  BlockLength blockLength() const
263  {
264  return blockLength_;
265  }
266 
267  /// Sets the `blockLength` field.
268  void setBlockLength(BlockLength value)
270  {
271  blockLength_ = value;
272  }
273 
274  /// \return the `templateId` field.
276  TemplateId templateId() const
278  {
279  return templateId_;
280  }
281 
282  /// Sets the `templateId` field.
283  void setTemplateId(TemplateId value)
285  {
286  templateId_ = value;
287  }
288 
289  /// \return the `schemaId` field.
291  SchemaId schemaId() const
293  {
294  return schemaId_;
295  }
296 
297  /// Sets the `schemaId` field.
298  void setSchemaId(SchemaId value)
300  {
301  schemaId_ = value;
302  }
303 
304  /// \return the `version` field.
306  Version version() const
308  {
309  return version_;
310  }
311 
312  /// Sets the `version` field.
313  void setVersion(Version value)
315  {
316  version_ = value;
317  }
318 
319 private:
320  BlockLength blockLength_;
321  TemplateId templateId_;
322  SchemaId schemaId_;
323  Version version_;
324 };
325 
326 
328 
329 ONIXS_ILINK3_DATA_PACKING_END
330 
331 /// Optional floating point decimal with int32 mantissa and int8 exponent.
332 typedef
334 <
335  Int32,
336  Int8
337 >
339 
340 /// Null values definition for optional Decimal32NULL field.
342 {
343  /// Aliases the type whose null value
344  /// traits are exposed by the given class.
346 
347  /// Null value for an optional Mantissa field.
348  typedef
351 
352 
353  /// Compares encoded data to NULL.
355  bool
356  operator ==(
357  const Value& other) const
358  {
359  return (
360  NullMantissa() ==
361  other.mantissa()
362  );
363  }
364 
365  /// Compares encoded data to NULL.
367  bool
369  const Value& other) const
370  {
371  return !(*this == other);
372  }
373 
374  /// \return the value of the constant.
376  operator Value() const
377  {
378  return Value(NullMantissa(), 0);
379  }
380 
381  /// \return the value of the constant.
383  Value operator()() const
384  {
385  return Value(NullMantissa(), 0);
386  }
387 
388  /// \return the value of the constant.
390  static Value value()
391  {
392  return Value(NullMantissa(), 0);
393  }
394 };
395 
396 /// \return whether the given value is Null.
398 inline
399 bool
401  const Decimal32NULL& value)
402 {
403  return NullDecimal32NULL() == value;
404 }
405 
406 
407 /// Optional floating point decimal.
408 typedef
410 <
411  Int64,
412  Int8
413 >
415 
416 /// Null values definition for optional Decimal64NULL field.
418 {
419  /// Aliases the type whose null value
420  /// traits are exposed by the given class.
422 
423  /// Null value for an optional Mantissa field.
424  typedef
427 
428 
429  /// Compares encoded data to NULL.
431  bool
432  operator ==(
433  const Value& other) const
434  {
435  return (
436  NullMantissa() ==
437  other.mantissa()
438  );
439  }
440 
441  /// Compares encoded data to NULL.
443  bool
445  const Value& other) const
446  {
447  return !(*this == other);
448  }
449 
450  /// \return the value of the constant.
452  operator Value() const
453  {
454  return Value(NullMantissa(), 0);
455  }
456 
457  /// \return the value of the constant.
459  Value operator()() const
460  {
461  return Value(NullMantissa(), 0);
462  }
463 
464  /// \return the value of the constant.
466  static Value value()
467  {
468  return Value(NullMantissa(), 0);
469  }
470 };
471 
472 /// \return whether the given value is Null.
474 inline
475 bool
477  const Decimal64NULL& value)
478 {
479  return NullDecimal64NULL() == value;
480 }
481 
482 
483 /// Year, Month and Date.
484 ///
485 /// FIX type: MonthYear.
487 {
488 public:
489  /// Size of the composite.
490  enum { Size = 5 };
491 
492  /// YYYY.
493  typedef UInt16 Year;
494 
495  /// Null value for an optional Year field.
496  typedef
499 
500  /// MM.
501  typedef UInt8 Month;
502 
503  /// Null value for an optional Month field.
504  typedef
507 
508  /// DD.
509  typedef UInt8 Day;
510 
511  /// Null value for an optional Day field.
512  typedef
515 
516  /// WW.
517  typedef UInt8 Week;
518 
519  /// Null value for an optional Week field.
520  typedef
523 
524  /// Default constructor.
525  ///
526  /// Initializes fields with appropriate null values.
529  : year_(NullYear::value()),
530  month_(NullMonth::value()),
531  day_(NullDay::value()),
532  week_(NullWeek::value())
533  {
534  }
535 
536  /// Initializes fields with provided values
539  Year year,
540  Month month,
541  Day day,
542  Week week)
543  : year_(year),
544  month_(month),
545  day_(day),
546  week_(week)
547  {
548  }
549 
550  /// \return a human-readable presentation.
552  std::string
553  toString() const;
554 
555  /// \private
556  /// Init traits.
557  struct MemberTraits
558  {
559  enum { Count = 4 };
560 
561  typedef Year FirstArgType;
562 
563  typedef Month SecondArgType;
564 
565  typedef Day ThirdArgType;
566 
567  typedef Week FourthArgType;
568  };
569 
570  /// Serializes to a data buffer
571  void serialize(void* addr) const
573  {
574  assert(addr);
575 
576  std::memcpy(addr, &year_, sizeof(year_));
577  addr = advanceByBytes(addr, sizeof(year_));
578 
579  std::memcpy(addr, &month_, sizeof(month_));
580  addr = advanceByBytes(addr, sizeof(month_));
581 
582  std::memcpy(addr, &day_, sizeof(day_));
583  addr = advanceByBytes(addr, sizeof(day_));
584 
585  std::memcpy(addr, &week_, sizeof(week_));
586  }
587 
588  /// YYYY.
590  Year year() const
592  {
593  return year_;
594  }
595 
596  /// YYYY.
597  void setYear(Year value)
599  {
600  year_ = value;
601  }
602 
604  {
605  year_ = NullYear();
606  }
607 
608  /// MM.
610  bool month(Month& value) const
612  {
613  value = month_;
614  return NullMonth() != month_;
615  }
616 
617  /// MM.
618  void setMonth(Month value)
620  {
621  month_ = value;
622  }
623 
625  {
626  month_ = NullMonth();
627  }
628 
629  /// DD.
631  bool day(Day& value) const
633  {
634  value = day_;
635  return NullDay() != day_;
636  }
637 
638  /// DD.
639  void setDay(Day value)
641  {
642  day_ = value;
643  }
644 
646  {
647  day_ = NullDay();
648  }
649 
650  /// WW.
652  bool week(Week& value) const
654  {
655  value = week_;
656  return NullWeek() != week_;
657  }
658 
659  /// WW.
660  void setWeek(Week value)
662  {
663  week_ = value;
664  }
665 
667  {
668  week_ = NullWeek();
669  }
670 
671  /// Compares encoded data
673  bool
674  operator==(
675  const MaturityMonthYear& other) const;
676 
677  /// Compares encoded data
679  bool
681  const MaturityMonthYear& other) const
682  {
683  return !(*this == other);
684  }
685 
686 private:
687  Year year_;
688  Month month_;
689  Day day_;
690  Week week_;
691 };
692 
693 
694 /// Null values definition for optional MaturityMonthYear field.
696 {
697  /// Aliases the type whose null value
698  /// traits are exposed by the given class.
700 
701  /// Compares encoded data to NULL.
703  bool
704  operator ==(
705  const Value& other) const
706  {
707  return (
709  other.year()
710  );
711  }
712 
713  /// Compares encoded data to NULL.
715  bool
717  const Value& other) const
718  {
719  return !(*this == other);
720  }
721 
722  /// \return the value of the constant.
724  operator Value() const
725  {
726  return Value();
727  }
728 
729  /// \return the value of the constant.
731  Value operator()() const
732  {
733  return Value();
734  }
735 
736  /// \return the value of the constant.
738  static Value value()
739  {
740  return Value();
741  }
742 };
743 
744 inline
745 bool
746 MaturityMonthYear::operator==(
747  const MaturityMonthYear& other) const
748 {
749  if((NullMaturityMonthYear() == *this) &&
750  (NullMaturityMonthYear() == other))
751  return true;
752 
753  return
754  (this->year_ == other.year_) &&
755  (this->month_ == other.month_) &&
756  (this->day_ == other.day_) &&
757  (this->week_ == other.week_);
758 }
759 
760 /// Price with constant exponent -9.
761 typedef
763 <
764  Int64,
765  IntegralConstant<Int8, -9>
766 >
768 
769 /// Null values definition for optional PRICE9 field.
771 {
772  /// Aliases the type whose null value
773  /// traits are exposed by the given class.
774  typedef PRICE9 Value;
775 
776  /// Null value for an optional Mantissa field.
777  typedef
780 
781 
782  /// Compares encoded data to NULL.
784  bool
785  operator ==(
786  const Value& other) const
787  {
788  return (
789  NullMantissa() ==
790  other.mantissa()
791  );
792  }
793 
794  /// Compares encoded data to NULL.
796  bool
798  const Value& other) const
799  {
800  return !(*this == other);
801  }
802 
803  /// \return the value of the constant.
805  operator Value() const
806  {
807  return Value(NullMantissa());
808  }
809 
810  /// \return the value of the constant.
812  Value operator()() const
813  {
814  return Value(NullMantissa());
815  }
816 
817  /// \return the value of the constant.
819  static Value value()
820  {
821  return Value(NullMantissa());
822  }
823 };
824 
825 /// \return whether the given value is Null.
827 inline bool isNull(const PRICE9& value)
828 {
829  return NullPRICE9() == value;
830 }
831 
832 
833 
#define ONIXS_ILINK3_CONSTEXPR
Definition: Compiler.h:167
void setWeek(Week value) noexcept
WW.
Definition: Composites.h:660
FloatingPointDecimal< Int64, Int8 > Decimal64NULL
Optional floating point decimal.
Definition: Composites.h:414
MaturityMonthYear Value
Aliases the type whose null value traits are exposed by the given class.
Definition: Composites.h:699
BlockLength blockLength() const noexcept
Definition: Composites.h:125
std::basic_string_view< Char > StrRef
Definition: StrRef.h:46
IntegralConstant< Int64, 9223372036854775807LL > NullMantissa
Null value for an optional Mantissa field.
Definition: Composites.h:779
char Char
Character type alias.
Definition: String.h:30
bool month(Month &value) const noexcept
MM.
Definition: Composites.h:610
void varData(StrRef value) noexcept
Sets the varData field.
Definition: Composites.h:78
A real number with a floating exponent.
Definition: Decimal.h:32
bool day(Day &value) const noexcept
DD.
Definition: Composites.h:631
constexpr MaturityMonthYear()
Default constructor.
Definition: Composites.h:528
Template ID and length of message root.
Definition: Composites.h:230
bool week(Week &value) const noexcept
WW.
Definition: Composites.h:652
NumInGroup numInGroup() const noexcept
Definition: Composites.h:140
void setNumInGroup(NumInGroup value) noexcept
Sets the numInGroup field.
Definition: Composites.h:147
PRICE9 Value
Aliases the type whose null value traits are exposed by the given class.
Definition: Composites.h:774
IntegralConstant< Int64, 9223372036854775807LL > NullMantissa
Null value for an optional Mantissa field.
Definition: Composites.h:426
MessageHeader MessageHeaderBuilder
Definition: Composites.h:327
Decimal32NULL Value
Aliases the type whose null value traits are exposed by the given class.
Definition: Composites.h:345
UInt16 BlockLength
Type alias for the BlockLength.
Definition: Composites.h:109
UInt16 UInt16
uInt16.
Definition: Fields.h:264
Null values definition for optional Decimal32NULL field.
Definition: Composites.h:341
void setSchemaId(SchemaId value) noexcept
Sets the schemaId field.
Definition: Composites.h:298
void setBlockLength(BlockLength value) noexcept
Sets the blockLength field.
Definition: Composites.h:132
Repeating group dimensions.
Definition: Composites.h:102
IntegralConstant< UInt8, 255 > NullWeek
Null value for an optional Week field.
Definition: Composites.h:522
void setMonth(Month value) noexcept
MM.
Definition: Composites.h:618
void setVersion(Version value) noexcept
Sets the version field.
Definition: Composites.h:313
void setYear(Year value) noexcept
YYYY.
Definition: Composites.h:597
bool isNull(const PRICE9 &value)
Definition: Composites.h:827
UInt16 NumInGroup
Type alias for the NumInGroup.
Definition: Composites.h:174
void setTemplateId(TemplateId value) noexcept
Sets the templateId field.
Definition: Composites.h:283
BlockLength blockLength() const noexcept
Definition: Composites.h:261
void setNumInGroup(NumInGroup value) noexcept
Sets the numInGroup field.
Definition: Composites.h:217
#define ONIXS_ILINK3_LTWT_CLASS
Definition: ABI.h:84
IntegralConstant< UInt8, 255 > NullDay
Null value for an optional Day field.
Definition: Composites.h:514
FixedPointDecimal< Int64, IntegralConstant< Int8,-9 >> PRICE9
Price with constant exponent -9.
Definition: Composites.h:767
UInt16 BlockLength
Type alias for the BlockLength.
Definition: Composites.h:237
constexpr MaturityMonthYear(Year year, Month month, Day day, Week week)
Initializes fields with provided values.
Definition: Composites.h:538
UInt16 SchemaId
Type alias for the SchemaId.
Definition: Composites.h:243
Null values definition for optional Decimal64NULL field.
Definition: Composites.h:417
UInt16 TemplateId
Type alias for the TemplateId.
Definition: Composites.h:240
IntegralConstant< Int32, 2147483647 > NullMantissa
Null value for an optional Mantissa field.
Definition: Composites.h:350
#define ONIXS_ILINK3_MESSAGING_NAMESPACE_END
Definition: ABI.h:144
bool operator!=(const MaturityMonthYear &other) const
Compares encoded data.
Definition: Composites.h:680
void length(Length value) noexcept
Sets the length.
Definition: Composites.h:63
BlockLength blockLength() const noexcept
Definition: Composites.h:189
Null values definition for optional PRICE9 field.
Definition: Composites.h:770
IntegralConstant< UInt8, 255 > NullMonth
Null value for an optional Month field.
Definition: Composites.h:506
void serialize(void *addr) const noexcept
Serializes to a data buffer.
Definition: Composites.h:571
Length binarySize() const noexcept
Definition: Composites.h:88
constexpr Value operator()() const
Definition: Composites.h:812
void setBlockLength(BlockLength value) noexcept
Sets the blockLength field.
Definition: Composites.h:268
TemplateId templateId() const noexcept
Definition: Composites.h:276
Null values definition for optional MaturityMonthYear field.
Definition: Composites.h:695
#define ONIXS_ILINK3_MESSAGING_NAMESPACE_BEGIN
Definition: ABI.h:140
void setBlockLength(BlockLength value) noexcept
Sets the blockLength field.
Definition: Composites.h:198
UInt8 NumInGroup
Type alias for the NumInGroup.
Definition: Composites.h:112
ONIXS_ILINK3_DATA_PACKING_END typedef FloatingPointDecimal< Int32, Int8 > Decimal32NULL
Optional floating point decimal with int32 mantissa and int8 exponent.
Definition: Composites.h:338
UInt16 BlockLength
Type alias for the BlockLength.
Definition: Composites.h:169
Decimal64NULL Value
Aliases the type whose null value traits are exposed by the given class.
Definition: Composites.h:421
IntegralConstant< UInt16, 65535 > NullYear
Null value for an optional Year field.
Definition: Composites.h:498
bool operator!=(const FixedPointDecimal< Mantissa, Exponent > &left, const FixedPointDecimal< Mantissa, Exponent > &right)
Compares two fixed-point decimals.
#define ONIXS_ILINK3_NODISCARD
Definition: Compiler.h:173
#define ONIXS_ILINK3_NOTHROW
Definition: Compiler.h:164
#define ONIXS_ILINK3_LTWT_STRUCT
Definition: ABI.h:88
UInt16 Version
Type alias for the Version.
Definition: Composites.h:246
StrRef varData() const noexcept
Definition: Composites.h:71