CFx SDK Documentation  2023 SP0
RxVariantValue.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2017, Open Design Alliance (the "Alliance").
3 // All rights reserved.
4 //
5 // This software and its documentation and related materials are owned by
6 // the Alliance. The software may only be incorporated into application
7 // programs owned by members of the Alliance, subject to a signed
8 // Membership Agreement and Supplemental Software License Agreement with the
9 // Alliance. The structure and organization of this software are the valuable
10 // trade secrets of the Alliance and its suppliers. The software is also
11 // protected by copyright law and international treaty provisions. Application
12 // programs incorporating this software must include the following statement
13 // with their copyright notices:
14 //
15 // This application incorporates Teigha(R) software pursuant to a license
16 // agreement with Open Design Alliance.
17 // Teigha(R) Copyright (C) 2002-2017 by Open Design Alliance.
18 // All rights reserved.
19 //
20 // By use of this software, its documentation or related materials, you
21 // acknowledge and accept the above terms.
23 
24 #ifndef _VARIANTVALUE_H_INCLUDED_
25 #define _VARIANTVALUE_H_INCLUDED_
26 
27 #include "TD_PackPush.h"
28 
29 #include "RxObject.h"
30 #include "RxVariant.h"
31 #include "RxObjectImpl.h"
32 
33 class OdRxVariant;
35 
44 class OdRxVariant : public OdRxObject, public OdVariant { };
45 
52 class OdRxVariantValue : public OdSmartPtr<OdRxVariant>
53 {
54 public:
59  void assign(const OdRxVariant* pVariant) { OdSmartPtr<OdRxVariant>::operator=(pVariant); }
60 
67  OdRxVariantValue(const OdRxObject* pObject) : OdSmartPtr<OdRxVariant>(pObject) {}
68 
69  OdRxVariantValue(const OdRxVariant* pVariant) : OdSmartPtr<OdRxVariant>(pVariant) {}
70 
71 #define ODRXVARVAL_CONSTR(type, setter) \
72  OdRxVariantValue(type value) \
73  { \
74  assign(OdRxObjectImpl<OdRxVariant>::createObject()); \
75  get()->setter(value); \
76  }
77  ODRXVARVAL_CONSTR(bool , setBool)
78  ODRXVARVAL_CONSTR(OdUInt8 , setUInt8)
79  ODRXVARVAL_CONSTR(OdInt8 , setInt8)
80  ODRXVARVAL_CONSTR(OdUInt16 , setUInt16)
81  ODRXVARVAL_CONSTR(OdInt16 , setInt16)
82  ODRXVARVAL_CONSTR(OdUInt32 , setUInt32)
83  ODRXVARVAL_CONSTR(OdInt32 , setInt32)
84  ODRXVARVAL_CONSTR(OdUInt64 , setUInt64)
85  ODRXVARVAL_CONSTR(OdInt64 , setInt64)
86 #ifdef OD_INTPTR_UNIQUE
87  ODRXVARVAL_CONSTR(OdIntPtr , setIntPtr)
88 #endif
89  ODRXVARVAL_CONSTR(double , setDouble)
90  ODRXVARVAL_CONSTR(const OdString&, setString)
91  ODRXVARVAL_CONSTR(const OdAnsiString&, setAnsiString)
92  ODRXVARVAL_CONSTR(const OdStringArray&, setStringArray)
93  ODRXVARVAL_CONSTR(const OdRxObjectPtrArray&, setRxObjectPtrArray)
94  ODRXVARVAL_CONSTR(const OdDoubleArray&, setDoubleArray)
95 #undef ODRXVARVAL_CONSTR
96 
101 #define ODRXVARVAL_IMPLICIT(type, getter) \
102  operator type() const \
103  { \
104  return get()->getter(); \
105  } \
106  operator type() \
107  { \
108  return get()->getter(); \
109  }
110  // #7196 : override OdSmartPtr<T>::operator bool() private member.
111  // #7196 : some compilers (MSVC) require non-const for all types if bool() member available.
112  ODRXVARVAL_IMPLICIT(bool , getBool)
113  ODRXVARVAL_IMPLICIT(OdUInt8 , getUInt8)
114  ODRXVARVAL_IMPLICIT(OdUInt16, getUInt16)
115  ODRXVARVAL_IMPLICIT(OdUInt32, getUInt32)
116  ODRXVARVAL_IMPLICIT(OdUInt64, getUInt64)
117  ODRXVARVAL_IMPLICIT(OdInt8 , getInt8)
118  ODRXVARVAL_IMPLICIT(OdInt16 , getInt16)
119  ODRXVARVAL_IMPLICIT(OdInt32 , getInt32)
120  ODRXVARVAL_IMPLICIT(OdInt64 , getInt64)
121 #ifdef OD_INTPTR_UNIQUE
122  ODRXVARVAL_IMPLICIT(OdIntPtr, getIntPtr)
123 #endif
124  ODRXVARVAL_IMPLICIT(double , getDouble)
125  ODRXVARVAL_IMPLICIT(OdString, getString)
126  ODRXVARVAL_IMPLICIT(OdAnsiString, getAnsiString)
127  ODRXVARVAL_IMPLICIT(OdStringArray, getStringArray)
128  ODRXVARVAL_IMPLICIT(OdRxObjectPtrArray, getRxObjectPtrArray)
129  ODRXVARVAL_IMPLICIT(OdDoubleArray, getDoubleArray)
130 #undef ODRXVARVAL_IMPLICIT
131 };
132 
133 #include "TD_PackPop.h"
134 
135 #endif //_VARIANTVALUE_H_INCLUDED_
unsigned int OdUInt32
short OdInt16
signed char OdInt8
unsigned short OdUInt16
int OdInt32
unsigned char OdUInt8
ptrdiff_t OdIntPtr
#define ODRXVARVAL_IMPLICIT(type, getter)
#define ODRXVARVAL_CONSTR(type, setter)
OdSmartPtr< OdRxVariant > OdRxVariantPtr
Definition: Int64.h:43
OdRxVariantValue(const OdRxObject *pObject)
OdRxVariantValue(const OdRxVariant *pVariant)
void assign(const OdRxVariant *pVariant)
OdSmartPtr & operator=(const OdSmartPtr &pObject)
Definition: SmartPtr.h:298