OnixS C++ CME MDP Premium Market Data Handler  5.8.9
API Documentation
ValueConverters.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 <stdexcept>
24 
25 #include <OnixS/CME/MDH/String.h>
26 #include <OnixS/CME/MDH/Time.h>
27 
28 #include <OnixS/CME/MDH/Decimal.h>
29 #include <OnixS/CME/MDH/Integral.h>
31 
33 
35 
36 /// Abstraction gathering operations
37 /// over a value of a particular type
38 /// stored as a field in a message.
40 {
41  /// The name of the type whose values are
42  /// manipulated through the given converter.
43  virtual const Char* typeName() const = 0;
44 
45  /// Outputs the text presentation of the FIX value
46  /// stored in the given container into the given string.
47  virtual void toStr(std::string&, const ValueContainer&) const {}
48 
49  /// Tries to convert the value stored in the given
50  /// container into the string reference. The returned
51  /// value indicates whether the conversion successful.
52  virtual bool convert(StrRef&, const ValueContainer&) const
53  {
54  return false;
55  }
56 
57  /// Tries to convert the value stored in the given
58  /// container into a character. The returned value
59  /// indicates whether the conversion successful.
60  virtual bool convert(Char&, const ValueContainer&) const
61  {
62  return false;
63  }
64 
65  /// Tries to convert the value stored in the
66  /// given container into an integer. The returned
67  /// value indicates whether the conversion successful.
68  virtual bool convert(Int8&, const ValueContainer&) const
69  {
70  return false;
71  }
72 
73  /// Tries to convert the value stored in the
74  /// given container into an integer. The returned
75  /// value indicates whether the conversion successful.
76  virtual bool convert(UInt8&, const ValueContainer&) const
77  {
78  return false;
79  }
80 
81  /// Tries to convert the value stored in the
82  /// given container into an integer. The returned
83  /// value indicates whether the conversion successful.
84  virtual bool convert(Int16&, const ValueContainer&) const
85  {
86  return false;
87  }
88 
89  /// Tries to convert the value stored in the
90  /// given container into an integer. The returned
91  /// value indicates whether the conversion successful.
92  virtual bool convert(UInt16&, const ValueContainer&) const
93  {
94  return false;
95  }
96 
97  /// Tries to convert the value stored in the
98  /// given container into an integer. The returned
99  /// value indicates whether the conversion successful.
100  virtual bool convert(Int32&, const ValueContainer&) const
101  {
102  return false;
103  }
104 
105  /// Tries to convert the value stored in the
106  /// given container into an integer. The returned
107  /// value indicates whether the conversion successful.
108  virtual bool convert(UInt32&, const ValueContainer&) const
109  {
110  return false;
111  }
112 
113  /// Tries to convert the value stored in the
114  /// given container into an integer. The returned
115  /// value indicates whether the conversion successful.
116  virtual bool convert(Int64&, const ValueContainer&) const
117  {
118  return false;
119  }
120 
121  /// Tries to convert the value stored in the
122  /// given container into an integer. The returned
123  /// value indicates whether the conversion successful.
124  virtual bool convert(UInt64&, const ValueContainer&) const
125  {
126  return false;
127  }
128 
129  /// Tries to convert the value stored in the
130  /// given container into a decimal. The returned
131  /// value indicates whether the conversion successful.
132  virtual bool convert(Decimal&, const ValueContainer&) const
133  {
134  return false;
135  }
136 
137  /// Tries to convert the value stored in the
138  /// given container into a timestamp. The returned
139  /// value indicates whether the conversion successful.
140  virtual bool convert(Timestamp&, const ValueContainer&) const
141  {
142  return false;
143  }
144 
145  /// Tries to convert the value stored in the
146  /// given container into a month-year. The returned
147  /// value indicates whether the conversion successful.
148  virtual bool convert(MaturityMonthYear&, const ValueContainer&) const
149  {
150  return false;
151  }
152 };
153 
155 {
157  {
158  return "Null";
159  }
160 
161  static const ValueConverter& self();
162 };
163 
164 //
165 
166 /// Implements the value conversion
167 /// abstraction for the text fields.
169 {
171  {
172  return "String";
173  }
174 
175  void toStr(std::string& str, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
176  {
177  const StrRef& ref = container.get<StrRef>();
178 
179  str.assign(ref.items(), ref.size());
180  }
181 
182  bool convert(StrRef& ref, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
183  {
184  ref = container.get<StrRef>();
185 
186  return true;
187  }
188 
189  bool convert(Char& value, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
190  {
191  const StrRef& str = container.get<StrRef>();
192 
193  if (1 == str.size())
194  {
195  value = str[0];
196 
197  return true;
198  }
199  else if (str.empty())
200  {
201  value = 0;
202 
203  return true;
204  }
205 
206  return false;
207  }
208 
209  bool convert(Int8& value, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
210  {
211  const StrRef& str = container.get<StrRef>();
212 
213  return fromStr(value, str.items(), str.size());
214  }
215 
216  bool convert(UInt8& value, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
217  {
218  const StrRef& str = container.get<StrRef>();
219 
220  return fromStr(value, str.items(), str.size());
221  }
222 
223  bool convert(Int16& value, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
224  {
225  const StrRef& str = container.get<StrRef>();
226 
227  return fromStr(value, str.items(), str.size());
228  }
229 
230  bool convert(UInt16& value, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
231  {
232  const StrRef& str = container.get<StrRef>();
233 
234  return fromStr(value, str.items(), str.size());
235  }
236 
237  bool convert(Int32& value, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
238  {
239  const StrRef& str = container.get<StrRef>();
240 
241  return fromStr(value, str.items(), str.size());
242  }
243 
244  bool convert(UInt32& value, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
245  {
246  const StrRef& str = container.get<StrRef>();
247 
248  return fromStr(value, str.items(), str.size());
249  }
250 
251  bool convert(Int64& value, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
252  {
253  const StrRef& str = container.get<StrRef>();
254 
255  return fromStr(value, str.items(), str.size());
256  }
257 
258  bool convert(UInt64& value, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
259  {
260  const StrRef& str = container.get<StrRef>();
261 
262  return fromStr(value, str.items(), str.size());
263  }
264 
266  {
267  const StrRef& str = container.get<StrRef>();
268 
269  return fromStr(value, str.items(), str.size());
270  }
271 
273  {
274  const StrRef& str = container.get<StrRef>();
275 
276  return fromStr(value, str.items(), str.size());
277  }
278 
280  {
281  return false;
282  }
283 
284  static const ValueConverter& self();
285 };
286 
287 //
288 
289 /// Implements the value conversion abstraction for
290 /// fields whose values represent a single character.
292 {
294  {
295  return "Char";
296  }
297 
298  void toStr(std::string& str, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
299  {
300  str.append(1, container.get<Char>());
301  }
302 
303  bool convert(StrRef& ref, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
304  {
305  ref = StrRef(&container.get<Char>(), 1);
306 
307  return true;
308  }
309 
310  bool convert(Char& value, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
311  {
312  value = container.get<Char>();
313 
314  return true;
315  }
316 
317  bool convert(Int8& value, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
318  {
319  return charToDigit(value, container.get<Char>());
320  }
321 
322  bool convert(UInt8& value, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
323  {
324  return charToDigit(value, container.get<Char>());
325  }
326 
327  bool convert(Int16& value, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
328  {
329  return charToDigit(value, container.get<Char>());
330  }
331 
332  bool convert(UInt16& value, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
333  {
334  return charToDigit(value, container.get<Char>());
335  }
336 
337  bool convert(Int32& value, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
338  {
339  return charToDigit(value, container.get<Char>());
340  }
341 
342  bool convert(UInt32& value, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
343  {
344  return charToDigit(value, container.get<Char>());
345  }
346 
347  bool convert(Int64& value, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
348  {
349  return charToDigit(value, container.get<Char>());
350  }
351 
352  bool convert(UInt64& value, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
353  {
354  return charToDigit(value, container.get<Char>());
355  }
356 
358  {
359  Decimal::Mantissa mantissa;
360 
361  if (charToDigit(mantissa, container.get<Char>()))
362  {
363  value = Decimal(mantissa, 0);
364 
365  return true;
366  }
367 
368  return false;
369  }
370 
372  {
373  return false;
374  }
375 
377  {
378  return false;
379  }
380 
381  static const ValueConverter& self();
382 
383 private:
384  template <class Integer>
385  static bool charToDigit(Integer& converted, Char original)
386  {
387  if ('0' <= original && '9' >= original)
388  {
389  converted = static_cast<Integer>(original - '0');
390 
391  return true;
392  }
393 
394  return false;
395  }
396 };
397 
398 //
399 
400 /// Implements the value conversion
401 /// abstraction for the integer fields.
402 template <class Integer, class Descendant>
404 {
405  template <class Integral, bool IsSigned>
406  struct FitsToChar
407  {
408  bool operator()(Integral value) const
409  {
410  return (0 <= value && value < 10);
411  }
412  };
413 
414  template <class Integral>
415  struct FitsToChar<Integral, false>
416  {
417  bool operator()(Integral value) const
418  {
419  return (value < 10);
420  }
421  };
422 
423  typedef FitsToChar<Integer, !(static_cast<Integer>(-1) > static_cast<Integer>(0))> CanFitToChar;
424 
425 public:
426  void toStr(std::string& str, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
427  {
428  OnixS::CME::MDH::toStr(str, container.get<Integer>());
429  }
430 
431  bool convert(Char& value, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
432  {
433  const Integer actual = container.get<Integer>();
434 
435  if (CanFitToChar()(actual))
436  {
437  value = static_cast<Char>('0' + actual);
438 
439  return true;
440  }
441 
442  return false;
443  }
444 
445  bool convert(Int8& value, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
446  {
447  value = static_cast<Int8>(container.get<Integer>());
448 
449  return true;
450  }
451 
452  bool convert(UInt8& value, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
453  {
454  value = static_cast<UInt8>(container.get<Integer>());
455 
456  return true;
457  }
458 
459  bool convert(Int16& value, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
460  {
461  value = static_cast<Int16>(container.get<Integer>());
462 
463  return true;
464  }
465 
466  bool convert(UInt16& value, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
467  {
468  value = static_cast<UInt16>(container.get<Integer>());
469 
470  return true;
471  }
472 
473  bool convert(Int32& value, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
474  {
475  value = static_cast<Int32>(container.get<Integer>());
476 
477  return true;
478  }
479 
480  bool convert(UInt32& value, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
481  {
482  value = static_cast<UInt32>(container.get<Integer>());
483 
484  return true;
485  }
486 
487  bool convert(Int64& value, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
488  {
489  value = static_cast<Int64>(container.get<Integer>());
490 
491  return true;
492  }
493 
494  bool convert(UInt64& value, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
495  {
496  value = static_cast<UInt64>(container.get<Integer>());
497 
498  return true;
499  }
500 
502  {
503  value = Decimal(static_cast<Decimal::Mantissa>(container.get<Integer>()), 0);
504 
505  return true;
506  }
507 
509  {
510  return false;
511  }
512 
514  {
515  return false;
516  }
517 
519  {
520  return false;
521  }
522 };
523 
524 /// Implements the value conversion
525 /// abstraction for the integer fields.
527 {
529  {
530  return "Int8";
531  }
532 
533  static const ValueConverter& self();
534 };
535 
536 /// Implements the value conversion
537 /// abstraction for the integer fields.
539 {
541  {
542  return "UInt8";
543  }
544 
545  static const ValueConverter& self();
546 };
547 
548 /// Implements the value conversion
549 /// abstraction for the integer fields.
551 {
553  {
554  return "Int16";
555  }
556 
557  static const ValueConverter& self();
558 };
559 
560 /// Implements the value conversion
561 /// abstraction for the integer fields.
562 struct ONIXS_CMEMDH_EXPORTED UInt16Converter : IntegerConverter<UInt16, UInt16Converter>
563 {
565  {
566  return "UInt16";
567  }
568 
569  static const ValueConverter& self();
570 };
571 
572 /// Implements the value conversion
573 /// abstraction for the integer fields.
575 {
577  {
578  return "Int32";
579  }
580 
581  static const ValueConverter& self();
582 };
583 
584 /// Implements the value conversion
585 /// abstraction for the integer fields.
586 struct ONIXS_CMEMDH_EXPORTED UInt32Converter : IntegerConverter<UInt32, UInt32Converter>
587 {
589  {
590  return "UInt32";
591  }
592 
593  static const ValueConverter& self();
594 };
595 
596 /// Implements the value conversion
597 /// abstraction for the integer fields.
599 {
601  {
602  return "Int64";
603  }
604 
605  static const ValueConverter& self();
606 };
607 
608 /// Implements the value conversion
609 /// abstraction for the integer fields.
610 struct ONIXS_CMEMDH_EXPORTED UInt64Converter : IntegerConverter<UInt64, UInt64Converter>
611 {
613  {
614  return "UInt64";
615  }
616 
617  static const ValueConverter& self();
618 };
619 
620 //
621 
622 /// Implements the value conversion
623 /// abstraction for the decimal fields.
625 {
627  {
628  return "Decimal";
629  }
630 
631  void toStr(std::string& str, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
632  {
633  OnixS::CME::MDH::toStr(str, container.get<Decimal>());
634  }
635 
637  {
638  value = container.get<Decimal>();
639 
640  return true;
641  }
642 
644  {
645  return false;
646  }
647 
649  {
650  return false;
651  }
652 
654  {
655  return false;
656  }
657 
659  {
660  return false;
661  }
662 
664  {
665  return false;
666  }
667 
669  {
670  return false;
671  }
672 
674  {
675  return false;
676  }
677 
679  {
680  return false;
681  }
682 
683  bool convert(Int64&, const ValueContainer&) const ONIXS_CMEMDH_OVERRIDE
684  {
685  return false;
686  }
687 
689  {
690  return false;
691  }
692 
694  {
695  return false;
696  }
697 
699  {
700  return false;
701  }
702 
703  static const ValueConverter& self();
704 };
705 
706 //
707 
708 /// Implements the value conversion
709 /// abstraction for the timestamp fields.
711 {
713  {
714  return "Timestamp";
715  }
716 
717  void toStr(std::string& str, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
718  {
719  OnixS::CME::MDH::toStr(str, container.get<Timestamp>());
720  }
721 
722  bool convert(Int64& value, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
723  {
724  value = static_cast<Int64>(container.get<Timestamp>().sinceEpoch());
725 
726  return true;
727  }
728 
729  bool convert(UInt64& value, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
730  {
731  value = container.get<Timestamp>().sinceEpoch();
732 
733  return true;
734  }
735 
737  {
738  value = container.get<Timestamp>();
739 
740  return true;
741  }
742 
744  {
745  return false;
746  }
747 
749  {
750  return false;
751  }
752 
754  {
755  return false;
756  }
757 
759  {
760  return false;
761  }
762 
764  {
765  return false;
766  }
767 
769  {
770  return false;
771  }
772 
774  {
775  return false;
776  }
777 
779  {
780  return false;
781  }
782 
784  {
785  return false;
786  }
787 
789  {
790  return false;
791  }
792 
793  static const ValueConverter& self();
794 };
795 
796 //
797 
798 /// Implements the value conversion
799 /// abstraction for the month-year fields.
801 {
803  {
804  return "MaturityMonthYear";
805  }
806 
807  void toStr(std::string& str, const ValueContainer& container) const ONIXS_CMEMDH_OVERRIDE
808  {
809  OnixS::CME::MDH::toStr(str, container.get<MaturityMonthYear>());
810  }
811 
813  {
814  value = container.get<MaturityMonthYear>();
815 
816  return true;
817  }
818 
820  {
821  return false;
822  }
823 
825  {
826  return false;
827  }
828 
830  {
831  return false;
832  }
833 
835  {
836  return false;
837  }
838 
840  {
841  return false;
842  }
843 
845  {
846  return false;
847  }
848 
850  {
851  return false;
852  }
853 
855  {
856  return false;
857  }
858 
859  bool convert(Int64&, const ValueContainer&) const ONIXS_CMEMDH_OVERRIDE
860  {
861  return false;
862  }
863 
865  {
866  return false;
867  }
868 
870  {
871  return false;
872  }
873 
875  {
876  return false;
877  }
878 
879  static const ValueConverter& self();
880 };
881 
882 //
883 
884 inline void throwBadConversion(const Char* typeName)
885 {
886  std::string issue;
887 
888  issue += "Cannot transform ";
889 
890  issue += typeName ? typeName : "Unknown type";
891 
892  issue += " value to the value of the requested "
893  "type because either conversion between "
894  "types does not exist or the value cannot "
895  "be fit to the value of the target type. ";
896 
897  throw std::domain_error(issue);
898 }
899 
900 //
901 
902 /// Identifies kinds of FIX field values.
904 {
905  /// Identifies kinds of FIX field values.
906  enum Enum
907  {
910  Bits
911  };
912 };
913 
914 /// Traits class used identify a field value kind.
915 template <class Value>
917 {
918  typedef char Ordinary[1];
919 
920  typedef char Enumeration[2];
921 
922  typedef char Bits[3];
923 
924  template <class Other>
925  static Bits& kind(typename Other::Bits*);
926 
927  template <class Other>
928  static Enumeration& kind(typename Other::Enum*);
929 
930  template <class Other>
931  static Ordinary& kind(...);
932 
933 public:
934  enum
935  {
936  /// The kind of the given field value by its type.
937  Kind =
938  (sizeof(Bits) == sizeof(kind<Value>(ONIXS_CMEMDH_NULLPTR))
939  ? ValueKinds::Bits
940  : (sizeof(Enumeration) == sizeof(kind<Value>(ONIXS_CMEMDH_NULLPTR)) ? ValueKinds::Enumeration : ValueKinds::Ordinary))
941  };
942 };
943 
944 /// The field value traits used in
945 /// conversion related operations.
946 template <class Value, int>
948 {
949  /// Type of the conversion output.
950  typedef Value Result;
951 
952  /// Converters the given value by using the
953  /// specified value converter and returns the
954  /// result of conversion. Throws an exception
955  /// in case of conversion failure.
956  static Result convert(const ValueConverter& converter, const ValueContainer& container)
957  {
958  Result result;
959 
960  if (!converter.convert(result, container))
961  {
962  throwBadConversion(converter.typeName());
963  }
964 
965  return result;
966  }
967 
968  /// Tries to convert the given value using
969  /// the given value converter and puts the
970  /// result of the conversion into the given
971  /// variable. Returns conversion status.
972  static bool convert(Result& result, const ValueConverter& converter, const ValueContainer& container)
973  {
974  return converter.convert(result, container);
975  }
976 };
977 
978 /// The field value traits used in
979 /// conversion related operations.
980 ///
981 /// Specialization for enumerations.
982 template <class Enumeration>
983 struct ValueConversionTraits<Enumeration, ValueKinds::Enumeration>
984 {
985  /// Type of the conversion output.
986  typedef typename Enumeration::Enum Result;
987 
988  /// Converters the given value by using the
989  /// specified value converter and returns the
990  /// result of conversion. Throws an exception
991  /// in case of conversion failure.
992  static Result convert(const ValueConverter& converter, const ValueContainer& container)
993  {
994  typename Enumeration::Base result;
995 
996  if (!converter.convert(result, container))
997  {
998  throwBadConversion(converter.typeName());
999  }
1000 
1001  return static_cast<Result>(result);
1002  }
1003 
1004  /// Tries to convert the given value using
1005  /// the given value converter and puts the
1006  /// result of the conversion into the given
1007  /// variable. Returns conversion status.
1008  static bool convert(Result& result, const ValueConverter& converter, const ValueContainer& container)
1009  {
1010  typename Enumeration::Base base;
1011 
1012  if (converter.convert(base, container))
1013  {
1014  result = static_cast<Result>(base);
1015 
1016  return true;
1017  }
1018 
1019  return false;
1020  }
1021 };
1022 
1023 /// The field value traits used in
1024 /// conversion related operations.
1025 ///
1026 /// Specialization for bit sets.
1027 template <class BitSet>
1028 struct ValueConversionTraits<BitSet, ValueKinds::Bits>
1029 {
1030  /// Type of the conversion output.
1031  typedef BitSet Result;
1032 
1033  /// Converters the given value by using the
1034  /// specified value converter and returns the
1035  /// result of conversion. Throws an exception
1036  /// in case of conversion failure.
1037  static BitSet convert(const ValueConverter& converter, const ValueContainer& container)
1038  {
1039  typename BitSet::Bits bits;
1040 
1041  if (!converter.convert(bits, container))
1042  {
1043  throwBadConversion(converter.typeName());
1044  }
1045 
1046  return BitSet(bits);
1047  }
1048 
1049  /// Tries to convert the given value using
1050  /// the given value converter and puts the
1051  /// result of the conversion into the given
1052  /// variable. Returns conversion status.
1053  static bool convert(BitSet& result, const ValueConverter& converter, const ValueContainer& container)
1054  {
1055  typename BitSet::Bits bits;
1056 
1057  if (converter.convert(bits, container))
1058  {
1059  result = BitSet(bits);
1060 
1061  return true;
1062  }
1063 
1064  return false;
1065  }
1066 };
1067 
1068 /// Implements value conversion operations
1069 /// through value conversion traits.
1070 template <class Value>
1072 {
1073  /// Conversion traits.
1075 
1076  /// Conversion output type.
1077  typedef typename Traits::Result Result;
1078 
1079  /// Converts the given value into a value of target
1080  /// type. Throws an exception in case of failure.
1081  typename Traits::Result operator()(const ValueConverter& converter, const ValueContainer& container) const
1082  {
1083  return Traits::convert(converter, container);
1084  }
1085 
1086  /// Converts the given value into a value
1087  /// of target type. Returns conversion status.
1088  bool
1089  operator()(typename Traits::Result& result, const ValueConverter& converter, const ValueContainer& container) const
1090  {
1091  return Traits::convert(result, converter, container);
1092  }
1093 };
1094 
virtual bool convert(UInt16 &, const ValueContainer &) const
Tries to convert the value stored in the given container into an integer.
Implements the value conversion abstraction for the timestamp fields.
bool convert(Decimal &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into a decimal.
bool convert(Int16 &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into an integer.
bool operator()(typename Traits::Result &result, const ValueConverter &converter, const ValueContainer &container) const
Converts the given value into a value of target type.
virtual bool convert(Timestamp &, const ValueContainer &) const
Tries to convert the value stored in the given container into a timestamp.
bool convert(Timestamp &, const ValueContainer &) const override
Tries to convert the value stored in the given container into a timestamp.
Int32 Int32
int32.
Definition: Fields.h:60
virtual bool convert(Int16 &, const ValueContainer &) const
Tries to convert the value stored in the given container into an integer.
bool convert(Timestamp &, const ValueContainer &) const override
Tries to convert the value stored in the given container into a timestamp.
bool convert(MaturityMonthYear &, const ValueContainer &) const override
Tries to convert the value stored in the given container into a month-year.
DecimalMantissa Mantissa
Aliases mantissa component type.
Definition: Decimal.h:140
bool convert(Int16 &, const ValueContainer &) const override
Tries to convert the value stored in the given container into an integer.
#define ONIXS_CMEMDH_OVERRIDE
Definition: Compiler.h:165
bool convert(Int32 &, const ValueContainer &) const override
Tries to convert the value stored in the given container into an integer.
bool convert(StrRef &, const ValueContainer &) const override
Tries to convert the value stored in the given container into the string reference.
bool empty() const
Indicates whether the referenced text is empty.
Definition: String.h:71
bool convert(UInt16 &, const ValueContainer &) const override
Tries to convert the value stored in the given container into an integer.
bool convert(UInt64 &, const ValueContainer &) const override
Tries to convert the value stored in the given container into an integer.
bool convert(UInt16 &, const ValueContainer &) const override
Tries to convert the value stored in the given container into an integer.
bool convert(Int16 &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into an integer.
virtual bool convert(Char &, const ValueContainer &) const
Tries to convert the value stored in the given container into a character.
bool convert(Int8 &, const ValueContainer &) const override
Tries to convert the value stored in the given container into an integer.
static Result convert(const ValueConverter &converter, const ValueContainer &container)
Converters the given value by using the specified value converter and returns the result of conversio...
Enum
Identifies kinds of FIX field values.
const Char * typeName() const override
The name of the type whose values are manipulated through the given converter.
bool convert(Int8 &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into an integer.
bool convert(UInt32 &, const ValueContainer &) const override
Tries to convert the value stored in the given container into an integer.
UInt32 UInt32
uInt32.
Definition: Fields.h:192
#define ONIXS_CMEMDH_NULLPTR
Definition: Compiler.h:167
bool convert(Decimal &, const ValueContainer &) const override
Tries to convert the value stored in the given container into a decimal.
virtual bool convert(MaturityMonthYear &, const ValueContainer &) const
Tries to convert the value stored in the given container into a month-year.
Implements the value conversion abstraction for the integer fields.
void toStr(std::string &str, const ValueContainer &container) const override
Outputs the text presentation of the FIX value stored in the given container into the given string...
#define ONIXS_CMEMDHFIX_NAMESPACE_BEGIN
Definition: Bootstrap.h:70
Represents time point without time-zone information.
Definition: Time.h:387
bool convert(Char &, const ValueContainer &) const override
Tries to convert the value stored in the given container into a character.
virtual const Char * typeName() const =0
The name of the type whose values are manipulated through the given converter.
bool convert(Int32 &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into an integer.
bool convert(UInt16 &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into an integer.
bool convert(Char &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into a character.
const Char * typeName() const override
The name of the type whose values are manipulated through the given converter.
virtual bool convert(UInt8 &, const ValueContainer &) const
Tries to convert the value stored in the given container into an integer.
bool convert(UInt8 &, const ValueContainer &) const override
Tries to convert the value stored in the given container into an integer.
bool convert(Timestamp &, const ValueContainer &) const override
Tries to convert the value stored in the given container into a timestamp.
bool convert(UInt32 &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into an integer.
bool convert(Timestamp &, const ValueContainer &) const override
Tries to convert the value stored in the given container into a timestamp.
static bool convert(Result &result, const ValueConverter &converter, const ValueContainer &container)
Tries to convert the given value using the given value converter and puts the result of the conversio...
static BitSet convert(const ValueConverter &converter, const ValueContainer &container)
Converters the given value by using the specified value converter and returns the result of conversio...
bool convert(Int16 &, const ValueContainer &) const override
Tries to convert the value stored in the given container into an integer.
bool convert(Int16 &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into an integer.
bool convert(UInt16 &, const ValueContainer &) const override
Tries to convert the value stored in the given container into an integer.
bool convert(UInt64 &, const ValueContainer &) const override
Tries to convert the value stored in the given container into an integer.
const Char * typeName() const override
The name of the type whose values are manipulated through the given converter.
bool convert(Decimal &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into a decimal.
void toStr(std::string &str, const ValueContainer &container) const override
Outputs the text presentation of the FIX value stored in the given container into the given string...
virtual bool convert(Decimal &, const ValueContainer &) const
Tries to convert the value stored in the given container into a decimal.
bool convert(Decimal &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into a decimal.
static bool convert(Result &result, const ValueConverter &converter, const ValueContainer &container)
Tries to convert the given value using the given value converter and puts the result of the conversio...
bool convert(Char &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into a character.
static Result convert(const ValueConverter &converter, const ValueContainer &container)
Converters the given value by using the specified value converter and returns the result of conversio...
Implements the value conversion abstraction for the decimal fields.
bool convert(UInt64 &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into an integer.
bool convert(UInt64 &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into an integer.
Implements value conversion operations through value conversion traits.
UInt8 UInt8
uInt8.
Definition: Fields.h:198
bool convert(Int8 &, const ValueContainer &) const override
Tries to convert the value stored in the given container into an integer.
const Char * typeName() const override
The name of the type whose values are manipulated through the given converter.
char Char
Character type alias.
Definition: String.h:36
const Char * typeName() const override
The name of the type whose values are manipulated through the given converter.
UInt64 UInt64
uInt64.
Definition: Fields.h:195
bool value(Number &number, const MultiContainer &container, Tag tag)
Finds a tag-value entry in the given collection by the given tag and returns its value component tran...
Identifies kinds of FIX field values.
bool convert(Decimal &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into a decimal.
Year, Month and Date.
Definition: Composites.h:87
virtual bool convert(Int64 &, const ValueContainer &) const
Tries to convert the value stored in the given container into an integer.
bool convert(UInt32 &, const ValueContainer &) const override
Tries to convert the value stored in the given container into an integer.
#define ONIXS_CMEMDHFIX_NAMESPACE_END
Definition: Bootstrap.h:71
bool convert(UInt64 &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into an integer.
Traits class used identify a field value kind.
The field value traits used in conversion related operations.
bool convert(MaturityMonthYear &, const ValueContainer &) const override
Tries to convert the value stored in the given container into a month-year.
bool convert(UInt16 &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into an integer.
virtual bool convert(UInt64 &, const ValueContainer &) const
Tries to convert the value stored in the given container into an integer.
Int16 Int16
int16.
Definition: Fields.h:57
bool convert(Int32 &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into an integer.
const Char * typeName() const override
The name of the type whose values are manipulated through the given converter.
const Char * typeName() const override
The name of the type whose values are manipulated through the given converter.
const Char * items() const
Read-only content.
Definition: String.h:77
bool convert(Char &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into a character.
static bool convert(BitSet &result, const ValueConverter &converter, const ValueContainer &container)
Tries to convert the given value using the given value converter and puts the result of the conversio...
Provides efficient way of accessing text-based values without copying content of the text being refer...
Definition: String.h:41
Implements the value conversion abstraction for fields whose values represent a single character...
bool convert(UInt32 &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into an integer.
void toStr(std::string &str, const ValueContainer &container) const override
Outputs the text presentation of the FIX value stored in the given container into the given string...
bool convert(StrRef &ref, const ValueContainer &container) const override
Tries to convert the value stored in the given container into the string reference.
A real number with floating exponent.
Definition: Decimal.h:136
virtual bool convert(Int32 &, const ValueContainer &) const
Tries to convert the value stored in the given container into an integer.
bool convert(Timestamp &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into a timestamp.
Implements the value conversion abstraction for the text fields.
Traits::Result Result
Conversion output type.
const Char * typeName() const override
The name of the type whose values are manipulated through the given converter.
bool fromStr(Decimal &, const Char *, size_t)
Deserializes a decimal number from the given text presentation.
bool convert(Int32 &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into an integer.
bool convert(MaturityMonthYear &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into a month-year.
bool convert(Int8 &, const ValueContainer &) const override
Tries to convert the value stored in the given container into an integer.
ValueConversionTraits< Value, ValueKind< Value >::Kind > Traits
Conversion traits.
const Char * typeName() const override
The name of the type whose values are manipulated through the given converter.
virtual void toStr(std::string &, const ValueContainer &) const
Outputs the text presentation of the FIX value stored in the given container into the given string...
bool convert(MaturityMonthYear &, const ValueContainer &) const override
Tries to convert the value stored in the given container into a month-year.
Value Result
Type of the conversion output.
Implements the value conversion abstraction for the integer fields.
bool convert(Int32 &, const ValueContainer &) const override
Tries to convert the value stored in the given container into an integer.
#define ONIXS_CMEMDH_EXPORTED
Definition: Compiler.h:160
virtual bool convert(UInt32 &, const ValueContainer &) const
Tries to convert the value stored in the given container into an integer.
bool convert(UInt8 &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into an integer.
bool convert(UInt8 &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into an integer.
bool convert(MaturityMonthYear &, const ValueContainer &) const override
Tries to convert the value stored in the given container into a month-year.
const Char * typeName() const override
The name of the type whose values are manipulated through the given converter.
bool convert(UInt64 &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into an integer.
void toStr(std::string &str, const ValueContainer &container) const override
Outputs the text presentation of the FIX value stored in the given container into the given string...
bool convert(Char &, const ValueContainer &) const override
Tries to convert the value stored in the given container into a character.
bool convert(UInt8 &, const ValueContainer &) const override
Tries to convert the value stored in the given container into an integer.
bool convert(Int16 &, const ValueContainer &) const override
Tries to convert the value stored in the given container into an integer.
Implements the value conversion abstraction for the month-year fields.
Implements the value conversion abstraction for the integer fields.
bool convert(MaturityMonthYear &, const ValueContainer &) const override
Tries to convert the value stored in the given container into a month-year.
bool convert(UInt32 &, const ValueContainer &) const override
Tries to convert the value stored in the given container into an integer.
bool convert(Int64 &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into an integer.
Traits::Result operator()(const ValueConverter &converter, const ValueContainer &container) const
Converts the given value into a value of target type.
virtual bool convert(StrRef &, const ValueContainer &) const
Tries to convert the value stored in the given container into the string reference.
UInt16 UInt16
uInt16 optional.
Definition: Fields.h:189
bool convert(StrRef &, const ValueContainer &) const override
Tries to convert the value stored in the given container into the string reference.
bool convert(Int64 &, const ValueContainer &) const override
Tries to convert the value stored in the given container into an integer.
bool convert(StrRef &, const ValueContainer &) const override
Tries to convert the value stored in the given container into the string reference.
void toStr(std::string &str, const ValueContainer &container) const override
Outputs the text presentation of the FIX value stored in the given container into the given string...
bool convert(Int8 &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into an integer.
Implements the value conversion abstraction for the integer fields.
Implements the value conversion abstraction for the integer fields.
bool convert(Char &, const ValueContainer &) const override
Tries to convert the value stored in the given container into a character.
const Char * typeName() const override
The name of the type whose values are manipulated through the given converter.
bool convert(Decimal &, const ValueContainer &) const override
Tries to convert the value stored in the given container into a decimal.
Implements the value conversion abstraction for the integer fields.
Int8 Int8
int8.
Definition: Fields.h:63
bool convert(UInt32 &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into an integer.
void throwBadConversion(const Char *typeName)
bool convert(Int64 &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into an integer.
bool convert(Int64 &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into an integer.
size_t size() const
Number of chars.
Definition: String.h:83
const Char * typeName() const override
The name of the type whose values are manipulated through the given converter.
bool convert(StrRef &, const ValueContainer &) const override
Tries to convert the value stored in the given container into the string reference.
bool convert(Int64 &, const ValueContainer &) const override
Tries to convert the value stored in the given container into an integer.
Implements the value conversion abstraction for the integer fields.
bool convert(UInt16 &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into an integer.
void toStr(std::string &str, const ValueContainer &container) const override
Outputs the text presentation of the FIX value stored in the given container into the given string...
bool convert(Timestamp &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into a timestamp.
bool convert(Int8 &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into an integer.
Container for a value of any supported kinds.
bool convert(Int32 &, const ValueContainer &) const override
Tries to convert the value stored in the given container into an integer.
bool convert(StrRef &ref, const ValueContainer &container) const override
Tries to convert the value stored in the given container into the string reference.
bool convert(Int64 &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into an integer.
Implements the value conversion abstraction for the integer fields.
Abstraction gathering operations over a value of a particular type stored as a field in a message...
const Char * typeName() const override
The name of the type whose values are manipulated through the given converter.
const Char * typeName() const override
The name of the type whose values are manipulated through the given converter.
bool convert(UInt8 &value, const ValueContainer &container) const override
Tries to convert the value stored in the given container into an integer.
virtual bool convert(Int8 &, const ValueContainer &) const
Tries to convert the value stored in the given container into an integer.
bool convert(UInt8 &, const ValueContainer &) const override
Tries to convert the value stored in the given container into an integer.
Implements the value conversion abstraction for the integer fields.
void toStr(std::string &, BookState::Enum)
Serializes book state value into a string.