Value :: read - Read data from MEMO or BLOB field
The function returns a binary data block with partial or complete data. The function is typically used for reading BLOB properties, which contain binary data.
Usually, BLOB values may be accessed simply by calling get() or tryGet(). While the content of a MEMO field may be retrieved by calling toString(), converting BLOB content into a string will result in hexadecimal representation (base 16) of the BLOB content. Using read(), however, returns the content in a Binary data block, which allows further processing of binary data.
One more reason to use read() is, that read allows providing partial data for BLOB properties. BLOB fields do not have a predefined maximum size, i.e. a BLOB property may grow up to 2 GB.
// read first block of data
rlen = 10000; // will automatically be reduced when being to large
data = read(0,rlen); // length cannot be passed as constant!
// read all property data
rlen = 10000;
property().get(0);
while ( rlen ) {
data = read(-1,rlen);
// do something with data
}
MEMO fields are called all types of text references, i.e. STRING, UTF8, ASCII etc. properties defined as references.
Constant reference to a binary data block handle, which may contain binary data up to 2 GB.
Implementation overview
- Read all data into Binary data block
Value :: read (  ) - Read data partially
Value :: read ( iPosition, iLength )
Implementation details
-
Read all data into Binary data block
odaba::Binary Value  :: read (  )
The function reads all data stored for a BLOB property into the binary data block. The length of data read may be obtained by calling Binary::length() with the Binary object instance returned by the function.
... StoreImage ( Property &image, String file_name ) {
Binary bin_data;
bin_data = image.read();
if ( bin_data.length() > 0 )
bin_data.storeFile(file_name);
}
to list
-
Read data partially
odaba::Binary Value  :: read ( int32 iPosition, int32 iLength )
The function allows reading part of the data stored for a BLOB property. The position passed in iPosition is the starting point for reading property data. The value must not exceed the maximum size of the currently selected instance. In order to use the current position (position after last read or write), -1 might be passed in iPosition.
The iLength value contains the maximum number of bytes to be read. When the size value is to large, it will be auto-corrected to the property size and finally set to the number of bytes really read. When the end of the instance has been reached, an empty binary data block will be returned.
- iPosition
- Position in collection
The position of an element in a collection is beginning with 0 for the first element.
- iLength
- Length
The length is the size allocated for an instance or area.
to list
- iPosition
- Position in collection