OnixS C++ FIX Engine  4.12.0
API Documentation
SbeCustomization.h
Go to the documentation of this file.
1 #pragma once
2 /*
3 * Copyright Onix Solutions Limited [OnixS]. All rights reserved.
4 *
5 * This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
6 * and international copyright treaties.
7 *
8 * Access to and use of the software is governed by the terms of the applicable ONIXS Software
9 * Services Agreement (the Agreement) and Customer end user license agreements granting
10 * a non-assignable, non-transferable and non-exclusive license to use the software
11 * for it's own data processing purposes under the terms defined in the Agreement.
12 *
13 * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
14 * of this source code or associated reference material to any other location for further reproduction
15 * or redistribution, and any amendments to this copyright notice, are expressly prohibited.
16 *
17 * Any reproduction or redistribution for sale or hiring of the Software not in accordance with
18 * the terms of the Agreement is a violation of copyright law.
19 */
20 
21 #include <cstddef>
22 #include <string>
23 #include <limits>
24 
25 #include <OnixS/FIXEngine/ABI.h>
30 
31 namespace OnixS {
32 namespace FIX {
33 ONIXS_FIXENGINE_API_DECL(class, Message);
34 ONIXS_FIXENGINE_API_DECL(class, Dictionary);
35 
36 namespace SBE {
37 
38 /// The size of wire-level entities.
40 
41 /// The owner of custom coders.
43 
44 /// The special value that usually mean "nothing" or "null" regarding wire-level entities.
45 const SbeWireSize UnusedWireSizeValue = (std::numeric_limits<SbeWireSize>::max)();
46 
47 /// An appearance of the %SBE-encoded field
48 struct SbePresence {
49  enum Enum {
50  /// The required field.
52 
53  /// The optional field.
55 
56  /// The constant value.
58  };
59 };
60 
61 /// The byte order of the message schema.
62 struct SbeEndianness {
63  enum Enum {
64  /// The big endian order.
66 
67  /// The little endian order.
68  LittleEndian
69  };
70 };
71 
72 /// The primitive type of the %SBE-encoded value.
74  enum Enum {
75  /// Inapplicable.
77 
78  /// The character.
80 
81  /// The signed 8-bits integer.
83 
84  /// The signed 16-bits integer.
86 
87  /// The signed 32-bits integer.
89 
90  /// The signed 64-bits integer.
92 
93  /// The unsigned 8-bits integer.
95 
96  /// The unsigned 16-bits integer.
98 
99  /// The unsigned 32-bits integer.
101 
102  /// The unsigned 64-bits integer.
104 
105  /// The single precision IEEE 754-2008 value (4 bytes).
107 
108  /// The double precision IEEE 754-2008 value (8 bytes).
110  };
111 };
112 
113 /// The %FIX semantic type of the %SBE-encoded field.
115  enum Enum {
116  /// Inapplicable or unknown.
118 
119  /// The integer value.
121 
122  /// The length value.
124 
125  /// The tag number.
127 
128  /// A message sequence number.
130 
131  /// The number of entries in a repeating group.
133 
134  /// A day during a particular month (values 1 to 31).
136 
137  /// The quantity.
139 
140  /// A real number.
142 
143  /// The price value.
145 
146  /// A price offset that can be added to the Price.
148 
149  /// A field typically representing a Price times a Qty.
151 
152  /// The percentage.
154 
155  /// The single character.
157 
158  /// A fixed-length character array.
160 
161  /// Alpha-numeric free format strings can include any character or punctuation.
163 
164  /// The non-ASCII string. The character encoding may be specified by a schema attribute.
166 
167  /// The variable-length data. Must be paired with a Length field.
169 
170  /// The variable-length XML. Must be paired with a Length field.
172 
173  /// The ISO 3166-1:2013 Country code.
175 
176  /// The ISO 4217:2008 Currency code (3 character).
178 
179  /// The ISO 10383:2012 Market Identifier Code (MIC).
181 
182  /// The National language - uses ISO 639-1:2002 standard.
184 
185  /// A single choice of alternative values.
187 
188  /// Values true or false.
190 
191  /// The multiple choice of a set of values.
193 
194  /// The multiple choice of a set of values.
196 
197  /// A flexible date format that must include month and year at least, but may also include day or week.
199 
200  /// The time/date combination represented in UTC (Universal Time Coordinated, also known as "GMT").
202 
203  /// The time-only represented in UTC (Universal Time Coordinated, also known as "GMT").
205 
206  /// The date represented in UTC (Universal Time Coordinated, also known as "GMT").
208 
209  /// The local date(as oppose to UTC).
211 
212  /// The time of a day.
214 
215  /// The time/date combination representing the local time with an offset to UTC to allow an identification of the local time and the timezone offset of that time. The representation is based on ISO 8601:2004.
216  TzTimestamp
217  };
218 };
219 
220 class SbeSchemaMetaData;
221 
222 /// The name and the description of an %SBE entity.
224 {
225 public:
226  /// The destructor.
228 
229  /// The name of the entity.
230  virtual const std::string &name() const = 0;
231 
232  /// The description of the entity.
233  virtual const std::string &description() const = 0;
234 };
235 
236 /// An %SBE entity that can be bound to the given message schema.
238 {
239 public:
240  /// Returns true if the entity really bound to the message schema.
241  virtual bool hasSchema() const = 0;
242 
243  /// The metadata of the schema.
244  ///
245  /// @throw The std::exception if <code>hasSchema() == false</code>.
246  ///
247  /// @return The message schema metadata if applicable.
248  virtual SbeSchemaMetaData schema() const = 0;
249 };
250 
251 /// The named value.
252 ///
253 /// This class represents a named value that appears in the %SBE set or enumeration.
255 {
256 public:
257  /// The name of the value.
258  const std::string& name() const ONIXS_FIXENGINE_OVERRIDE;
259 
260  /// The description of the value.
261  const std::string& description() const ONIXS_FIXENGINE_OVERRIDE;
262 
263  /// Return true for most of such objects.
264  bool hasSchema() const ONIXS_FIXENGINE_OVERRIDE;
265 
266  /// The schema metadata.
267  SbeSchemaMetaData schema() const ONIXS_FIXENGINE_OVERRIDE;
268 
269  /// The value in the string presentation.
270  const std::string& value() const;
271 private:
272  friend SbeNamedValueMetaData createSbeNamedValueMetaData(const void*);
274  SbeNamedValueMetaData(const void*);
275  const void* details_;
276 };
277 
278 /// The metadata of the %SBE type.
280 {
281 public:
282  /// The name of the type.
283  const std::string& name() const;
284 
285  /// The description of the type.
286  const std::string& description() const;
287 
288  /// Return true for most of such objects.
289  bool hasSchema() const ONIXS_FIXENGINE_OVERRIDE;
290 
291  /// The schema metadata.
292  SbeSchemaMetaData schema() const ONIXS_FIXENGINE_OVERRIDE;
293 
294  /// The earliest version of the scheme where the type appears.
295  unsigned sinceVersion() const;
296 
297  /// Checks if the object describes an %SBE set.
298  bool isSet() const;
299 
300  /// Checks if the object describes an %SBE enumeration.
301  bool isEnumeration() const;
302 
303  /// Checks if the object describes an %SBE composite.
304  bool isComposite() const;
305 
306  /// Checks if the object describes a simple %SBE type.
307  ///
308  /// The simple type is a type that consists of a single field. This differs it against composites, arrays or field sets.
309  bool isSimple() const;
310 
311  /// Checks if the object describes an %SBE array.
312  bool isArray() const;
313 
314  /// Primitive type that is used by the given type.
315  SbePrimitiveType::Enum primitiveType() const;
316 
317  /// The size of the type.
318  ///
319  /// @return 0 if the type is a variadic-length type or fixed size of the type in bytes.
320  SbeWireSize fixedSize() const;
321 
322  /// The length of the fixed-length array.
323  SbeWireSize arraySize() const;
324 
325  /// The local offset of the object.
326  SbeWireSize localOffset() const;
327 
328  /// The presence of the type.
329  SbePresence::Enum presence() const;
330 
331  /// The null value (if applicable).
332  ///
333  /// @return The null value if it applicable to the type; an empty string otherwise.
334  const std::string& nullValue() const;
335 
336  /// The minimum value (if applicable).
337  ///
338  /// @return The minimum possible value if it applicable to the type; an empty string otherwise.
339  const std::string& minValue() const;
340 
341  /// The maximum value (if applicable).
342  ///
343  /// @return The maximum possible value if it applicable to the type; an empty string otherwise.
344  const std::string& maxValue() const;
345 
346  /// The constant value (if applicable).
347  ///
348  /// @return The constant value if it applicable to the type; an empty string otherwise.
349  const std::string& constValue() const;
350 
351  /// The %FIX semantic type of the type if applicable.
352  SbeFixSemanticType::Enum semanticType() const;
353 
354  /// The string presentation of the %FIX semantic type.
355  const std::string& rawSemanticType() const;
356 
357  /// The epoch for the time-aware type.
358  const std::string& timeEpoch() const;
359 
360  /// The time unit for the time-aware type.
361  const std::string& timeUnit() const;
362 
363  /// The number of composite type members.
364  size_t noOfMembers() const;
365 
366  /// The metadata of the particular composite member.
367  SbeTypeMetaData member(size_t) const;
368 
369  /// The number of values for the multivalue type.
370  size_t noOfValues() const;
371 
372  /// The metadata of the particular value.
373  SbeNamedValueMetaData value(size_t) const;
374 private:
375  friend SbeTypeMetaData createSbeTypeMetaData(const void*);
376  SbeTypeMetaData() {}
377  SbeTypeMetaData(const void*);
378  const void *details_;
379 };
380 
381 /// The metadata of the field set: the %FIX message of the %FIX repeating group.
383 {
384 public:
385  /// The name of the field set.
386  const std::string& name() const ONIXS_FIXENGINE_OVERRIDE;
387 
388  /// The description.
389  const std::string& description() const ONIXS_FIXENGINE_OVERRIDE;
390 
391  /// Always return true.
392  bool hasSchema() const ONIXS_FIXENGINE_OVERRIDE;
393 
394  /// The metadata of the %SBE schema.
395  SbeSchemaMetaData schema() const ONIXS_FIXENGINE_OVERRIDE;
396 
397  /// Checks if the field set has the parent field set.
398  bool hasParent() const;
399 
400  /// The parent field set.
401  ///
402  /// @throw An exception when <code>hasParent() == false</code>.
403  /// @return The metadata of the parent field set.
404  const SbeFieldSetMetaData parent() const;
405 
406  /// The tag associated with the field set.
407  ///
408  /// This is the tag of the %FIX message or repeating group.
409  int tag() const;
410 
411  /// Check if the field is a repeating group.
412  bool isGroup() const;
413 
414  /// Check if the field is a %FIX message.
415  bool isMessage() const;
416 
417  /// The metadata of the group dimension composite.
418  SbeTypeMetaData groupDimensionType() const;
419 
420  /// The %FIX semantic type if the field set is a %FIX message.
421  const std::string& messageSemanticType() const;
422 private:
423  friend SbeFieldSetMetaData createSbeFieldSetMetaData(const void*);
425  SbeFieldSetMetaData(const void*);
426  const void* details_;
427 };
428 
430 {
431 public:
432  /// The name of the field.
433  const std::string& name() const ONIXS_FIXENGINE_OVERRIDE;
434 
435  /// The description.
436  const std::string& description() const ONIXS_FIXENGINE_OVERRIDE;
437 
438  /// Always return true.
439  bool hasSchema() const ONIXS_FIXENGINE_OVERRIDE;
440 
441  /// The metadata of the %SBE schema.
442  SbeSchemaMetaData schema() const ONIXS_FIXENGINE_OVERRIDE;
443 
444  /// The parent of the %FIX field.
445  SbeFieldSetMetaData parent() const;
446 
447  /// The %FIX tag of the field.
448  int tag() const;
449 
450  /// Checks if the field represents a %FIX repeating group.
451  bool isGroup() const;
452 
453  /// The %FIX group if the field is a group.
454  ///
455  /// @throw An exception if the field is not a %FIX group.
456  SbeFieldSetMetaData group() const;
457 
458  /// The type of the field.
459  SbeTypeMetaData typeMetaData() const;
460 private:
461  friend SbeFieldMetaData createSbeFieldMetaData(const void*);
462  SbeFieldMetaData() {}
463  SbeFieldMetaData(const void*);
464  const void* details_;
465 };
466 
467 /// The metadata of the %SBE schema.
469 {
470 public:
471  /// The name of the schema: repeats the schema Id in the text form.
472  const std::string& name() const ONIXS_FIXENGINE_OVERRIDE;
473 
474  /// The description of the schema.
475  ///
476  /// The description appears in the "description" attribute of the &lt;messageSchema&gt; node.
477  const std::string& description() const ONIXS_FIXENGINE_OVERRIDE;
478 
479  /// The schema Id.
480  ///
481  /// The id appears in the "id" attribute of the &lt;messageSchema&gt; node.
482  UInt32 id() const;
483 
484  /// The schema package.
485  ///
486  /// The package name appears in the "package" attribute of the &lt;messageSchema&gt; node.
487  const std::string& package() const;
488 
489  /// The schema version.
490  ///
491  /// The version appears in the "version" attribute of the &lt;messageSchema&gt; node.
492  unsigned version() const;
493 
494  /// The schema semantic version.
495  ///
496  /// The semantic version appears in the "semanticVersion" attribute of the &lt;messageSchema&gt; node.
497  const std::string& semanticVersion() const;
498 
499  /// The schema byte order.
500  ///
501  /// The byte order appears in the "byteOrder" attribute of the &lt;messageSchema&gt; node.
502  SbeEndianness::Enum byteOrder() const;
503 
504  /// Checks if the schema has the message header composite.
505  bool hasHeaderType() const;
506 
507  /// Returns the metadata of the message header composite.
508  SbeTypeMetaData headerType() const;
509 private:
510  friend SbeSchemaMetaData createSbeSchemaMetaData(const void*);
511  SbeSchemaMetaData() {}
512  SbeSchemaMetaData(const void*);
513  const void* details_;
514 };
515 
516 class ISbeManageCodingParameters;
517 class ISbeFieldDecoder;
520 class ISbeFieldEncoder;
523 
524 /// The coding modes management.
525 ///
526 /// The class allows to control different aspects of the coding without usage of custom coders.
527 /// The request for the management is issued for each field of all %FIX messages unless the coding library
528 /// has been provided a custom coder for the given %FIX field.
530 {
531 public:
533 
534  /// @name The handling of named values.
535  /// The methods control how to handle fields that uses the name-value mapping. Such fields are set and enumeration fields.
536  ///
537  /// - When value names are not used externally (default) the raw value is exported to the %FIX message by the decoder or expected by the encoder.
538  /// - When value names are used externally, the associated names are exported to %FIX messages by the decoder and expected by the encoder.
539 
540  /// @{
541  /// Controls the usage of value names.
542  void useValueNamesExternally(bool);
543 
544  /// Checks if the value names are used externally.
545  bool useValueNamesExternally() const;
546  /// @}
547 
548  /// @name The Usage of the formatted date and time.
549  /// The methods control how to handle fields that represents the date and time.
550  ///
551  /// - When usage of the formatted date and time specified (default), the raw value formatted into the %FIX-aware format like YYYYMMDD, etc.
552  /// in dependency on the semantic type of the field. The formatted timestamps are produced by the decoder and expected by the encoder.
553  ///
554  /// - When usage of the formatted date and time is not specified, the raw numeric data is exported to the %FIX message by the decoder without an additional handling.
555  /// The encoder also expects numeric data in such fields.
556 
557  /// @{
558  /// Controls the usage of the formatted date and time.
559  void useFormattedDateTime(bool);
560 
561  /// Checks if the formatted date and time used.
562  bool useFormattedDateTime() const;
563  /// @}
564 private:
565  friend SbeFieldCodingSettings createSbeFieldCodingSettings(void*);
567  SbeFieldCodingSettings(void*);
568  void* details_;
569 };
570 
571 /// The library that contains user-defined %SBE coders.
573 {
574 public:
575  /// The destructor.
577 
578  /// @name Attach and detach the library to a coder
579  /// These methods used to inform the library about attaching and detaching of particular coders.
580  ///
581  /// @{
582 
583  /// Attach the %SBE coder to the library.
584  ///
585  /// This method called one time during the initialization of the %SBE coder or decoder that will use this library.
586  /// Exactly the same 'owner' parameter will be used for subsequent calls to create custom codecs or request for the management.
587  ///
588  /// @param owner The identifier of the attached coder.
589  virtual void attach(ONIXS_FIXENGINE_UNUSED CoderOwnerId owner) {}
590 
591  /// Detaches the coder from the library.
592  ///
593  /// This method is called just before the destruction of the encoder or decoder that has been requested it for custom coders.
594  /// The library can permanently remove codecs that were created for the given owner.
595  ///
596  /// @param owner The pointer to the object that owns removed coders.
597  virtual void detach(ONIXS_FIXENGINE_UNUSED CoderOwnerId owner) {}
598  /// @}
599 
600 
601  /// @name The control coding without user-defined codecs
602  ///
603  /// The method allows to control the coding without creating of a custom coder.
604  ///
605  /// @{
606 
607  /// Query for manage modes of the coding.
608  ///
609  /// This method is used to query the user code to manage modes of the coding that can be managed via the SbeFieldCodingSettings object.
610  /// The method called once for each %FIX field.
611  ///
612  /// @param owner The owner of the request.
613  /// @param field The field which coding modes will be controlled.
614  /// @param settings The object that allows to control coding modes.
615  virtual void queryCodingControl(ONIXS_FIXENGINE_UNUSED CoderOwnerId owner,
618  /// @}
619 
620  /// @name Custom decoders
621  ///
622  /// These methods are used to create custom decoders called by the Decoder or EventBasedDecoder.
623  ///
624  /// @{
625 
626  /// Request for the custom decoder.
627  ///
628  /// Requests for the custom decoder that must be used to decode the particular field. The method should return a interface to the decoder instance or \c nullptr
629  /// if the custom decoder should not be used.
630  ///
631  /// The main Decoder does not control life-cycle of the custom decoder and never deletes it directly. The pointer to the custom decoder must remain valid during
632  /// all the time when the main Decoder appears. It is possible to delete the custom decoder only when the library receives the removeCoder callback.
633  ///
634  /// @param owner The object that owns the request.
635  /// @param field The field that should be addressed by the custom decoder.
637  ONIXS_FIXENGINE_UNUSED SbeFieldMetaData field) { return ONIXS_FIXENGINE_NULLPTR; }
638 
639  /// Request for the custom decoder of the group dimension.
640  ///
641  /// Requests for the custom decoder that must be used to decode the composite that keeps the group size. The method should return an interface to the decoder instance or \c nullptr
642  /// if the custom decoder should not be used.
643  ///
644  /// The main Decoder does not control life-cycle of the custom decoder and never deletes it directly. The pointer to the custom decoder must remain valid during
645  /// all the time when the main Decoder appears. It is possible to delete the custom decoder only when the library receives the removeCoder callback.
646  ///
647  /// @param owner The object that owns the request.
648  /// @param field The field that should be addressed by the custom decoder.
650  ONIXS_FIXENGINE_UNUSED SbeFieldSetMetaData field) { return ONIXS_FIXENGINE_NULLPTR; }
651 
652  /// Request for the custom decoder of the separate composite.
653  ///
654  /// Requests for the decoder of such composite that never used within the message as a field. For now there is a single composite: the message header.
655  /// @param owner The object that owns the request.
656  /// @param composite The composite type that should be addressed by the custom decoder.
657  virtual ISbeCompositeDecoder* queryDecoder(ONIXS_FIXENGINE_UNUSED CoderOwnerId owner, ONIXS_FIXENGINE_UNUSED SbeTypeMetaData composite) { return ONIXS_FIXENGINE_NULLPTR; }
658  /// @}
659 
660  /// @name Custom encoders
661  /// These methods are used to create custom encoders by the Encoder.
662  ///
663  /// @{
664 
665  /// Request for the custom encoder.
666  ///
667  /// Requests for the custom encoder that must be used to encode the particular field. The method should return an interface to the encoder instance or \c nullptr
668  /// if the custom encoder should not be used.
669  ///
670  /// The main Encoder does not control life-cycle of the custom encoder and never deletes it directly. The pointer to the custom encoder must remain valid during
671  /// all the time when the main Encoder appears. It is possible to delete the custom encoder only when the library receives the detach callback.
672  ///
673  /// @param owner The object that owns the request.
674  /// @param field The field that should be addressed by the custom encoder.
675  virtual ISbeFieldEncoder* queryEncoder(ONIXS_FIXENGINE_UNUSED CoderOwnerId owner, ONIXS_FIXENGINE_UNUSED SbeFieldMetaData field) { return ONIXS_FIXENGINE_NULLPTR; }
676 
677  /// Request for the custom encoder of the group dimension.
678  ///
679  /// Requests for the custom encoder that must be used to decode composite that keeps the group size. The method should return an interface to the encoder instance or \c nullptr
680  /// if the custom encoder should not be used.
681  ///
682  /// The main Encoder does not control life-cycle of the custom encoder and never deletes it directly. The pointer to the custom encoder must remain valid during
683  /// all the time when the main Encoder appears. It is possible to delete the custom encoder only when the library receives the detach callback.
684  ///
685  /// @param owner The object that owns the request.
686  /// @param group The group that should be addressed by the custom encoder.
687  virtual ISbeGroupDimensionEncoder* queryGroupDimensionEncoder(ONIXS_FIXENGINE_UNUSED CoderOwnerId owner, ONIXS_FIXENGINE_UNUSED SbeFieldSetMetaData group) { return ONIXS_FIXENGINE_NULLPTR; }
688 
689  /// Request for the custom encoder of the separate composite.
690  ///
691  /// Requests for the encoder of such composite that never used within the message as a field. For now there is a single composite: the message header.
692  ///
693  /// @param owner The object that owns the request.
694  /// @param composite The composite type that should be addressed by the custom encoder.
695  virtual ISbeCompositeEncoder* queryEncoder(ONIXS_FIXENGINE_UNUSED CoderOwnerId owner, ONIXS_FIXENGINE_UNUSED SbeTypeMetaData composite) { return ONIXS_FIXENGINE_NULLPTR; }
696  /// @}
697 };
698 
699 /// The output interface for the data decoded by the custom decoder.
700 ///
701 /// This class is used to assign data produced by the custom decoder to the particular field of the %FIX message or to report about such data via the IDecoderEvents interface.
702 ///
703 /// @note The class is copy-assignable and valid only during the appropriate callback of the custom decoder.
705 {
706 public:
708 
709  /// The field metadata for reference needs.
710  SbeFieldMetaData field() const;
711 
712  /// Explicitly assigns Null value to the destination.
713  void setNull();
714 
715  /// Assigns the character value.
716  void setChar(char value);
717 
718  /// Assigns the signed 16-bits value.
719  void set(Int16 value);
720 
721  /// Assigns the unsigned 16-bits value.
722  void set(UInt16 value);
723 
724  /// Assigns the signed 32-bits value.
725  void set(Int32 value);
726 
727  /// Assigns the unsigned 32-bits value.
728  void set(UInt32 value);
729 
730  /// Assigns the signed 64-bits value.
731  void set(Int64 value);
732 
733  /// Assigns the unsigned 64-bits value.
734  void set(UInt64 value);
735 
736  /// Assigns the float value.
737  void set(float value);
738 
739  /// Assigns the double value.
740  void set(double value);
741 
742  /// Assigns the plain data of the variadic length value.
743  void set(const void* value, SbeWireSize length);
744 
745  /// Assigns the value as a string of the variadic length.
746  void set(const char* value, SbeWireSize length);
747 private:
748  friend SbeFieldDecoderOutput createSbeFieldDecoderOutput(void*);
750  SbeFieldDecoderOutput(void*);
751  void* details_;
752 };
753 
754 /// The output interface for the data about the repeating group.
755 ///
756 /// This class is used by the custom decoder to report the core decoder about parameters of the repeating group, before the decoding of the repeating group itself.
757 ///
758 /// @note The class is copy-assignable and valid only during the appropriate callback of the custom decoder.
760 {
761 public:
762  /// The destructor.
764 
765  /// The group metadata for reference needs.
766  SbeFieldSetMetaData group() const;
767 
768  /// Reports data about the repeating group.
769  ///
770  /// @param blockLength The length of the fixed-length part of the repeating group item.
771  /// @param itemCount The number of items in the repeating group.
772  /// @param numGroups The number of nested groups of the given repeating group (optional).
773  /// @param numVarDataFields The number of nested data fields of the given repeating group (optional).
774  void set(SbeWireSize blockLength, SbeWireSize itemCount, SbeWireSize numGroups = UnusedWireSizeValue, SbeWireSize numVarDataFields = UnusedWireSizeValue);
775 private:
776  friend SbeGroupDimensionOutput createSbeGroupDimensionOutput(void*);
779  void* details_;
780 };
781 
782 /// The output interface for composites that are not used inside of %FIX messages.
783 ///
784 /// That class is used by the custom decoder to report the content of composites that are never incorporated into %FIX messages but must be used by the decoding process.
785 /// For now there is a single only such composite: the message header composite.
786 ///
787 /// @note The class is copy-assignable and valid only during the appropriate callback of the custom decoder.
789 {
790 public:
791  /// The destructor.
793 
794  /// The composite metadata for reference needs.
795  SbeTypeMetaData type() const;
796 
797  /// Reports data about the message from the message header.
798  ///
799  /// @param blockLength The length of fixed-length part of the repeating group item.
800  /// @param templateId The template Id of the message.
801  /// @param schemaId The identifier of the schema.
802  /// @param schemaVersion The version of the message.
803  /// @param numGroups The number of nested groups of the given repeating group (optional).
804  /// @param numVarDataFields The number of nested data fields of the given repeating group (optional).
805  void setMessageHeader(SbeWireSize blockLength, unsigned templateId,
806  UInt32 schemaId, unsigned schemaVersion,
807  SbeWireSize numGroups = UnusedWireSizeValue,
808  SbeWireSize numVarDataFields = UnusedWireSizeValue);
809 private:
810  friend SbeSpecialCompositeOutput createSbeSpecialCompositeOutput(void*);
813  void* details_;
814 };
815 
816 /// The interface of the custom decoder for the %FIX field.
817 ///
818 /// The interface must be implemented by the custom decoder that decodes a %FIX field.
819 ///
820 /// The decoder is attached to the particular field during the ISbeCustomCoderLibrary::queryDecoder.
822 {
823 public:
824  /// The destructor.
826 
827  /// Decode data for the field.
828  ///
829  /// This method is used to read wire-level data and convert it into the %FIX field value. The core decoder calls it if the user code
830  /// provided the custom decoder for the particular %FIX field.
831  ///
832  /// @param output The destination for the decoded data.
833  /// @param version The version of the message being decoded.
834  /// @param data The wire-level data.
835  /// @param available The number of wire-level bytes available to analyze.
836  /// @return The number of used bytes.
837  virtual size_t decode(SbeFieldDecoderOutput output, unsigned version, const void* data, size_t available) = 0;
838 };
839 
840 /// The interface of the custom decoder for the group dimension composite.
841 ///
842 /// The interface must be implemented by the decoder that decodes the group dimension composite.
843 ///
844 /// The decoder is attached to the particular %FIX group during the ISbeCustomCoderLibrary::queryGroupDimensionDecoder.
846 {
847 public:
848  /// The virtual destructor.
850 
851  /// Decode the group size data.
852  ///
853  /// This method is used to read wire-level data and restore repeating group parameters. The core decoder calls this method
854  /// before the decoding of the repeating group content.
855  ///
856  /// @param output The destination for the decoded data.
857  /// @param version The version of the message being decoded.
858  /// @param data The wire-level data.
859  /// @param available The number of wire-level bytes available to analyze.
860  /// @return The number of used bytes.
861  virtual size_t decode(SbeGroupDimensionOutput output, unsigned version, const void* data, size_t available) = 0;
862 };
863 
864 
865 /// The interface of the custom decoder for composites that are not used inside of %FIX messages.
866 ///
867 /// The decoder is attached to the particular composite during the ISbeCustomCoderLibrary::queryDecoder.
869 {
870 public:
871  /// The virtual destructor.
873 
874  /// Decode composite data.
875  ///
876  /// This method is used to read wire-level data and restore the content of the required composite data.
877  ///
878  /// @param output The destination for the decoded data.
879  /// @param version The version of the message being decoded.
880  /// @param data The wire-level data.
881  /// @param available The number of wire-level bytes available to analyze.
882  /// @return The number of used bytes.
883  virtual size_t decode(SbeSpecialCompositeOutput output, unsigned version, const void* data, size_t available) = 0;
884 };
885 
886 /// The stream to write the encoded data.
888 {
889 public:
891 
892  /// Write data.
893  ///
894  /// The method writes data to the destination binary stream and moves the stream pointer to the end of the written data.
895  /// Subsequent writing will add new data to the end of the previously written ones.
896  ///
897  /// @param data The data to write.
898  /// @param size The number of bytes to write.
899  void put(const void* data, SbeWireSize size);
900 private:
901  friend SbeBinaryOutputStream createSbeBinaryOutputStream(void*);
903  SbeBinaryOutputStream(void*);
904  void* details_;
905 };
906 
907 /// The Accessor to the field content.
909 {
910 public:
912 
913  /// The tag of the field that is being encoded.
914  Tag tag() const;
915 
916  /// The complete metadata of the field that is encoded (contains the same tag as one returned by the tag() method).
917  SbeFieldMetaData fieldMetaData() const;
918 
919  /// Checks if the field value is null.
920  bool present() const;
921 
922  /// Tries to convert the field value to the string.
923  bool toString(std::string&) const;
924 
925  /// Tries to convert the field value to the char.
926  bool toChar(Char&) const;
927 
928  /// Tries to convert the field value to the 32-bits signed integer.
929  bool toNumber(Int32&) const;
930 
931  /// Tries to convert the field value to the 32-bits unsigned integer.
932  bool toNumber(UInt32&) const;
933 
934  /// Tries to convert the field value to the 64-bits signed integer.
935  bool toNumber(Int64&) const;
936 
937  /// Tries to convert the field value to the 64-bits unsigned integer.
938  bool toNumber(UInt64&) const;
939 
940  /// Tries to convert the field value to the double value.
941  bool toNumber(Double&) const;
942 
943  /// Tries to convert the field value to the decimal.
944  bool toNumber(Decimal&) const;
945 
946  /// Tries to convert the field value to the timestamp using the particular formatter.
947  bool toTimestamp(Timestamp&,
949 
950  /// Tries to convert the field value to the timespan using the particular formatter.
951  bool toTimeSpan(TimeSpan&,
953 protected:
954  friend SbeConstFieldAccess createSbeConstFieldAccess(Tag tag, const void*, const void*);
956  SbeConstFieldAccess(Tag tag, const void*, const void*);
958  const void* details_;
959  const void* details2_;
960 };
961 
962 /// The input interface for composites that are not used inside of %FIX messages.
963 ///
964 /// That class is used by custom encoders to get the content for composites that are never incorporated into %FIX messages but must be used by the encoding process.
965 /// For now there is a single only such composite: the message header composite.
966 ///
967 /// @note The class is copy-assignable and valid only during the appropriate callback of the custom decoder.
969 {
970 public:
972 
973  /// Metadata of the composite which data are reported via this object.
974  SbeTypeMetaData typeMetaData() const;
975 
976  /// Gets the message header data.
977  ///
978  /// Requests all or particular data for the %SBE message header.
979  /// The data is provided in its most common form, as unsigned 32-bits integer values that is too wide for most of message headers.
980  /// Thus the obtained values can (and usually - should) be converted by the encoder to other data types, for example, to the UInt16.
981  ///
982  /// @param blockLength The length of the 'root segment' of the message.
983  /// @param templateId The required template Id to encode.
984  /// @param schemaId The schema Id.
985  /// @param schemaVersion The version of the template to use for the subsequent %FIX message.
986  /// @param numOfGroups The number of groups in the top-level field set of the message.
987  /// @param numOfVarDataFields The number of &lt;data&gt; fields in the top-level field set of the message.
988  void getMessageHeaderData(UInt32* blockLength = ONIXS_FIXENGINE_NULLPTR,
989  UInt32* templateId = ONIXS_FIXENGINE_NULLPTR,
990  UInt32* schemaId = ONIXS_FIXENGINE_NULLPTR,
991  UInt32* schemaVersion = ONIXS_FIXENGINE_NULLPTR,
992  UInt32* numOfGroups = ONIXS_FIXENGINE_NULLPTR,
993  UInt32* numOfVarDataFields = ONIXS_FIXENGINE_NULLPTR) const;
994 protected:
995  friend SbeSpecialCompositeInput createSbeSpecialCompositeInput(const void*);
997  SbeSpecialCompositeInput(const void*);
998  const void* details_;
999 };
1000 
1001 /// The input interface for the data about the repeating group.
1002 ///
1003 /// This class is used by the custom encoder to read parameters of the repeating group before the encoding of the repeating group itself.
1004 ///
1005 /// @note The class is copy-assignable and valid only during the appropriate callback of the custom decoder.
1007 {
1008 public:
1010 
1011  /// The field set of the group which dimensions are reported via this object.
1012  SbeFieldSetMetaData groupMetaData() const;
1013 
1014  /// Gets the group dimension data.
1015  ///
1016  /// @param blockLength The length of fixed-length part of the repeating group item.
1017  /// @param itemCount The number of items in the repeating group.
1018  /// @param numGroups The number of nested groups of the given repeating group (optional).
1019  /// @param numVarDataFields The number of nested data fields of the given repeating group (optional).
1020  void getGroupDimensionData(SbeWireSize* blockLength = ONIXS_FIXENGINE_NULLPTR,
1021  size_t* itemCount = ONIXS_FIXENGINE_NULLPTR,
1022  SbeWireSize* numGroups = ONIXS_FIXENGINE_NULLPTR,
1023  SbeWireSize* numVarDataFields = ONIXS_FIXENGINE_NULLPTR) const;
1024 protected:
1025  friend SbeGroupDimensionInput createSbeGroupDimensionInput(const void*);
1027  SbeGroupDimensionInput(const void*);
1028  const void* details_;
1029 };
1030 
1031 /// The interface of custom encoder for the %FIX field.
1032 ///
1033 /// The interface must be implemented by the custom encoder that encodes a %FIX field.
1034 ///
1035 /// The encoder is attached to the particular field during the ISbeCustomCoderLibrary::queryEncoder.
1037 {
1038 public:
1040 
1041  /// Query for the size of the encoded field.
1042  ///
1043  /// This method should return the size of the encoded field if the field has a fixed binary size.
1044  /// In a case of a variable-length field, the method is **not called** and is considered to return zero.
1045  virtual SbeWireSize queryFixedSize(unsigned version) = 0;
1046 
1047  /// Encodes the %FIX field to the binary stream.
1048  ///
1049  /// This method is used to encode the %FIX field value to the binary data. The core encoder calls it if user code
1050  /// provided the custom encoder for the particular %FIX field.
1051  ///
1052  /// @note If the field is a fixed-length field, the number of written bytes must be exactly the same as reported via queryFixedSize.
1053  ///
1054  /// @param out The binary data stream for the encoded data.
1055  /// @param version The version of the %FIX message being encoded.
1056  /// @param field The %FIX field to encode.
1057  virtual void encode(SbeBinaryOutputStream out, unsigned version, const SbeConstFieldAccess &field) = 0;
1058 };
1059 
1060 /// The interface of the custom encoder for composites that are not used inside of %FIX messages.
1061 ///
1062 /// The encoder is attached to the particular composite during the ISbeCustomCoderLibrary::queryEncoder.
1064 {
1065 public:
1067 
1068  /// The encode composite data.
1069  ///
1070  /// This method is used to encode the composite to the binary data.
1071  ///
1072  /// @param out The binary data stream for the encoded data.
1073  /// @param version The version of the composite being encoded.
1074  /// @param input The content of the composite to encode.
1075  virtual void encode(SbeBinaryOutputStream out, unsigned version, SbeSpecialCompositeInput input) = 0;
1076 };
1077 
1078 /// The interface of the custom encoder for the group dimension composite.
1079 ///
1080 /// The interface must be implemented by the encoder that encodes the group dimension composite.
1081 ///
1082 /// The encoder is attached to the particular %FIX group during the ISbeCustomCoderLibrary::queryGroupDimensionEncoder.
1084 {
1085 public:
1087 
1088  /// Encodes the group size data.
1089  ///
1090  /// This method is used to encode the group dimension data to the output binary data. The core encoder calls this method
1091  /// before encoding of the repeating group content.
1092  ///
1093  /// @param out The binary data stream for the encoded data.
1094  /// @param version The version of the composite being encoded.
1095  /// @param input The data of the group to be encoded.
1096  virtual void encode(SbeBinaryOutputStream out, unsigned version, SbeGroupDimensionInput input) = 0;
1097 };
1098 
1099 }
1100 }
1101 }
The library that contains user-defined SBE coders.
The unsigned 64-bits integer.
The output interface for the data about the repeating group.
The multiple choice of a set of values.
The name and the description of an SBE entity.
Indicates the timestamp in the "YYYYMMDD-HH:MM:SS.sssssssss" format.
Definition: Timestamp.h:83
The interface of the custom decoder for the group dimension composite.
The interface of the custom encoder for composites that are not used inside of FIX messages...
An SBE entity that can be bound to the given message schema.
The National language - uses ISO 639-1:2002 standard.
The FIX semantic type of the SBE-encoded field.
virtual ISbeFieldDecoder * queryDecoder(ONIXS_FIXENGINE_UNUSED CoderOwnerId owner, ONIXS_FIXENGINE_UNUSED SbeFieldMetaData field)
Request for the custom decoder.
virtual void attach(ONIXS_FIXENGINE_UNUSED CoderOwnerId owner)
Attach the SBE coder to the library.
unsigned int UInt32
Definition: Numeric.h:36
long long Int64
Definition: Numeric.h:38
The interface of the custom decoder for composites that are not used inside of FIX messages...
#define ONIXS_FIXENGINE_DEFAULT
Definition: Compiler.h:176
The unsigned 16-bits integer.
An appearance of the SBE-encoded field.
#define ONIXS_FIXENGINE_API
Definition: ABI.h:45
The number of entries in a repeating group.
The ISO 4217:2008 Currency code (3 character).
virtual void detach(ONIXS_FIXENGINE_UNUSED CoderOwnerId owner)
Detaches the coder from the library.
UInt64 CoderOwnerId
The owner of custom coders.
The interface of custom encoder for the FIX field.
A single choice of alternative values.
A flexible date format that must include month and year at least, but may also include day or week...
#define ONIXS_FIXENGINE_UNUSED
Definition: Compiler.h:128
virtual ISbeCompositeEncoder * queryEncoder(ONIXS_FIXENGINE_UNUSED CoderOwnerId owner, ONIXS_FIXENGINE_UNUSED SbeTypeMetaData composite)
Request for the custom encoder of the separate composite.
The primitive type of the SBE-encoded value.
A field typically representing a Price times a Qty.
The unsigned 8-bits integer.
int Int32
Definition: Numeric.h:35
virtual ISbeFieldEncoder * queryEncoder(ONIXS_FIXENGINE_UNUSED CoderOwnerId owner, ONIXS_FIXENGINE_UNUSED SbeFieldMetaData field)
Request for the custom encoder.
The ISO 10383:2012 Market Identifier Code (MIC).
The metadata of the SBE schema.
const SbeWireSize UnusedWireSizeValue
The special value that usually mean "nothing" or "null" regarding wire-level entities.
The date represented in UTC (Universal Time Coordinated, also known as "GMT").
virtual void queryCodingControl(ONIXS_FIXENGINE_UNUSED CoderOwnerId owner, ONIXS_FIXENGINE_UNUSED SbeFieldMetaData field, ONIXS_FIXENGINE_UNUSED SbeFieldCodingSettings settings)
Query for manage modes of the coding.
A day during a particular month (values 1 to 31).
The time-only represented in UTC (Universal Time Coordinated, also known as "GMT").
The output interface for composites that are not used inside of FIX messages.
The interface of the custom encoder for the group dimension composite.
unsigned long long UInt64
Definition: Numeric.h:39
ONIXS_FIXENGINE_API_DECL(class, IEngineListener)
The ISO 3166-1:2013 Country code.
unsigned Tag
Alias for tag numbers.
Definition: Tag.h:28
The metadata of the SBE type.
The Accessor to the field content.
virtual ISbeGroupDimensionDecoder * queryGroupDimensionDecoder(ONIXS_FIXENGINE_UNUSED CoderOwnerId owner, ONIXS_FIXENGINE_UNUSED SbeFieldSetMetaData field)
Request for the custom decoder of the group dimension.
The time span related functionality.
Definition: TimeSpan.h:93
virtual ISbeCompositeDecoder * queryDecoder(ONIXS_FIXENGINE_UNUSED CoderOwnerId owner, ONIXS_FIXENGINE_UNUSED SbeTypeMetaData composite)
Request for the custom decoder of the separate composite.
The time/date combination represented in UTC (Universal Time Coordinated, also known as "GMT")...
virtual ISbeGroupDimensionEncoder * queryGroupDimensionEncoder(ONIXS_FIXENGINE_UNUSED CoderOwnerId owner, ONIXS_FIXENGINE_UNUSED SbeFieldSetMetaData group)
Request for the custom encoder of the group dimension.
The input interface for the data about the repeating group.
A price offset that can be added to the Price.
The variable-length data. Must be paired with a Length field.
The input interface for composites that are not used inside of FIX messages.
The coding modes management.
The Decimal type for a better precision.
Definition: Numeric.h:47
short unsigned int UInt16
Definition: Numeric.h:33
The stream to write the encoded data.
Alpha-numeric free format strings can include any character or punctuation.
The byte order of the message schema.
The variable-length XML. Must be paired with a Length field.
The single precision IEEE 754-2008 value (4 bytes).
short int Int16
Definition: Numeric.h:32
Indicates the time span in the "HH:MM:SS.sss" format.
Definition: TimeSpan.h:79
The timestamps related functionality.
Definition: Timestamp.h:91
The unsigned 32-bits integer.
UInt32 SbeWireSize
The size of wire-level entities.
The multiple choice of a set of values.
double Double
Definition: Numeric.h:41
The non-ASCII string. The character encoding may be specified by a schema attribute.
The output interface for the data decoded by the custom decoder.
The metadata of the field set: the FIX message of the FIX repeating group.
char Char
Definition: Numeric.h:30
The interface of the custom decoder for the FIX field.