HxmClass Class¶
-
class HxmClass¶
Each instance of an HxmClass represents a class available and loaded in a module. Each HXM object has a type represented by an HxmClass whether it comes from a builtin or a user defined class. Therefore, it is possible to retrieve the class of any value that is not a boolean, integer, double or nil.
The functions below can be used to introspect the contents of all HXM classes and, in particular, to extract the various functions, properties and fields of the class, including static fields. It is also possible to build new instances of this class using the
newInstance()
function.Since an HxmClass is a value, each HxmClass also has a type represented by another HxmClass that describes the fundamental type of all other types.
- Since:
13.0
Summary¶
Returns a new instance of this class. |
|
Returns a new instance of this class. |
|
Returns a new instance of this class. |
|
Returns a new instance of this class. |
|
Gets the full name of the class including the name of the module in which the class has been declared (e. |
|
Returns true if the class has been declared as final. |
|
Returns true if this class is a subclass of the class given as parameter. |
|
Returns true if the value passed in parameter is an instance of this class. |
|
Returns true if this class extends another class. |
|
Returns the class extended by this class. |
|
Returns the number of members present in this class. |
|
Returns the name of the member with the given id. |
|
Returns the type of the member with the given id. |
|
Returns the type of the member with the given name. |
|
Returns the id of the member with the given name or -1 if no such member exists in the class. |
|
Returns true if a member with the given name is present in the class. |
|
Returns true if a function with the given name is present in the class or inherited from a parent class. |
|
Returns true if the member with the given id is a function. |
|
Returns true if a field with the given name is present in the class or inherited from a parent class. |
|
Returns true if the member with the given id is a field. |
|
Returns true if a property with the given name is present in the class or inherited from a parent class. |
|
Returns true if the member with the given id is a property. |
|
Returns the function with the given id as an HxmFunction. |
|
Returns the function with the given name as an HxmFunction. |
|
Returns the field with the given id as an HxmField. |
|
Returns the field with the given name as an HxmField. |
|
Returns the property with the given id as an HxmProperty. |
|
Returns the property with the given name as an HxmProperty. |
|
Returns the number of static members declared in the class. |
|
Returns the name of the static member with the given id. |
|
Returns the id of the static member with the given name or -1 if no such member exists in the class. |
|
Returns true if a static member with the given name is declared in the class. |
|
Returns the value of the static member with the given id. |
|
Returns the value of the static member with the given name. |
|
Sets the value of the static member with the given id. |
|
Sets the value of the static member with the given id. |
|
Returns the class as an HxmValue. |
Returns the class as an HxmValue. |
Functions¶
-
HxmValue HxmClass::newInstance()¶
Returns a new instance of this class. The constructor is called with no arguments.
- Returns:
A new instance object of this class.
- See:
-
HxmValue HxmClass::newInstance(const std::vector<HxmValue> &arguments)¶
Returns a new instance of this class. The constructor is called with the arguments passed as parameters.
- Parameters:
arguments – List of arguments for the constructor.
- Returns:
A new instance object of this class.
- See:
-
HxmValue HxmClass::newInstance(const HxmValue *arguments, int nbArguments)¶
Returns a new instance of this class. The constructor is called with the arguments passed as parameters.
- Parameters:
arguments – Pointer to the first argument.
nbArguments – Number of arguments.
- Returns:
A new instance object of this class.
- See:
-
template<typename T>
HxmValue HxmClass::newInstance(T begin, T end)¶ Returns a new instance of this class. The constructor is called with the arguments passed as parameters. The arguments must be iterators referencing HxmValues.
- Parameters:
T – Type of an iterator referencing HxmValues.
begin – Iterator to the beginning of the arguments.
end – Iterator to the end of the arguments.
- Returns:
A new instance object of this class.
- See:
-
std::string HxmClass::getDeclaredName() const¶
Gets the full name of the class including the name of the module in which the class has been declared (e.g.
module_name.ClassName
).- Returns:
Name of the class.
-
bool HxmClass::isFinal() const¶
Returns true if the class has been declared as final. A final class is a class that cannot be extended by inheritance.
- Returns:
True if the class is final.
-
bool HxmClass::isSubClassOf(const HxmClass &other) const¶
Returns true if this class is a subclass of the class given as parameter. To be considered a subclass, this class must inherit directly or indirectly from the class given as parameter.
- Parameters:
other – Other class from which the inheritance will be tested.
- Returns:
True if this class is a subclass of the class the given as parameter.
-
bool HxmClass::isInstance(const HxmValue &value) const¶
Returns true if the value passed in parameter is an instance of this class. An object is considered to be an instance of the class if the object’s type is equal to this class, or if the object’s type is a subclass of this class. If the value passed in parameter is not an object (such as a boolean, integer, double or nil), then false is always returned.
- Parameters:
value – Value for which the inheritance will be tested.
- Returns:
True if the given value is an instance of this class.
-
bool HxmClass::hasSuperClass() const¶
Returns true if this class extends another class. The extended class can be retrieved with the function
getSuperClass()
.- Returns:
True if this class extends another class.
-
HxmClass HxmClass::getSuperClass() const¶
Returns the class extended by this class. An exception is thrown if this class does not have a super class.
- Returns:
The class extended by this class.
-
int HxmClass::getNbMembers() const¶
Returns the number of members present in this class. The members considered are those declared in this class or inherited from parent classes. A member is a field, property, function or constructor. The returned number can be used to browse members using the following functions, which take a
memberId
parameter ranging from 0 togetNbMembers()
.- Returns:
Number of members declared in the class or in the parent classes.
-
string HxmClass::getMemberName(int memberId) const¶
Returns the name of the member with the given id. An exception is thrown if
memberId
is less than 0 or greater than the number of members returned by the functiongetNbMembers()
.- Parameters:
memberId – Id of the member to get the name.
- Returns:
Name of the member with the given id.
-
HxmMemberType HxmClass::getMemberType(int memberId) const¶
Returns the type of the member with the given id. An exception is thrown if
memberId
is less than 0 or greater than the number of members returned by the functiongetNbMembers()
.- Parameters:
memberId – Id of the member to get the type.
- Returns:
Type of the member with the given id.
- See:
-
HxmMemberType HxmClass::getMemberType(const std::string &memberName) const¶
Returns the type of the member with the given name. An exception is thrown if no member with the given name is present in the class. The member name is case sensitive.
- Parameters:
memberName – Name of the member to get the type.
- Returns:
Type of the member with the given name.
- See:
-
int HxmClass::FindMemberId(const std::string &memberName) const¶
Returns the id of the member with the given name or -1 if no such member exists in the class. The considered members are those declared in this class or inherited from parent classes. The member name is case sensitive.
- Parameters:
memberName – Name of the member to get the id.
- Returns:
The id of the member with the given name.
-
bool HxmClass::isMember(const std::string &memberName) const¶
Returns true if a member with the given name is present in the class. The considered members are those declared in this class or inherited from parent classes. The member name is case sensitive. This function is equivalent to
findMemberId(memberName) != -1
.- Parameters:
memberName – Name of the member to check.
- Returns:
True if a member with the given name is present in the class.
-
bool HxmClass::isMethod(const std::string &memberName) const¶
Returns true if a function with the given name is present in the class or inherited from a parent class. Returns false if no function with the given name is present or if the member is not a function. The member name is case sensitive.
- Parameters:
memberName – Name of the function to check.
- Returns:
True if a function with the given name is present in the class.
-
bool HxmClass::isMethod(int memberId) const¶
Returns true if the member with the given id is a function. False is returned otherwise or an exception is thrown if
memberId
is less than 0 or greater than the number of members returned by the functiongetNbMembers()
.- Parameters:
memberId – Id of the function to check.
- Returns:
True if the member with the given id is a function.
-
bool HxmClass::isField(const std::string &memberName) const¶
Returns true if a field with the given name is present in the class or inherited from a parent class. Returns false if no field with the given name is present or if the member is not a field. The member name is case sensitive.
- Parameters:
memberName – Name of the field to check.
- Returns:
True if a field with the given name is present in the class.
-
bool HxmClass::isField(int memberId) const¶
Returns true if the member with the given id is a field. False is returned otherwise or an exception is thrown if
memberId
is less than 0 or greater than the number of members returned by the functiongetNbMembers()
.- Parameters:
memberId – Id of the field to check.
- Returns:
True if the member with the given id is a field.
-
bool HxmClass::isProperty(const std::string &memberName) const¶
Returns true if a property with the given name is present in the class or inherited from a parent class. Returns false if no property with the given name is present or if the member is not a property. The member name is case sensitive.
- Parameters:
memberName – Name of the property to check.
- Returns:
True if a property with the given name is present in the class.
-
bool HxmClass::isProperty(int memberId) const¶
Returns true if the member with the given id is a property. False is returned otherwise or an exception is thrown if memberId is less than 0 or greater than the number of members returned by the function
getNbMembers()
.- Parameters:
memberId – Id of the property to check.
- Returns:
True if the member with the given id is a property.
-
HxmFunction HxmClass::getMethod(int memberId) const¶
Returns the function with the given id as an
HxmFunction
. An exception is thrown if the member is not a function or ifmemberId
is less than 0 or greater than the number of members returned by the functiongetNbMembers()
.Once the function has been retrieved as a
HxmFunction
, you can call it withHxmFunction::callThis()
by passing an object of this class as the first argument.- Parameters:
memberId – Id of the function to get.
- Returns:
The function with the given id.
- See:
-
HxmFunction HxmClass::getMethod(const std::string &memberName) const¶
Returns the function with the given name as an
HxmFunction
. An exception is thrown if the member is not a function or if no member with the given name is present in the class. The member name is case sensitive.Once the function has been retrieved as a
HxmFunction
, you can call it withHxmFunction::callThis()
by passing an object of this class as the first argument.- Parameters:
memberName – Name of the function to get.
- Returns:
The function with the given name.
- See:
-
HxmField HxmClass::getField(int memberId) const¶
Returns the field with the given id as an
HxmField
. An exception is thrown if the member is not a field or ifmemberId
is less than 0 or greater than the number of members returned by the functiongetNbMembers()
.Once the field has been retrieved as a
HxmField
, you can retrieve or modify the value of the field for any object of this class using the various get and set functions likeHxmField::getValue()
.- Parameters:
memberId – Id of the member to get.
- Returns:
The field with the given id.
- See:
-
HxmField HxmClass::getField(const std::string &memberName) const¶
Returns the field with the given name as an
HxmField
. An exception is thrown if the member is not a field or if no member with the given name is present in the class. The member name is case sensitive.Once the field has been retrieved as a
HxmField
, you can retrieve or modify the value of the field for any object of this class using the various get and set functions likeHxmField::getValue()
.- Parameters:
memberName – Name of the field to get.
- Returns:
The field with the given name.
- See:
-
HxmProperty HxmClass::getProperty(int memberId) const¶
Returns the property with the given id as an
HxmProperty
. An exception is thrown if the member is not a property or ifmemberId
is less than 0 or greater than the number of members returned by the functiongetNbMembers()
.Once the property has been retrieved as a
HxmProperty
, you can retrieve or modify the value of the property for any object of this class using the various get and set functions likeHxmProperty::getValue()
.- Parameters:
memberId – Id of the member to get.
- Returns:
The property with the given id.
- See:
-
HxmProperty HxmClass::getProperty(const std::string &memberName) const¶
Returns the property with the given name as an
HxmProperty
. An exception is thrown if the member is not a property or if no member with the given name is present in the class. The member name is case sensitive.Once the property has been retrieved as a
HxmProperty
, you can retrieve or modify the value of the property for any object of this class using the various get and set functions likeHxmProperty::getValue()
.- Parameters:
memberName – Name of the property to get.
- Returns:
The property with the given name.
- See:
-
int HxmClass::getNbStaticMembers() const¶
Returns the number of static members declared in the class. Only the static members declared specfically in this class actually count. There is no inheritance for static members and therefore parent classes are ignored. The returned number can be used to browse static members using the following functions, which take a
staticMemberId
parameter ranging from 0 togetNbStaticMembers()
.- Returns:
Number of static members declared in this class
- Rtype:
int
-
std::string HxmClass::getStaticMemberName(int staticMemberId) const¶
Returns the name of the static member with the given id. An exception is thrown if
staticMemberId
is less than 0 or greater than the number of static members returned by the functiongetNbStaticMembers()
.- Parameters:
staticMemberId – Id of the static member to get.
- Returns:
Name of the member with the given id.
-
int HxmClass::findStaticMemberId(const std::string &staticMemberName) const¶
Returns the id of the static member with the given name or -1 if no such member exists in the class. Only the static members declared specfically in this class are actually considered for the search. The static member name is case sensitive.
- Parameters:
staticMemberName – Name of the static member to get the id.
- Returns:
The id of the static member with the given name.
-
bool HxmClass::isStaticMember(const std::string &staticMemberName) const¶
Returns true if a static member with the given name is declared in the class. The considered static members are only those specifically declared in the current class. There is no inheritance for static members, therefore parent classes are ignored in the search. The static member name is case sensitive.
- Parameters:
staticMemberName – Name of the static member to check.
- Returns:
True if a static member with the given name is declared in the class.
-
HxmValue HxmClass::getStaticMember(int staticMemberId) const¶
Returns the value of the static member with the given id. An exception is thrown if
staticMemberId
is less than 0 or greater than the number of static members returned by the functiongetNbStaticMembers()
.- Parameters:
staticMemberId – Id of the static member to get.
- Returns:
Value of the static member with the given id.
- See:
-
HxmValue HxmClass::getStaticMember(const std::string &staticMemberName) const¶
Returns the value of the static member with the given name. An exception is thrown if no static member with the given name is present in the class. The static member name is case sensitive;
- Parameters:
staticMemberName – Name of the static member to get.
- Returns:
Value of the static member with the given name.
- See:
-
void HxmClass::setStaticMember(int staticMemberId, const HxmValue &value)¶
Sets the value of the static member with the given id. An exception is thrown if
staticMemberId
is less than 0 or greater than the number of static members returned by the functiongetNbStaticMembers()
.- Parameters:
staticMemberId – Id of the static member to set.
value – Value of the static member to set.
-
void HxmClass::setStaticMember(const std::string &staticMemberName, HxmValue value)¶
Sets the value of the static member with the given id. An exception is thrown if no static member with the given name is present in the class. The static member name is case sensitive.
- Parameters:
staticMemberName – Name of the static member to set.
value – Value of the static member to set.