FARGOS/VISTA Object Management Environment Core  ..
FARGOS/VISTA Object Management Environment Core Table of Contents
OMEbaseType.h
Go to the documentation of this file.
1 #ifndef _OME_BASE_TYPE_H_
2 #define _OME_BASE_TYPE_H_ "$Id: OMEbaseType.h 312 2020-03-21 21:25:35Z geoff $"
4 
14 #include <OMEmanifests.h>
15 
16 #define FORCE_OME_EXTENDED_TYPE 0
17 
18 #if (FORCE_OME_EXTENDED_TYPE == 1) || (__SIZEOF_POINTER__ < 8)
19 #define OME_EXT_TYPE(member) value.extType->extValue. member
20 #else
21 #define OME_EXT_TYPE(member) value. member
22 #endif
23 
24 #if (FORCE_OME_EXTENDED_TYPE == 1) || (__SIZEOF_POINTER__ < 8)
25 // OMEextendedType is used internally by OMEbaseType
29 {
30 public:
31  union {
32  double df;
33  int64_t i64;
34  uint64_t ui64;
35  } extValue;
36 
37  explicit OMEextendedType(double f)
38  {
39  extValue.df = f;
40  }
41 
42  explicit OMEextendedType(int64_t i)
43  {
44  extValue.i64 = i;
45  }
46 
47  explicit OMEextendedType(uint64_t ui)
48  {
49  extValue.ui64 = ui;
50  }
51 
53 }; // end class OMEextendedType
54 #endif
55 
59 {
60 public:
62  IDENTICAL_TYPES = (1 << 0),
63  CAN_ASSIGN = (1 << 1),
64  SAME_BASE_TYPE = (1 << 2),
65  DISSIMILAR_SIGN = (1 << 3),
66  CAN_PROMOTE = (1 << 4),
67  CAN_DEMOTE = (1 << 5),
68  INCOMPATIBLE_TYPES = (1 << 6),
69  UNKNOWN_COMPATIBILITY = (1 << 7),
71 
72  // used by OIL2 compiler
73  TYPE_MASK = 255,
76  };
77 
78  static uint32_t baseType(uint32_t t) OME_CONST_FUNCTION {
79  return (OMEfundamentalType(t));
80  }
81 
82  static bool isTypeANY(uint32_t t) OME_CONST_FUNCTION {
83  uint32_t t1 = t & TYPE_MASK;
84  if ((t1 == OME_ANY) || (t1 == OME_POINTER) || (t1 == OME_CONST_POINTER)
85  || (t & OPTIONAL_TYPE_FLAG))
86  {
87  return (true);
88  }
89  return (false);
90  }
91 
92  static constexpr bool is32BitInteger(uint32_t t) OME_CONST_FUNCTION {
93  return ((t == OME_UINT32) || (t == OME_INT32));
94  }
95 
96  static constexpr bool isHeldBy32BitInteger(uint32_t t) OME_CONST_FUNCTION {
97  return ((t == OME_UINT32) || (t == OME_INT32) ||
98  (t == OME_UINT16) || (t == OME_UINT8));
99  }
100 
101  static constexpr bool is64BitInteger(uint32_t t) OME_CONST_FUNCTION {
102  return ((t == OME_UINT64) || (t == OME_INT64));
103  }
104 
105  static constexpr bool isInteger(uint32_t t) OME_CONST_FUNCTION {
106  return (isHeldBy32BitInteger(t) || is64BitInteger(t));
107  }
108 
109  static constexpr bool isContainer(uint32_t t) OME_CONST_FUNCTION {
110  return ((t == OME_ARRAY) | (t == OME_ASSOC) | (t == OME_SET));
111  }
112 
113  // NOTE: order matches signature of VISTA OME routine OMEokToAssignTypes() for performance
114  static uint32_t typesAreAssignable(uint32_t srcType, uint32_t targetType) OME_CONST_FUNCTION {
115  if (targetType == srcType) // identical types
116  {
117  // TODO: if const supported, drop CAN_ASSIGN
119  }
120  // runtime evaluation if srcType == OME_ANY or OME_POINTER
121  if (isTypeANY(targetType)) // assume it will work
122  {
123  return (ASSUME_COMPATIBLE | CAN_ASSIGN);
124  }
125  if (targetType == OME_NIL) // not initialized
126  {
127  return (CAN_ASSIGN);
128  }
129  if (isTypeANY(srcType)) // we don't know...but assume OK
130  {
132  }
133  // type-specific checks
134  // OID's can be set to nil...
135  bool isSigned = false;
136  switch (targetType)
137  {
138  case OME_NIL: // uninitialized
139  return (CAN_ASSIGN);
140  case OME_OID:
141  if (srcType == OME_NIL) {
142  //cerr << "oid assigned to nil\n";
143  return (CAN_ASSIGN);
144  }
145  return (INCOMPATIBLE_TYPES);
146  case OME_STRING:
147  return (INCOMPATIBLE_TYPES);
148  case OME_DOUBLE:
149  switch (srcType) {
150  case OME_FLOAT: // can promote to double
152  case OME_INT32:
153  case OME_INT64:
154  case OME_UINT64:
155  case OME_UINT32:
156  case OME_UINT16:
157  case OME_UINT8:
158  return (CAN_PROMOTE | CAN_ASSIGN);
159  default:
160  return (INCOMPATIBLE_TYPES);
161  } // end switch srcType
162  break;
163  case OME_FLOAT:
164  switch (srcType) {
165  case OME_DOUBLE: // can promote to double
166  return (CAN_DEMOTE | SAME_BASE_TYPE | CAN_ASSIGN);
167  case OME_INT32:
168  case OME_INT64:
169  case OME_UINT64:
170  case OME_UINT32:
171  case OME_UINT16:
172  case OME_UINT8:
173  return (CAN_PROMOTE | CAN_ASSIGN);
174  default:
175  return (INCOMPATIBLE_TYPES);
176  } // end switch srcType
177  break;
178  case OME_INT64:
179  isSigned = true;
180  // fallthrough intentionally
181  case OME_UINT64:
182  switch (srcType) {
183  // NOTE: identical types have been handled above
184  case OME_INT64:
185  case OME_UINT64:
187  case OME_INT32:
188  if (isSigned == true) {
190  }
192  case OME_UINT32:
193  case OME_UINT16:
194  case OME_UINT8:
195  if (isSigned == false) {
197  }
199  case OME_FLOAT:
200  case OME_DOUBLE:
201  // TODO: add CAN_ASSIGN?
202  return (CAN_DEMOTE);
203  default:
204  return (INCOMPATIBLE_TYPES);
205 
206  } // end switch (srcType)
207  break;
208  case OME_INT32:
209  isSigned = true;
210  // fallthrough intentionally
211  case OME_UINT32:
212  switch (srcType) {
213  case OME_INT64:
214  if (isSigned == true) {
215  return (CAN_DEMOTE | CAN_ASSIGN);
216  }
218  case OME_UINT64:
219  if (isSigned == false) {
220  return (CAN_DEMOTE | CAN_ASSIGN);
221  }
223  case OME_INT32:
224  case OME_UINT32:
226  case OME_UINT16:
227  case OME_UINT8:
228  if (isSigned == false) {
229  return (CAN_PROMOTE | CAN_ASSIGN);
230  }
232  default:
233  return (INCOMPATIBLE_TYPES);
234  }
235  break;
236  case OME_UINT16:
237  // TODO
238  break;
239  case OME_UINT8:
240  // TODO
241  break;
242  } // end switch targetType
243  // NOTREACHED
244  return (INCOMPATIBLE_TYPES);
245  }
246 }; // end class OME_TypeCheck
247 
250 class OME_DLL_EXPORT OMEbaseType
251 {
252 public:
259  static constexpr const char *typeName(const unsigned int t) OME_CONST_FUNCTION {
260  // ensure type is not beyond type range
261  // 32 = POWER_OF_2_TYPE_TABLE_SIZE in OMEtype.cpp
262  return (_OMEtypeTable[t & (32 - 1)].typeName);
263 
264  }
265 
272  static constexpr const char *enumName(const unsigned int t) OME_CONST_FUNCTION {
273  // ensure type is not beyond type range
274  // 32 = POWER_OF_2_TYPE_TABLE_SIZE in OMEtype.cpp
275  return (_OMEtypeTable[t & (32 - 1)].enumName);
276 
277  }
278 
279  static OMEbaseType *decode(const class OMEstring *data, size_t *offset,
280  const uint32_t version = 0);
281 
282  int encode(class OMEencodeBuffer *) const; // NOT A STATIC FUNCTION
283 public:
284  union {
285  int32_t i;
286  uint32_t ui;
287  float f;
288 #if (FORCE_OME_EXTENDED_TYPE == 0) && (__SIZEOF_POINTER__ == 8)
289  int64_t i64;
290  uint64_t ui64;
291  double df;
292 #endif
294  class OMEarray *array;
295  class OMEarray *arrayPtr; // alias since gdb cannot deal with array
296  class OMEassoc *assoc;
297  class OMEoid *oid;
298  class OMEset *set;
299  class OMEstring *s;
300  class OMEfixed *fixed;
301  class OMEnlm *nlm;
302  OMEbaseType *pointer;
303  } value;
304  uint32_t type;
305 
306 private:
307  void freeComplexData();
308 
310  {
311  if (OMEtypeClass(type) != OME_SIMPLE_TYPE) {
312  freeComplexData();
313  }
314  }
315 
316  void makeUnique();
317 
318 public:
319  // destructor
320  ~OMEbaseType()
321  {
322  freeData();
323  }
324 
326  OMEbaseType()
327  {
328  type = OME_NIL;
329  }
330 
332  OMEbaseType(const OMEbaseType &org) {
333  type = OME_NIL;
334  *this = org;
335  }
336 
338  explicit OMEbaseType(const enum OMEtypes_t t)
339  {
340  type = OME_NIL;
341  initializeAsType(t);
342  }
343 
344  explicit OMEbaseType(int32_t arg)
345  {
346  type = OME_INT32;
347  value.i = arg;
348  }
349 
350  explicit OMEbaseType(uint32_t arg)
351  {
352  type = OME_UINT32;
353  value.ui = arg;
354  }
355 
356  explicit OMEbaseType(uint16_t arg)
357  {
358  type = OME_UINT16;
359  value.ui = arg;
360  }
361 
362  explicit OMEbaseType(uint8_t arg)
363  {
364  type = OME_UINT8;
365  value.ui = arg;
366  }
367 
368  explicit OMEbaseType(float arg)
369  {
370  type = OME_FLOAT;
371  value.f = arg;
372  }
373 
374  explicit OMEbaseType(uint64_t arg)
375  {
376  type = OME_UINT64;
377 #if (FORCE_OME_EXTENDED_TYPE == 1) || (__SIZEOF_POINTER__ < 8)
378  value.extType = new OMEextendedType(arg);
379 #else
380  value.ui64 = arg;
381 #endif
382  }
383 
384  explicit OMEbaseType(int64_t arg)
385  {
386  type = OME_INT64;
387 #if (FORCE_OME_EXTENDED_TYPE == 1) || (__SIZEOF_POINTER__ < 8)
388  value.extType = new OMEextendedType(arg);
389 #else
390  value.i64 = arg;
391 #endif
392  }
393 
394  explicit OMEbaseType(double arg)
395  {
396  type = OME_DOUBLE;
397 #if (FORCE_OME_EXTENDED_TYPE == 1) || (__SIZEOF_POINTER__ < 8)
398  value.extType = new OMEextendedType(arg);
399 #else
400  value.df = arg;
401 #endif
402  }
403 
404  explicit OMEbaseType(const OMEfixed &arg)
405  {
406  type = OME_FIXED;
407  value.fixed = new OMEfixed(arg);
408  }
409 
411  explicit OMEbaseType(const OMEstring &s)
412  {
413  type = OME_STRING;
414  value.s = new OMEstring(s);
415  }
416 
418  explicit OMEbaseType(OMEstring *s)
419  {
420  type = OME_STRING;
421  value.s = s;
422  }
423 
425  explicit OMEbaseType(OMEstringInROM s, int len = -1) {
426  type = OME_STRING;
427  value.s = new OMEstring(s, len);
428  }
429 
431  explicit OMEbaseType(const OMEarray &a)
432  {
433  type = OME_ARRAY;
434  value.array = new OMEarray(a);
435  }
436 
438  explicit OMEbaseType(const OMEassoc &a)
439  {
440  type = OME_ASSOC;
441  value.assoc = new OMEassoc(a);
442  }
443 
445  explicit OMEbaseType(const OMEset &s)
446  {
447  type = OME_SET;
448  value.set = new OMEset(s);
449  }
450 
451  void initializeAsType(const enum OMEtypes_t t);
452 
453  // Reference Operators
454 # ifdef OBSOLETE
455  void addReadOnlyReference();
456  void dropReference();
457  OMEbaseType *deepCopy() const;
458 # endif
459 
461  {
462  if (OMEtypeClass(type) != OME_REFERENCE_TYPE) {
463  return;
464  }
465  makeUnique();
466  }
467  // END REFERENCE OPERATORS
468  template <typename TO_TYPE> TO_TYPE convertToNumericType() const;
469 
470  // Casts
471  explicit operator int32_t() const;
472 
473  explicit operator uint32_t() const;
474 
475  explicit operator int64_t() const;
476 
477  explicit operator uint64_t() const;
478 
479  explicit operator float() const;
480 
481  explicit operator double() const;
482 
483  explicit operator const char *() const {
484  switch (type) {
485  case OME_STRING:
486  return ((const char *) (*value.s));
487  default:
488  return ("[NOTSTRING]");
489  }
490  }
491 
492  // simple assignment operators
493  OME_FAST_CALL OMEbaseType &operator=(const int16_t i)
494  {
495  freeData();
496  type = OME_INT32; // TODO: support int16_t
497  value.i = static_cast<int32_t>(i);
498  return (*this);
499  }
500 
501  OME_FAST_CALL OMEbaseType &operator=(const uint16_t i)
502  {
503  freeData();
504  type = OME_UINT16;
505  value.ui = static_cast<uint32_t>(i);
506  return (*this);
507  }
508 
509  OME_FAST_CALL OMEbaseType &operator=(const int32_t i)
510  {
511  freeData();
512  type = OME_INT32;
513  value.i = i;
514  return (*this);
515  }
516 
517  OME_FAST_CALL OMEbaseType &operator=(const uint32_t i)
518  {
519  freeData();
520  type = OME_UINT32;
521  value.ui = i;
522  return (*this);
523  }
524 
525  OME_FAST_CALL OMEbaseType &operator=(const float f)
526  {
527  freeData();
528  type = OME_FLOAT;
529  value.f = f;
530  return (*this);
531  }
532 
533  // ASSIGNMENT
534  // extended assignment operators
535  OME_FAST_CALL OMEbaseType &operator=(const double f) {
536  freeData();
537  type = OME_DOUBLE;
538 #if (FORCE_OME_EXTENDED_TYPE == 1) || (__SIZEOF_POINTER__ < 8)
539  value.extType = new OMEextendedType(f);
540 #else
541  value.df = f;
542 #endif
543  return (*this);
544  }
545 
546  OME_FAST_CALL OMEbaseType &operator=(const int64_t i) {
547  freeData();
548  type = OME_INT64;
549 #if (FORCE_OME_EXTENDED_TYPE == 1) || (__SIZEOF_POINTER__ < 8)
550  value.extType = new OMEextendedType(i);
551 #else
552  value.i64 = i;
553 #endif
554  return (*this);
555  }
556 
557  OME_FAST_CALL OMEbaseType &operator=(const uint64_t ui) {
558  freeData();
559  type = OME_UINT64;
560 #if (FORCE_OME_EXTENDED_TYPE == 1) || (__SIZEOF_POINTER__ < 8)
561  value.extType = new OMEextendedType(ui);
562 #else
563  value.ui64 = ui;
564 #endif
565  return (*this);
566  }
567 
568  OME_FAST_CALL OMEbaseType &operator=(const OMEfixedConstant *f) {
569  freeData();
570  type = OME_FIXED;
571  value.fixed = new OMEfixed(f->d);
572  return (*this);
573  }
574 
575  // complex assignment operators
576  // strings
577  OME_FAST_CALL OMEbaseType &operator=(const char c) {
578  freeData();
579  type = OME_STRING;
580  value.s = new OMEstring(((const unsigned char *) &c), 1);
581  return (*this);
582  }
583 
584  OME_FAST_CALL OMEbaseType &operator=(const unsigned char c) {
585  freeData();
586  type = OME_STRING;
587  value.s = new OMEstring(&c, 1);
588  return (*this);
589  }
590 
591  OME_FAST_CALL OMEbaseType &operator=(const char *s) {
592  freeData();
593  type = OME_STRING;
594  value.s = new OMEstring(s);
595  return (*this);
596  }
597 
599  freeData();
600  type = OME_STRING;
601  value.s = new OMEstring(s);
602  return (*this);
603  }
604 
605  OME_FAST_CALL OMEbaseType &operator=(const OMEstring &s) {
606  freeData();
607  type = OME_STRING;
608  value.s = new OMEstring(s);
609  return (*this);
610  }
611 
612  OME_FAST_CALL OMEbaseType &operator=(OMEstring *s) { // take ownership
613  freeData();
614  type = OME_STRING;
615  value.s = s; // take ownership...
616  return (*this);
617  }
618 
619  // fixed
620  OME_FAST_CALL OMEbaseType &operator=(const OMEfixed &f) {
621  freeData();
622  type = OME_FIXED;
623  value.fixed = new OMEfixed(f);
624  return (*this);
625  }
626 
627  OME_FAST_CALL OMEbaseType &operator=(OMEfixed *f) { // take ownership
628  freeData();
629  type = OME_FIXED;
630  value.fixed = f; // take ownership
631  return (*this);
632  }
633 
634  // oid
635  OME_FAST_CALL OMEbaseType &operator=(const OMEoid &o) {
636  freeData();
637  type = OME_OID;
638  value.oid = new OMEoid(o);
639  return (*this);
640  }
641 
642  OME_FAST_CALL OMEbaseType &operator=(OMEoid *o) { // take ownership
643  freeData();
644  type = OME_OID;
645  value.oid = o; // take ownership...
646  return (*this);
647  }
648 
649  // array
650  OME_FAST_CALL OMEbaseType &operator=(const OMEarray &a) {
651  freeData();
652  type = OME_ARRAY;
653  value.array = new OMEarray(a);
654  return (*this);
655  }
656 
657  OME_FAST_CALL OMEbaseType &operator=(OMEarray *a) { // take ownership...
658  freeData();
659  type = OME_ARRAY;
660  value.array = a; // take ownership...
661  return (*this);
662  }
663 
664  // assoc
665  OME_FAST_CALL OMEbaseType &operator=(const OMEassoc &a) {
666  freeData();
667  type = OME_ASSOC;
668  value.assoc = new OMEassoc(a);
669  return (*this);
670  }
671 
672  OME_FAST_CALL OMEbaseType &operator=(OMEassoc *a) { // take ownership...
673  freeData();
674  type = OME_ASSOC;
675  value.assoc = a; // take ownership...
676  return (*this);
677  }
678 
679  // set
680  OME_FAST_CALL OMEbaseType &operator=(const OMEset &s) {
681  freeData();
682  type = OME_SET;
683  value.set = new OMEset(s);
684  return (*this);
685  }
686 
687  OME_FAST_CALL OMEbaseType &operator=(OMEset *s) { // take ownership...
688  freeData();
689  type = OME_SET;
690  value.set = s; // take ownership...
691  return (*this);
692  }
693 
694  // native language message
695  OME_FAST_CALL OMEbaseType &operator=(const OMEnlm &m) {
696  freeData();
697  type = OME_NLM;
698  value.nlm = new OMEnlm(m);
699  return (*this);
700  }
701 
702  OME_FAST_CALL OMEbaseType &operator=(OMEnlm *m) { // take ownership...
703  freeData();
704  type = OME_NLM;
705  value.nlm = m; // take ownership...
706  return (*this);
707  }
708 
709  // assignment by same type
710  OME_FAST_CALL OMEbaseType &operator=(const OMEbaseType &);
711 
712  OME_FAST_CALL OMEbaseType &operator=(OMEbaseType *d); // take ownership...
713 
714  OME_FAST_CALL bool operator==(const char *) const;
715 
716  OME_FAST_CALL bool operator!=(const char *) const;
717 
718 #if 0 // OPERATORS
719  // COMPARISON
720 
721  OME_FAST_CALL bool operator==(const OMEbaseType &) const;
722 
723  OME_FAST_CALL bool operator==(const int32_t) const;
724 
725  OME_FAST_CALL bool operator==(const uint32_t) const;
726 
727  OME_FAST_CALL bool operator==(const float) const;
728 
729  OME_FAST_CALL bool operator==(const bool) const;
730 
731 
732  OME_FAST_CALL bool operator==(const OMEstring &) const;
733 
734  OME_FAST_CALL bool operator==(const OMEoid &) const;
735 
736  OME_FAST_CALL bool operator!=(const OMEbaseType &) const;
737 
738  OME_FAST_CALL bool operator!=(const int32_t) const;
739 
740  OME_FAST_CALL bool operator!=(const uint32_t) const;
741 
742  OME_FAST_CALL bool operator!=(const float) const;
743 
744  OME_FAST_CALL bool operator!=(const bool) const;
745 
746  OME_FAST_CALL bool operator!=(const OMEoid &) const;
747 
748  OME_FAST_CALL bool operator!=(const char *) const;
749 
750  OME_FAST_CALL bool operator!=(const OMEstring &) const;
751 
752  OME_FAST_CALL bool operator<(const OMEbaseType &) const;
753 
754  OME_FAST_CALL bool operator<(const int32_t) const;
755 
756  OME_FAST_CALL bool operator<(const uint32_t) const;
757 
758  OME_FAST_CALL bool operator<(const float) const;
759 
760  OME_FAST_CALL bool operator>(const OMEbaseType &) const;
761 
762  OME_FAST_CALL bool operator>(const uint32_t) const;
763 
764  OME_FAST_CALL bool operator>(const int32_t) const;
765 
766  OME_FAST_CALL bool operator<=(const OMEbaseType &) const;
767 
768  OME_FAST_CALL bool operator<=(const int32_t) const;
769 
770  OME_FAST_CALL bool operator<=(const uint32_t) const;
771 
772  OME_FAST_CALL bool operator<=(const float) const;
773 
774  OME_FAST_CALL bool operator>=(const OMEbaseType &) const;
775 
776  OME_FAST_CALL bool operator>=(const int32_t) const;
777 
778  OME_FAST_CALL bool operator>=(const uint32_t) const;
779 
780  OME_FAST_CALL bool operator>=(const float) const;
781 
782  // ARITHMETIC
783 # include <OMEtypeHdr1.genh>
784 
785 
786  // Integer-only operators
787 # include <OMEtypeHdr2.genh>
788 
789 #endif // OPERATORS
790 
791  // SUBSCRIPTING
792  OME_FAST_CALL READ_ONLY_OMEtype operator[](const uint64_t) const;
793 
794  OME_FAST_CALL OMEbaseType &operator[](const uint64_t);
795 
797  {
798  uint64_t ui = static_cast<uint64_t>(i);
799  READ_ONLY_OMEtype result = (*this)[ui];
800  return (result);
801  }
802 
804  {
805  uint64_t ui = static_cast<uint64_t>(i);
806  READ_ONLY_OMEtype result = (*this)[ui];
807  return (result);
808  }
809 
811  {
812  uint64_t ui = static_cast<uint64_t>(i);
813  READ_ONLY_OMEtype result = (*this)[ui];
814  return (result);
815  }
816 
817  OME_FAST_CALL OMEbaseType &operator[](const uint32_t i)
818  {
819  uint64_t ui = static_cast<uint64_t>(i);
820  OMEbaseType &result = (*this)[ui];
821  return (result);
822  }
823 
824  OME_FAST_CALL OMEbaseType &operator[](const int64_t i)
825  {
826  uint64_t ui = static_cast<uint64_t>(i);
827  OMEbaseType &result = (*this)[ui];
828  return (result);
829  }
830 
831  OME_FAST_CALL OMEbaseType &operator[](const int32_t i)
832  {
833  uint64_t ui = static_cast<uint64_t>(i);
834  OMEbaseType &result = (*this)[ui];
835  return (result);
836  }
837 
838  // associative subscript with read-only access
839  OME_FAST_CALL READ_ONLY_OMEtype operator[](const OMEbaseType &) const;
840 
842 
844  {
845  OMEstring s(reinterpret_cast<OMEstringInROM>(k));
846 
847  READ_ONLY_OMEtype result = (*this)[s];
848  return (result);
849  }
850 
851  OME_FAST_CALL OMEbaseType &operator[](const OMEbaseType &);
852 
853  OME_FAST_CALL OMEbaseType &operator[](const OMEstring &);
854 
855  OME_FAST_CALL OMEbaseType &operator[](const char *k) NONNULL_CLASS_PARAMETERS(2)
856  {
857  OMEstring s(k);
858 
859  OMEbaseType &result = (*this)[s];
860  return (result);
861  }
862 
863  // simple chained operators...
864 
865  // output functions
866  enum OMEtype_OutputFlags_t : uint8_t {
867  OUTPUT_TYPENAME = (1 << 0),
868  DISABLE_QUOTE_OUTPUT = (1 << 1),
869  OUTPUT_NEWLINE = (1 << 2)
870  };
871  template <typename STREAMTYPE> STREAMTYPE &outputOnStream(STREAMTYPE &outputOnStream,
872  int_fast16_t indent = 0, uint8_t includeTypePrefix = OUTPUT_TYPENAME) const;
873 
874  const char *typeName() const NONNULL_RETURN
875  {
876  return (OMEbaseType::typeName(type));
877  }
878 }; // end class OMEbaseType
879 
880 # ifndef DOXYGEN_ONLY
881 # define OMEtype OMEbaseType
882 # endif
883 
884 template <typename TO_TYPE> inline TO_TYPE OMEbaseType::convertToNumericType() const
885 {
886  TO_TYPE result;
887 
888  switch (type) {
889  case OME_INT32:
890  result = static_cast<TO_TYPE>(value.i);
891  break;
892  case OME_UINT32:
893  case OME_UINT16:
894  case OME_UINT8:
895  result = static_cast<TO_TYPE>(value.ui);
896  break;
897  case OME_INT64:
898  result = static_cast<TO_TYPE>(OME_EXT_TYPE(i64));
899  break;
900  case OME_UINT64:
901  result = static_cast<TO_TYPE>(OME_EXT_TYPE(ui64));
902  break;
903  case OME_FLOAT:
904  result = static_cast<TO_TYPE>(value.f);
905  break;
906  case OME_DOUBLE:
907  result = static_cast<TO_TYPE>(OME_EXT_TYPE(df));
908  break;
909  default:
910  result = static_cast<TO_TYPE>(0);
911  break;
912  }
913  return (result);
914 }
915 
916 inline OMEbaseType::operator int32_t() const
917 {
918  return (convertToNumericType<int32_t>());
919 }
920 
921 inline OMEbaseType::operator uint32_t() const
922 {
923  return (convertToNumericType<uint32_t>());
924 }
925 
926 inline OMEbaseType::operator int64_t() const
927 {
928  return (convertToNumericType<int64_t>());
929 }
930 
931 inline OMEbaseType::operator uint64_t() const
932 {
933  return (convertToNumericType<uint64_t>());
934 }
935 
936 inline OMEbaseType::operator float() const
937 {
938  return (convertToNumericType<float>());
939 }
940 
941 inline OMEbaseType::operator double() const
942 {
943  return (convertToNumericType<double>());
944 }
945 
946 #include <OMEtype_operators.hpp>
947 
951 #endif
952 
953 /* vim: set expandtab shiftwidth=4 tabstop=4: */
OMEtype::operator=
OME_FAST_CALL OMEtype & operator=(const OMEnlm &m)
Definition: OMEbaseType.h:695
OME_TypeCheck::DISSIMILAR_SIGN
@ DISSIMILAR_SIGN
signed vs. unsigned
Definition: OMEbaseType.h:65
OME_EXT_TYPE
#define OME_EXT_TYPE(member)
Definition: OMEbaseType.h:19
OME_TypeCheck::UNKNOWN_COMPATIBILITY
@ UNKNOWN_COMPATIBILITY
right side is ANY
Definition: OMEbaseType.h:69
OME_TypeCheck::isInteger
static constexpr bool isInteger(uint32_t t) OME_CONST_FUNCTION
Definition: OMEbaseType.h:105
OME_NLM
@ OME_NLM
Definition: OMEmanifests.h:90
OMEtype::operator[]
OME_FAST_CALL READ_ONLY_OMEtype operator[](const int64_t i) const
Definition: OMEbaseType.h:803
l
Ïúíþ ð Ø ˜ ˜ __text __TEXT € __apple_names __DWARF __apple_objc __DWARF __apple_namespac__DWARF H X __apple_types __DWARF l
Definition: tmp3.o.cpp:1
operator!=
bool operator!=(const OMEtype &lArg, const OMEtype &rArg)
Definition: OMEtype_operators.cpp:5508
OMEtype::operator=
OME_FAST_CALL OMEtype & operator=(const int32_t i)
Definition: OMEbaseType.h:509
OME_FLOAT
@ OME_FLOAT
Definition: OMEmanifests.h:82
OMEtype::operator=
OME_FAST_CALL OMEtype & operator=(const uint64_t ui)
Definition: OMEbaseType.h:557
OMEbase64alphabet
const unsigned char OMEbase64alphabet[]
Definition: OMEbase64.cpp:20
OMEtype::OMEtype_OutputFlags_t
OMEtype_OutputFlags_t
Definition: OMEbaseType.h:866
s
const char s[]
Definition: t.cpp:4
OME_TypeCheck::OPTIONAL_TYPE_FLAG
@ OPTIONAL_TYPE_FLAG
Definition: OMEbaseType.h:74
OMEtype::typeName
const char * typeName() const NONNULL_RETURN
Definition: OMEbaseType.h:874
OMEnlm::operator=
OMEnlm & operator=(const OMEnlm &arg)
Definition: OMEnlm.h:142
OME_POINTER
@ OME_POINTER
Definition: OMEmanifests.h:92
OMEtype::operator=
OME_FAST_CALL OMEtype & operator=(const OMEarray &a)
Definition: OMEbaseType.h:650
OME_TypeCheck::is64BitInteger
static constexpr bool is64BitInteger(uint32_t t) OME_CONST_FUNCTION
Definition: OMEbaseType.h:101
OMEtype::fixed
class OMEfixed * fixed
Definition: OMEbaseType.h:300
OMEtype::operator=
OME_FAST_CALL OMEtype & operator=(OMEoid *o)
Definition: OMEbaseType.h:642
OMEtype::freeData
void freeData() OME_ALWAYS_INLINE
Definition: OMEbaseType.h:309
OME_UINT16
@ OME_UINT16
Definition: OMEmanifests.h:98
OME_TypeCheck::CAN_DEMOTE
@ CAN_DEMOTE
large size to small
Definition: OMEbaseType.h:67
OMEtype::operator=
OME_FAST_CALL OMEtype & operator=(const char *s)
Definition: OMEbaseType.h:591
OMEtype::operator[]
OME_FAST_CALL READ_ONLY_OMEtype operator[](const int32_t i) const
Definition: OMEbaseType.h:810
OMEassoc
Implements associative array of OMEtype elements.
Definition: OMEassoc.h:112
OMEreferenceToData< OMEnlmStorage >::addReadOnlyReference
void addReadOnlyReference() OME_ALWAYS_INLINE
Definition: OMErefCount.h:84
OMEstring
Implements text and binary string storage.
Definition: OMEstring.h:305
OMEencodeBuffer
Buffer into which OMEtype data is encoded.
Definition: OMEencode.h:54
OMEtype::operator=
OME_FAST_CALL OMEtype & operator=(const OMEassoc &a)
Definition: OMEbaseType.h:665
OME_REFERENCE_TYPE
#define OME_REFERENCE_TYPE
A complex, reference counted type.
Definition: OMEtype.h:41
OMEtype::operator=
OME_FAST_CALL OMEtype & operator=(const uint16_t i)
Definition: OMEbaseType.h:501
OME_DOUBLE
@ OME_DOUBLE
Definition: OMEmanifests.h:83
OMEtype::operator[]
OME_FAST_CALL OMEtype & operator[](const uint32_t i)
Definition: OMEbaseType.h:817
OMEstring::determineCharacterSet
void determineCharacterSet()
Definition: OMEstring.h:391
OMEtype::oid
class OMEoid * oid
Definition: OMEbaseType.h:297
OMEstringInROM
const typedef void * OMEstringInROM
Points to immovable, read-only string data.
Definition: OMEstring.h:68
operator<
bool operator<(const OMEtype &lArg, const OMEtype &rArg)
Definition: OMEtype_operators.cpp:10983
OME_UINT32
@ OME_UINT32
Definition: OMEmanifests.h:96
OMEtype::operator=
OME_FAST_CALL OMEtype & operator=(const double f)
Definition: OMEbaseType.h:535
OMEtype::s
class OMEstring * s
Definition: OMEbaseType.h:299
OMEtypeClass
#define OMEtypeClass(t)
Definition: OMEtype.h:54
NONNULL_CLASS_PARAMETERS
#define NONNULL_CLASS_PARAMETERS(...)
Mark a function as never returning a null pointer.
Definition: compiler_hints.h:337
OMEextendedType::OMEextendedType
OMEextendedType(int64_t i)
Definition: OMEbaseType.h:42
OMEtype::operator=
OME_FAST_CALL OMEtype & operator=(const unsigned char c)
Definition: OMEbaseType.h:584
OMEtype::i
int32_t i
Definition: OMEbaseType.h:285
OMEtype::array
class OMEarray * array
Definition: OMEbaseType.h:294
OMEstring::truncateToLength
void truncateToLength(size_t newLen)
Definition: OMEstring.h:531
OMEtype::operator[]
OME_FAST_CALL READ_ONLY_OMEtype operator[](const uint32_t i) const
Definition: OMEbaseType.h:796
OMEextendedType::OMEextendedType
OMEextendedType(double f)
Definition: OMEbaseType.h:37
OMEtype::nlm
class OMEnlm * nlm
Definition: OMEbaseType.h:301
OME_TypeCheck::IDENTICAL_TYPES
@ IDENTICAL_TYPES
same exact types
Definition: OMEbaseType.h:62
OME_SIMPLE_TYPE
#define OME_SIMPLE_TYPE
A simple native type.
Definition: OMEtype.h:39
OMEtype::operator=
OME_FAST_CALL OMEtype & operator=(const OMEfixedConstant *f)
Definition: OMEbaseType.h:568
_OMEtypeTable
const _OMEtypeDescription _OMEtypeTable[POWER_OF_2_TYPE_TABLE_SIZE]
Definition: OMEtype.cpp:48
PAD
#define PAD
Definition: OMEbase64.cpp:18
OMEtype::operator[]
OME_FAST_CALL OMEtype & operator[](const char *k) NONNULL_CLASS_PARAMETERS(2)
Definition: OMEbaseType.h:855
makeUnique
int makeUnique(OMEthread *thread, OMEtype &result, const OMEtype &arg)
Definition: OILdebug.cpp:357
OME_TypeCheck::typesAreAssignable
static uint32_t typesAreAssignable(uint32_t srcType, uint32_t targetType) OME_CONST_FUNCTION
Definition: OMEbaseType.h:114
OMEnlm
Public interface to an OME Native Language Message.
Definition: OMEnlm.h:98
OMEtype::operator[]
OME_FAST_CALL OMEtype & operator[](const int64_t i)
Definition: OMEbaseType.h:824
OMEtype::operator=
OME_FAST_CALL OMEtype & operator=(const OMEstring &s)
Definition: OMEbaseType.h:605
OMEtype::operator=
OME_FAST_CALL OMEtype & operator=(const uint32_t i)
Definition: OMEbaseType.h:517
srcID
const char srcID[]
Definition: catSym.c:17
OME_STRING
@ OME_STRING
Definition: OMEmanifests.h:85
OMEstring::noteCharacterSet
void noteCharacterSet(uint_fast8_t c)
Definition: OMEstring.h:386
OMEtype::operator=
OME_FAST_CALL OMEtype & operator=(const OMEset &s)
Definition: OMEbaseType.h:680
OMEfundamentalType
#define OMEfundamentalType(t)
Definition: OMEtype.h:55
OMEset
Implements an ordered list of OMEtype elements.
Definition: OMEset.h:64
OME_TypeCheck::CAN_PROMOTE
@ CAN_PROMOTE
small size convertable to larger
Definition: OMEbaseType.h:66
OME_TypeCheck::TypeCompatibility_t
TypeCompatibility_t
Definition: OMEbaseType.h:61
OMEtype::operator=
OME_FAST_CALL OMEtype & operator=(OMEstring *s)
Definition: OMEbaseType.h:612
OME_TypeCheck::TYPE_MASK
@ TYPE_MASK
Definition: OMEbaseType.h:73
OMEtype::pointer
OMEtype * pointer
Definition: OMEbaseType.h:302
OME_TypeCheck::isHeldBy32BitInteger
static constexpr bool isHeldBy32BitInteger(uint32_t t) OME_CONST_FUNCTION
Definition: OMEbaseType.h:96
OME_TypeCheck::ASSUME_COMPATIBLE
@ ASSUME_COMPATIBLE
left side is ANY
Definition: OMEbaseType.h:70
OME_NIL
@ OME_NIL
Definition: OMEmanifests.h:78
OMEnlm::operator[]
const OMEtype & operator[](const OMEarray::ARRAY_SUBSCRIPT_t i) const
Definition: OMEnlm.h:191
OME_OID
@ OME_OID
Definition: OMEmanifests.h:84
OMEtype::f
float f
Definition: OMEbaseType.h:287
OMEtypes_t
OMEtypes_t
Definition: OMEmanifests.h:77
OMEstring::getCharacterSet
uint_fast8_t getCharacterSet() const
Definition: OMEstring.h:396
OMEtype::operator=
OME_FAST_CALL OMEtype & operator=(const float f)
Definition: OMEbaseType.h:525
OMEtype::operator=
OME_FAST_CALL OMEtype & operator=(OMEfixed *f)
Definition: OMEbaseType.h:627
ILLEGAL
#define ILLEGAL
Definition: OMEbase64.cpp:16
OMEtype::operator[]
OME_FAST_CALL OMEtype & operator[](const int32_t i)
Definition: OMEbaseType.h:831
OMEhexToBinary
size_t OMEhexToBinary(const unsigned char *src, size_t srcLen, unsigned char *dest, size_t destLen)
Convert hexadecimal text to binary.
Definition: OMEbase64.cpp:225
OMEbase64ToBinary
OMEstring * OMEbase64ToBinary(const OMEstring &source)
Convert base-64 encoded text to its binary representation.
Definition: OMEbase64.cpp:156
OME_UINT64
@ OME_UINT64
Definition: OMEmanifests.h:97
OMEtype.h
OME fundamental type implementation.
OME_TypeCheck::OME_CONST_POINTER
@ OME_CONST_POINTER
Definition: OMEbaseType.h:75
OMEtype::operator=
OME_FAST_CALL OMEtype & operator=(OMEnlm *m)
Definition: OMEbaseType.h:702
OMEtype_operators.hpp
OMEtype::operator=
OME_FAST_CALL OMEtype & operator=(OMEarray *a)
Definition: OMEbaseType.h:657
OMEtype::operator=
OME_FAST_CALL OMEtype & operator=(OMEstringInROM s)
Definition: OMEbaseType.h:598
OMEtype::operator=
OME_FAST_CALL OMEtype & operator=(OMEset *s)
Definition: OMEbaseType.h:687
OMEtype::ui
uint32_t ui
Definition: OMEbaseType.h:286
OME_TypeCheck
Utility class for type check operations on OMEtype interactions.
Definition: OMEbaseType.h:58
OMEstring::length
size_t length() const
Definition: OMEstring.h:401
OME_TypeCheck::isTypeANY
static bool isTypeANY(uint32_t t) OME_CONST_FUNCTION
Definition: OMEbaseType.h:82
OME_USED
const char srcID[] OME_USED
Definition: tick_time.cpp:24
OMEnlm::OMEnlm
OMEnlm(OMEnlmStorage *s)
Definition: OMEnlm.h:101
OME_TypeCheck::INCOMPATIBLE_TYPES
@ INCOMPATIBLE_TYPES
no conversion possible
Definition: OMEbaseType.h:68
OME_CONST_FUNCTION
#define OME_CONST_FUNCTION
Mark as an idempotent function that only accesses arguments – no global data.
Definition: compiler_hints.h:390
OMEextendedType::i64
int64_t i64
Definition: OMEbaseType.h:33
OME_TypeCheck::is32BitInteger
static constexpr bool is32BitInteger(uint32_t t) OME_CONST_FUNCTION
Definition: OMEbaseType.h:92
OMEtype::getUniqueReference
void getUniqueReference() OME_ALWAYS_INLINE
Definition: OMEbaseType.h:460
OMEtype::extType
class OMEextendedType * extType
Definition: OMEbaseType.h:293
OME_SET
@ OME_SET
Definition: OMEmanifests.h:89
OME_TypeCheck::SAME_BASE_TYPE
@ SAME_BASE_TYPE
exact same basic type
Definition: OMEbaseType.h:64
ntohl
#define ntohl(x)
Definition: tmp.o.cpp:3101
operator<=
bool operator<=(const OMEtype &lArg, const OMEtype &rArg)
Definition: OMEtype_operators.cpp:13657
OMEmanifests.h
OME constants and typedefs.
OME_TypeCheck::CAN_ASSIGN
@ CAN_ASSIGN
can assign into type
Definition: OMEbaseType.h:63
OMEfixed
Public interface to OME fixed-point type.
Definition: OMEfixed.h:85
OME_ALWAYS_INLINE
#define OME_ALWAYS_INLINE
Tell the compiler to alway inline a function, regardless of optimization level.
Definition: compiler_hints.h:364
OMEreferenceToData< OMEnlmStorage >::dropReference
void dropReference(OMEnlmStorage *newData=nullptr) OME_ALWAYS_INLINE
Definition: OMErefCount.h:91
OME_UINT8
@ OME_UINT8
Definition: OMEmanifests.h:99
OME_FAST_CALL
#define OME_FAST_CALL
Definition: compiler_hints.h:468
OME_TypeCheck::isContainer
static constexpr bool isContainer(uint32_t t) OME_CONST_FUNCTION
Definition: OMEbaseType.h:109
OME_FIXED
@ OME_FIXED
Definition: OMEmanifests.h:91
OME_DLL_EXPORT
#define OME_DLL_EXPORT
Definition: compiler_hints.h:464
OMEtype::arrayPtr
class OMEarray * arrayPtr
Definition: OMEbaseType.h:295
OMEbinaryToBase64
OMEstring * OMEbinaryToBase64(const OMEstring &source, bool breakIntoLines)
Convert binary data to base64 text encoding.
Definition: OMEbase64.cpp:112
OMEarray
Implements sparse array of OMEtype elements.
Definition: OMEarray.h:75
OMEoid
Public interface to an OME Object Identifier.
Definition: OMEoid.h:196
OME_ANY
@ OME_ANY
Definition: OMEmanifests.h:93
OMEextendedType::ui64
uint64_t ui64
Definition: OMEbaseType.h:34
OMEtype::type
uint32_t type
Definition: OMEbaseType.h:304
operator>=
bool operator>=(const OMEtype &lArg, const OMEtype &rArg)
Definition: OMEtype_operators.cpp:19005
READ_ONLY_OMEtype
const class OMEtype & READ_ONLY_OMEtype
A convenience typedef for performing read-only access to sparse and associative arrays....
Definition: OMEtype.h:58
OMEnlm::outputOnStream
STREAMTYPE & outputOnStream(STREAMTYPE &outputStream, int_fast16_t indent=0, uint8_t includeTypePrefix=OME_DEFAULT_COMPLEX_OUTPUT_MODE, const OMEstring *lang=nullptr) const
Output an OMEnlm object to an output stream.
Definition: OMEnlm.h:242
OMEextendedType::OMEextendedType
OMEextendedType(uint64_t ui)
Definition: OMEbaseType.h:47
OMEtype::operator[]
OME_FAST_CALL READ_ONLY_OMEtype operator[](const char *k) const NONNULL_CLASS_PARAMETERS(2)
Definition: OMEbaseType.h:843
OMEtype::operator=
OME_FAST_CALL OMEtype & operator=(const char c)
Definition: OMEbaseType.h:577
OMEbinaryToHex
OMEstring * OMEbinaryToHex(const unsigned char *srcBfr, size_t srcLen)
Convert binary data to hexadecimal characters.
Definition: OMEbase64.cpp:252
OMEextendedType
Storage record for large-sized elements on 32-bit hardware.
Definition: OMEbaseType.h:28
OME_TypeCheck::baseType
static uint32_t baseType(uint32_t t) OME_CONST_FUNCTION
Definition: OMEbaseType.h:78
OMEtype::typeName
static constexpr const char * typeName(const unsigned int t) OME_CONST_FUNCTION
Return text identifying the indicated OME type.
Definition: OMEbaseType.h:259
OME_ARRAY
@ OME_ARRAY
Definition: OMEmanifests.h:86
operator>
bool operator>(const OMEtype &lArg, const OMEtype &rArg)
Definition: OMEtype_operators.cpp:16331
OMEtype::operator=
OME_FAST_CALL OMEtype & operator=(const OMEfixed &f)
Definition: OMEbaseType.h:620
OMEnlm::deepCopy
OMEnlm * deepCopy() const
Definition: OMEnlm.h:222
OMEtype::assoc
class OMEassoc * assoc
Definition: OMEbaseType.h:296
OMEtype::set
class OMEset * set
Definition: OMEbaseType.h:298
_OMEfixedConstant
Internal data type to generate fixed-point constant from floating-point value.
Definition: OMEfixed.h:26
OMEtype::enumName
static constexpr const char * enumName(const unsigned int t) OME_CONST_FUNCTION
Return text identifying the OME enum name for the indicated type.
Definition: OMEbaseType.h:272
htonl
#define htonl(x)
Definition: tmp.o.cpp:3098
_OMEfixedConstant::d
double d
Definition: OMEfixed.h:27
OMEextendedType::~OMEextendedType
~OMEextendedType()
Definition: OMEbaseType.h:52
OMEtype::operator=
OME_FAST_CALL OMEtype & operator=(const int64_t i)
Definition: OMEbaseType.h:546
NONNULL_RETURN
char NONNULL_RETURN
Definition: compiler_hints.h:745
OMEconvertURIescapes
OMEstring * OMEconvertURIescapes(const OMEstring &arg)
Convert Uniform Resource Identifier escape sequences.
Definition: OMEbase64.cpp:314
OMEextendedType::df
double df
Definition: OMEbaseType.h:32
OMEtype::operator=
OME_FAST_CALL OMEtype & operator=(const OMEoid &o)
Definition: OMEbaseType.h:635
OMEhexDigits
const unsigned char OMEhexDigits[]
Definition: OMEstring.cpp:19
OME_ASSOC
@ OME_ASSOC
Definition: OMEmanifests.h:87
operator==
bool operator==(const OMEtype &lArg, const OMEtype &rArg)
Definition: OMEtype_operators.cpp:33
OMEmakeSafeURI
OMEstring * OMEmakeSafeURI(const OMEstring &arg)
Escape any special characters in an Uniform Resource Identifier.
Definition: OMEbase64.cpp:366
OMEtype::operator=
OME_FAST_CALL OMEtype & operator=(OMEassoc *a)
Definition: OMEbaseType.h:672
OME_INT32
@ OME_INT32
Definition: OMEmanifests.h:79
OMEtype::operator=
OME_FAST_CALL OMEtype & operator=(const int16_t i)
Definition: OMEbaseType.h:493
OME_INT64
@ OME_INT64
Definition: OMEmanifests.h:81
Generated: Tue Jul 28 2020 16:03:25
Support Information