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)
Constructs an array with an array argument payload and an optional null bitmap.
McoSql::ValueRef getAt(size_t index)

Returns 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)

Gets 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)
Sets the array element at position index to value and clears the corresponding bit in the nullBitmap or, if value is null, sets the corresponding bit in the nullBitmap.
Value *updateAt(int index)
Throws an "Invalid Operation" exception; to change the value of an array element, use method setAt().
size_t size()
Returns the number of elements in the allocated array.
void setSize(size_t newSize);
Sets 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 method setSize() again) after the desired operation is completed; otherwise deallocation will be performed incorrectly.
void getBody(void * dst, size_t offs, size_t len)
Returns 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)
Sets the specified number of elements len from the buffer src to the array body and, for null elements, sets the corresponding bit in the nullBitmap.
size_t getElemSize(void)
Returns the size in bytes of an array element.
McoSql::Type getElemType()
Returns the type of the array elements.
size_t toString(char * buf, size_t & size)
Serializes 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)
Creates a copy of the array using the specified memory allocator.
Array * getNullBitmap()
Returns the nullBitmap.