The Array class is provided for handling arrays of Values.
Note that Array inherits from List, which implements methods common to Arrays and Strings.
The Array methods are listed below.
McoSql::ValueRef getAt(size_t index)
Returns a reference to the Value object at index.
Note that, if the application gets a reference to an object, and this object is deallocated
(perhaps along with its parent array), the reference becomes invalid. In this case
the user should obtain a copy of the object using getCopyAt() (see below)
instead of the reference.
McoSql::Value *getCopyAt(size_t index)
Returns a copy of the object at index. Note that the difference between
getAt() and getCopyAt() is that getAt() returns a
reference (ValueRef) to the element in the array, while getCopyAt()
returns a copy of the element. When using getCopyAt(), the application is
responsible for explicitly freeing (deallocating) the copy. For example:
// Get a copy of the object at index 0
McoSql::Value *v = array->getCopyAt(0);
// Use the object...
// Explicitly destroy the copy to avoid a memory leak
v->destroy(&allocator);
void setAt(size_t index, McoSql::Value* value)
index to value.Value *updateAt(int index)
Gets the structure or array element with the specified index for update; returns the Value of the element with the specified index whose components or elements will be updated.
size_t size();
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)
Copies the specified number of elements len from the array body to the buffer
dst. (Note that this method can be used only for arrays of scalar types.)
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. (Note that this method can be used only for arrays of scalar types.)
size_t getElemSize(void)
McoSql::Type getElemType()
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)
allocator.Array * makeNullable()
Returns the underlying value array as a NullableArray.