AcValue.h 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2015 Autodesk, Inc. All rights reserved.
  4. //
  5. // Use of this software is subject to the terms of the Autodesk license
  6. // agreement provided at the time of installation or download, or which
  7. // otherwise accompanies this software in either electronic or hard copy form.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. //
  11. // Name: AcValue.h
  12. //
  13. // Description:
  14. //////////////////////////////////////////////////////////////////////////////
  15. #pragma once
  16. #include "adesk.h"
  17. #include "AdAChar.h"
  18. class AcDbEvalVariant;
  19. typedef struct tagVARIANT VARIANT;
  20. typedef struct _SYSTEMTIME SYSTEMTIME;
  21. class AcDbObjectId;
  22. class AcGePoint2d;
  23. class AcGePoint3d;
  24. class AcCmColor;
  25. struct resbuf;
  26. class AcDbDwgFiler;
  27. class AcDbDxfFiler;
  28. #if __LP64__
  29. typedef unsigned int DWORD;
  30. #else
  31. typedef unsigned long DWORD;
  32. #endif
  33. //*************************************************************************
  34. // AcValue
  35. //*************************************************************************
  36. class AcValue : public AcRxObject
  37. {
  38. public:
  39. enum DataType
  40. {
  41. kUnknown = 0,
  42. kLong = (0x1 << 0),
  43. kDouble = (0x1 << 1),
  44. kString = (0x1 << 2),
  45. kDate = (0x1 << 3),
  46. kPoint = (0x1 << 4),
  47. k3dPoint = (0x1 << 5),
  48. kObjectId = (0x1 << 6),
  49. kBuffer = (0x1 << 7),
  50. kResbuf = (0x1 << 8),
  51. kGeneral = (0x1 << 9),
  52. kColor = (0x1 << 10),
  53. };
  54. enum UnitType
  55. {
  56. kUnitless = 0,
  57. kDistance = (0x1 << 0),
  58. kAngle = (0x1 << 1),
  59. kArea = (0x1 << 2),
  60. kVolume = (0x1 << 3),
  61. kCurrency = (0x1 << 4),
  62. kPercentage = (0x1 << 5),
  63. kAngleNotTransformed = (0x1 << 16),
  64. };
  65. enum ParseOption
  66. {
  67. kParseOptionNone = 0,
  68. kSetDefaultFormat = (0x1 << 0),
  69. kPreserveMtextFormat = (0x1 << 1),
  70. kConvertTextToValue = (0x1 << 2),
  71. kChangeDataType = (0x1 << 3),
  72. kParseTextForFieldCode = (0x1 << 4),
  73. };
  74. enum FormatOption
  75. {
  76. kFormatOptionNone = 0,
  77. kForEditing = (0x1 << 0),
  78. kForExpression = (0x1 << 1),
  79. kUseMaximumPrecision = (0x1 << 2),
  80. kIgnoreMtextFormat = (0x1 << 3),
  81. };
  82. public:
  83. static bool isValidDataType (const VARIANT& var);
  84. public:
  85. ACRX_DECLARE_MEMBERS(AcValue);
  86. ACDB_PORT AcValue(void);
  87. ACDB_PORT AcValue(AcValue::DataType nDataType);
  88. ACDB_PORT AcValue(const AcValue& value);
  89. ACDB_PORT AcValue(const ACHAR * pszValue);
  90. ACDB_PORT AcValue(Adesk::Int32 lValue);
  91. ACDB_PORT AcValue(double fValue);
  92. ACDB_PORT AcValue(const __time64_t& date);
  93. ACDB_PORT AcValue(const SYSTEMTIME& date);
  94. ACDB_PORT AcValue(const AcGePoint2d& pt);
  95. ACDB_PORT AcValue(double x, double y);
  96. ACDB_PORT AcValue(const AcGePoint3d& pt);
  97. ACDB_PORT AcValue(double x, double y, double z);
  98. ACDB_PORT AcValue(const AcDbObjectId& id);
  99. ACDB_PORT AcValue(const resbuf& rb);
  100. ACDB_PORT AcValue(const AcDbEvalVariant& evalVar);
  101. ACDB_PORT AcValue(const VARIANT& var);
  102. ACDB_PORT AcValue(const AcCmColor& var);
  103. ACDB_PORT AcValue(const void* pBuf, DWORD dwBufSize);
  104. ACDB_PORT ~AcValue(void);
  105. ACDB_PORT bool reset (void);
  106. ACDB_PORT bool reset (AcValue::DataType nDataType);
  107. ACDB_PORT bool resetValue (void);
  108. ACDB_PORT AcValue::DataType dataType (void) const;
  109. ACDB_PORT AcValue::UnitType unitType (void) const;
  110. ACDB_PORT bool setUnitType (AcValue::UnitType nUnitType);
  111. ACDB_PORT const ACHAR* getFormat (void) const;
  112. ACDB_PORT bool setFormat (const ACHAR* pszFormat);
  113. ACDB_PORT bool isValid (void) const;
  114. ACDB_PORT operator const ACHAR * (void) const;
  115. ACDB_PORT operator Adesk::Int32 (void) const;
  116. ACDB_PORT operator double (void) const;
  117. ACDB_PORT operator __time64_t (void) const;
  118. ACDB_PORT operator AcGePoint2d (void) const;
  119. ACDB_PORT operator AcGePoint3d (void) const;
  120. ACDB_PORT operator AcDbObjectId (void) const;
  121. ACDB_PORT AcValue& operator= (const AcValue& value);
  122. ACDB_PORT AcValue& operator= (const ACHAR * pszValue);
  123. ACDB_PORT AcValue& operator= (Adesk::Int32 lValue);
  124. ACDB_PORT AcValue& operator= (double fValue);
  125. ACDB_PORT AcValue& operator= (__time64_t date);
  126. ACDB_PORT AcValue& operator= (const AcGePoint2d& pt);
  127. ACDB_PORT AcValue& operator= (const AcGePoint3d& pt);
  128. ACDB_PORT AcValue& operator= (const AcDbObjectId& objId);
  129. ACDB_PORT AcValue& operator= (const resbuf& rb);
  130. ACDB_PORT AcValue& operator= (const AcDbEvalVariant& evalVar);
  131. ACDB_PORT AcValue& operator= (const VARIANT& var);
  132. ACDB_PORT AcValue& operator= (const AcCmColor& clr);
  133. ACDB_PORT bool operator== (const AcValue& val) const;
  134. ACDB_PORT bool operator!= (const AcValue& val) const;
  135. Adesk::Boolean isEqualTo (const AcRxObject* pOther) const;
  136. ACDB_PORT bool get (const ACHAR *& pszValue) const;
  137. ACDB_PORT bool get (ACHAR *& pszValue) const;
  138. ACDB_PORT bool get (Adesk::Int32& lValue) const;
  139. ACDB_PORT bool get (double& fValue) const;
  140. ACDB_PORT bool get (__time64_t& date) const;
  141. ACDB_PORT bool get (SYSTEMTIME& date) const;
  142. ACDB_PORT bool get (AcGePoint2d& pt) const;
  143. ACDB_PORT bool get (double& x,
  144. double& y) const;
  145. ACDB_PORT bool get (AcGePoint3d& pt) const;
  146. ACDB_PORT bool get (double& x,
  147. double& y,
  148. double& z) const;
  149. ACDB_PORT bool get (AcDbObjectId& objId) const;
  150. ACDB_PORT bool get (resbuf** pRb) const;
  151. ACDB_PORT bool get (AcDbEvalVariant& evalVar) const;
  152. ACDB_PORT bool get (VARIANT& var) const;
  153. ACDB_PORT bool get (AcCmColor& clr) const;
  154. ACDB_PORT bool get (void*& pBuf,
  155. DWORD& dwBufSize) const;
  156. ACDB_PORT bool set (const AcValue& value);
  157. ACDB_PORT bool set (const ACHAR* pszValue);
  158. ACDB_PORT bool set (AcValue::DataType nDataType,
  159. const ACHAR* pszValue);
  160. ACDB_PORT bool set (Adesk::Int32 lValue);
  161. ACDB_PORT bool set (double fValue);
  162. ACDB_PORT bool set (const __time64_t& date);
  163. ACDB_PORT bool set (const SYSTEMTIME& date);
  164. ACDB_PORT bool set (const AcGePoint2d& pt);
  165. ACDB_PORT bool set (double x,
  166. double y);
  167. ACDB_PORT bool set (const AcGePoint3d& pt);
  168. ACDB_PORT bool set (double x,
  169. double y,
  170. double z);
  171. ACDB_PORT bool set (const AcDbObjectId& objId);
  172. ACDB_PORT bool set (const resbuf& rb);
  173. ACDB_PORT bool set (const AcDbEvalVariant& evalVar);
  174. ACDB_PORT bool set (const VARIANT& var);
  175. ACDB_PORT bool set (const AcCmColor& clr);
  176. ACDB_PORT bool set (const void* pBuf,
  177. DWORD dwBufSize);
  178. ACDB_PORT bool parse (const ACHAR* pszText,
  179. AcValue::DataType nDataType,
  180. AcValue::UnitType nUnitType,
  181. const ACHAR* pszFormat,
  182. AcValue::ParseOption nOption,
  183. const AcDbObjectId* pTextStyleId);
  184. ACDB_PORT const ACHAR* format (void) const;
  185. ACDB_PORT AcString format (const ACHAR* pszFormat) const;
  186. ACDB_PORT bool format (ACHAR*& pszValue) const;
  187. ACDB_PORT bool format (const ACHAR* pszFormat,
  188. ACHAR*& pszValue) const;
  189. ACDB_PORT AcString format (AcValue::FormatOption nOption);
  190. ACDB_PORT AcString format (const ACHAR* pszFormat,
  191. AcValue::FormatOption nOption);
  192. ACDB_PORT bool convertTo (AcValue::DataType nDataType,
  193. AcValue::UnitType nUnitType);
  194. ACDB_PORT bool convertTo (AcValue::DataType nDataType,
  195. AcValue::UnitType nUnitType,
  196. bool bResetIfIncompatible);
  197. Acad::ErrorStatus dwgInFields (AcDbDwgFiler* pFiler);
  198. Acad::ErrorStatus dwgOutFields (AcDbDwgFiler* pFiler) const;
  199. Acad::ErrorStatus dxfInFields (AcDbDxfFiler* pFiler);
  200. Acad::ErrorStatus dxfOutFields (AcDbDxfFiler* pFiler) const;
  201. protected:
  202. void * mpImpObj;
  203. private:
  204. friend class AcSystemInternals;
  205. };
  206. typedef AcArray<AcValue, AcArrayObjectCopyReallocator<AcValue> > AcValueArray;