ponder 3.2
C++ reflection library
ponder::ArrayProperty Class Referenceabstract

Specialized type of property for arrays. More...

#include <arrayproperty.hpp>

+ Inheritance diagram for ponder::ArrayProperty:

Public Member Functions

 ArrayProperty (IdRef name, ValueKind elementType, bool dynamic)
 Construct the property from its description. More...
 
virtual ~ArrayProperty ()
 Destructor.
 
ValueKind elementType () const
 Get the type of the array elements. More...
 
bool dynamic () const
 Check if the array is dynamic. More...
 
size_t size (const UserObject &object) const
 Get the current size of the array. More...
 
void resize (const UserObject &object, size_t newSize) const
 Resize the array. More...
 
Value get (const UserObject &object, size_t index) const
 Get an element of the array for a given object. More...
 
void set (const UserObject &object, size_t index, const Value &value) const
 Set an element of the array for a given object. More...
 
void insert (const UserObject &object, size_t before, const Value &value) const
 Insert a new element into the array. More...
 
void remove (const UserObject &object, size_t index) const
 Remove an element from the array. More...
 
void accept (ClassVisitor &visitor) const override
 Accept the visitation of a ClassVisitor. More...
 
- Public Member Functions inherited from ponder::Property
virtual ~Property ()
 Destructor.
 
IdReturn name () const
 Get the name of the property. More...
 
ValueKind kind () const
 Get the type of the property. More...
 
virtual bool isReadable () const
 Check if the property can be read. More...
 
virtual bool isWritable () const
 Check if the property can be written. More...
 
Value get (const UserObject &object) const
 Get the current value of the property for a given object. More...
 
void set (const UserObject &object, const Value &value) const
 Set the current value of the property for a given object. More...
 

Detailed Description

Specialized type of property for arrays.

Constructor & Destructor Documentation

◆ ArrayProperty()

ponder::ArrayProperty::ArrayProperty ( IdRef  name,
ValueKind  elementType,
bool  dynamic 
)

Construct the property from its description.

Parameters
nameName of the property
elementTypeType of the property
dynamicTells if the array is dynamic or not

Member Function Documentation

◆ accept()

void ponder::ArrayProperty::accept ( ClassVisitor visitor) const
overridevirtual

Accept the visitation of a ClassVisitor.

Parameters
visitorVisitor to accept

Reimplemented from ponder::Property.

◆ dynamic()

bool ponder::ArrayProperty::dynamic ( ) const

Check if the array is dynamic.

If the array is not dynamic, the insert and remove functions are disabled.

Returns
True if the array is dynamic, false otherwise

◆ elementType()

ValueKind ponder::ArrayProperty::elementType ( ) const

Get the type of the array elements.

Returns
Type of elements

◆ get()

Value ponder::ArrayProperty::get ( const UserObject object,
size_t  index 
) const

Get an element of the array for a given object.

Parameters
objectObject
indexIndex of the element to get
Returns
Value of the index-th element
Exceptions
NullObjectobject is invalid
ForbiddenReadproperty is not readable
OutOfRangeindex is out of range

◆ insert()

void ponder::ArrayProperty::insert ( const UserObject object,
size_t  before,
const Value value 
) const

Insert a new element into the array.

This function will throw an error if the array is not dynamic

Parameters
objectObject
beforeIndex before which the new element will be inserted
valueValue of the element to insert
Exceptions
NullObjectobject is invalid
ForbiddenWritearray is not writable or not dynamic
BadTypevalue can't be converted to the property's type
OutOfRangeindex is out of range

◆ remove()

void ponder::ArrayProperty::remove ( const UserObject object,
size_t  index 
) const

Remove an element from the array.

This function will throw an error if the array is not dynamic

Parameters
objectObject
indexIndex of the element to remove
Exceptions
NullObjectobject is invalid
ForbiddenWritearray is not writable or not dynamic
OutOfRangeindex is out of range

◆ resize()

void ponder::ArrayProperty::resize ( const UserObject object,
size_t  newSize 
) const

Resize the array.

If size is lesser than the current size of the array, the last elements will be removed; if size is greater than the current size of the array, default-constructed elements will be added at the end.

This function will throw an error if the array is not dynamic

Parameters
objectObject
newSizeNew size of the array
Exceptions
InvalidObjectobject has an invalid value
InvalidAccessarray is not writable or not dynamic
InvalidIndexindex is out of range

◆ set()

void ponder::ArrayProperty::set ( const UserObject object,
size_t  index,
const Value value 
) const

Set an element of the array for a given object.

Parameters
objectObject
indexIndex of the element to get
valueNew value to assign to the element
Exceptions
NullObjectobject is invalid
ForbiddenWriteproperty is not writable
BadTypevalue can't be converted to the property's type
OutOfRangeindex is out of range

◆ size()

size_t ponder::ArrayProperty::size ( const UserObject object) const

Get the current size of the array.

Parameters
objectObject
Returns
Number of elements in the array
Exceptions
NullObjectobject is invalid
ForbiddenReadproperty is not readable

The documentation for this class was generated from the following file: