Tagged data can store (8, 16, 32, 64)-bit integer, double, or Boolean values:
In the following examples, the pRb variable stores a pointer to the resbuf-object.
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".
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".
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".
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.
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.
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.
Copyright © 2002 – 2022. Open Design Alliance. All rights reserved.
|