Drawings SDK Developer Guide > Working with .dwg Files > Working with Databases > Working with Tagged Data > Getting and Setting Typical Data (integer, double, boolean)
Getting and Setting Typical Data (integer, double, boolean)

Tagged data can store (8, 16, 32, 64)-bit integer, double, or Boolean values:

  • Group codes 280 to 289 define data as an 8-bit integer value.
  • Group codes 60 to 79, 170 to 179, 270 to 279, 370 to 389, 400 to 409, 1070, and 5003 define data as a 16-bit integer value.
  • Group codes 90 to 99, 420 to 429, 440 to 459, 1071, and 5010 define data as a 32-bit integer value.
  • Group code 160 to 169 define data as a 64-bit integer value.
  • Group codes 38 to 59, 140 to 149, 460 to 499, 1020 to 1023, 1030 to 1033, 1040 to 1042, 5001, and 5004 define data as a double-precision floating-point value.
  • Group codes 290 to 299 define data as a Boolean value.

In the following examples, the pRb variable stores a pointer to the resbuf-object.

8-bit Integer Value

To get the 8-bit integer value, use the getInt8() method which does not have arguments and returns an instance of the OdInt8 type. For example:


OdInt8 num8 = pRb->getInt8();
odPrintConsoleString(L"\nValue = %d (%x)", num8, num8);

To set the 8-bit integer value, use the setInt8() method which requires an instance of the OdInt8 type as an argument and does not return a value. For example:


pRb->setRestype(OdResBuf::kDxfInt8);
pRb->setInt8((OdInt8) 125);

Note: If the stored data type is 16-bit, the getInt8() method casts it to an 8-bit integer value. If the stored data type is more than 16-bit, the getInt8() method generates the exception "68 - Invalid ResBuf".

16-bit Integer Value

To get the 16-bit integer value, use the getInt16() method which does not have arguments and returns an instance of the OdInt16 type. For example:


OdInt16 num16 = pRb->getInt16();
odPrintConsoleString(L"\nValue = %d (%x)", num16, num16);

To set the 16-bit integer value, use the setInt16() method which requires an instance of the OdInt16 type as an argument and does not return a value. For example:


pRb->setRestype(OdResBuf::kDxfInt16);
pRb->setInt16((OdInt16) 12600);

Note: If the stored data type is 8-bit, the getInt16() method casts it to a 16-bit integer value. If the stored data type is more than 16-bit, the getInt16() method generates the exception "68 - Invalid ResBuf".

32-bit Integer Value

To get the 32-bit integer value, use the getInt32() method which does not have arguments and returns an instance of the OdInt32 type. For example:


OdInt32 num32 = pRb->getInt32();
odPrintConsoleString(L"\nValue = %ld (%lx)", num32, num32);

To set the 32-bit integer value, use the setInt32() method which requires an instance of the OdInt32 type as an argument and does not return a value. For example:


pRb->setRestype(OdResBuf::kDxfInt32);
pRb->setInt32((OdInt32) 12680450);

Note: If the stored data type is 8-bit or 16-bit, the getInt32() method casts it to a 32-bit integer value. If the stored data type is 64-bit, the getInt32() method generates the exception "68 - Invalid ResBuf".

64-bit Integer Value

To get the 64-bit integer value, use the getInt64() method which does not have arguments and returns an instance of the OdInt64 type. For example:


OdInt64 num64 = pRb->getInt64();
odPrintConsoleString(L"\nValue = %ld (%lx)", num64, num64);

To set the 64-bit integer value, use the setInt64() method which requires an instance of the OdInt64 type as an argument and does not return a value. For example:


pRb->setRestype(OdResBuf::kDxfInt64);
pRb->setInt64((OdInt64) 9073012068045000);

Note: If the stored data type has capacity less than 64-bit, the getInt64() method casts it to the 64-bit integer value.

Double Value

To get the double-precision floating-point value, use the getDouble() method which does not have arguments and returns a double value. For example:


double value = pRb->getDouble();
odPrintConsoleString(L"\nValue = %g", value);

To set the double-precision floating-point value, use the setDouble() method which requires a double value as an argument and does not return a value. For example:


pRb->setRestype(OdResBuf::kDxfReal);
pRb->setDouble(3.47615E12);

Note: The passed data value must correspond to the specified data type, otherwise the exception "68 - Invalid ResBuf" occurs.

Boolean Value

To get the Boolean value, use the getBool() method which does not have arguments and returns True or False. For example:


odPrintConsoleString(L"\nValue = %s", ((pRb->getBool()) ? L"true" : L"false"));

To set the Boolean value, use the setBool() method which requires True or False as an argument and does not return a value. For example:


pRb->setBool(true);

Note: If the stored data type is a 16-bit integer value, the getBool() method casts it to True when the value is not zero or False when the value is zero.

See Also

Working with Tagged Data

Determining the Data Type by Group Code

Example of Entering and Displaying Tagged Data

Copyright © 2002 – 2021. Open Design Alliance. All rights reserved.