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.
Return 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.
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 memory leak v->destroy(&allocator);
index
to value
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 incorrectlylen
from the array body to the buffer dst
. (Note that this method can be used only for arrays of scalar types)
len
from the buffer src
to the array body (Note that this method can be used only for arrays of scalar types)
size
bytes are copied (Note that if the terminating null does not fit in size bytes, the resulting buffer will NOT be null-terminated)allocator