The C++ NullableArray Class

NullableArray overrides the Array methods allowing for null values in the array.

For an overview see page C++ Classes

NullableArray overrides all public methods of base class Array using the nullBitmap to determine which array elements have null values. The nullBitmap is an array of unsigned 64 bit integers whose set bits indicate elements having null values.

NullableArray(Array* payload, ScalarArray<uint64_t>* bitmap = NULL) Constructor taking an array argument payload and optional null bitmap
McoSql::ValueRef getAt( size_t index )

Return the reference to the Value object at index returned by Array method getAt(), or McoSql::Null if the corresponding bit in the nullBitmap is set

McoSql::Value *getCopyAt( size_t index )

Get a copy of the Value object at index returned by Array method getCopyAt(), or McoSql::Null if the corresponding bit in the nullBitmap is set. Note that, when using getCopyAt(), the application is responsible for explicitly freeing (deallocating) the copy.

void setAt( size_t index, McoSql::Value* value) Set the array element at position index to value and clear the corresponding bit in the nullBitmap or, if value is null, set the corresponding bit in the nullBitmap
Value * updateAt( int index ) This method throws an "Invalid Operation" exception; to change the value of an array element use method setAt()
size_t size() Return the number of elements in the allocated array
void setSize(size_t newSize); Set the number of elements in the array to operate on. Note that the specified size must not exceed the size of the allocated array (returned by method size()) and it is necessary to later restore it to the original value (by calling again method setSize()) after the desired operation is completed; otherwise deallocation will be performed incorrectly
void getBody( void * dst, size_t offs, size_t len ) Return the specified number of elements len from the array body to the buffer dst returned by Array method getBody()
void setBody( void * src, size_t offs, size_t len ) Set the specified number of elements len from the buffer src to the array body and, for null elements, set the corresponding bit in the nullBitmap
size_t getElemSize( void ) Return the size in bytes of an array element
McoSql::Type getElemType() Return the type of the type of the array elements
size_t toString( char * buf , size_t & size ) Serialize the current Value to the specified buffer. Only size bytes are copied (Note that if the terminating null does not fit in size bytes, the resulting buffer will NOT be null-terminated)
Value * clone( McoSql::Allocator* allocator ) Create a copy of the array using the specified memory allocator
Array * getNullBitmap() Return the mullBitmap