siplasplas
A library for C++ reflection and introspection
cpp::dynamic_reflection::Enum Class Reference

Stores dynamic reflection information of an enumeration type. More...

#include <siplasplas/reflection/dynamic/enum.hpp>

Inheritance diagram for cpp::dynamic_reflection::Enum:
cpp::dynamic_reflection::Entity

Public Member Functions

std::size_t count () const
 Returns the number of constants in the enumeration.
 
const std::string & name (std::size_t i) const
 Returns the name of the i-th enumeration constant. More...
 
const std::vector< std::string > & names () const
 Returns the set of enum constants names.
 
std::int64_t value (std::size_t i) const
 Returns the value of the i-th enumeration constant. More...
 
const std::vector< std::int64_t > & values () const
 Returns the set of enum constants values.
 
bool isUnsigned () const
 Checks whether the underlying enumeration type is an unsigned integral type. More...
 
std::int64_t fromString (const std::string &name) const
 Returns the enumeration value of the constant with the given name. More...
 
const std::string & toString (std::int64_t value) const
 Returns The name of the enumeration constant with the given value. More...
 
- Public Member Functions inherited from cpp::dynamic_reflection::Entity
Entityparent ()
 Returns a reference to the parent entity The behavior is undefined if the entity has no parent entity (See orphan())
 
Runtimeruntime ()
 Returns a reference to the runtime where the entity is registered. More...
 
const SourceInfo & sourceInfo () const
 Returns source information about the entity.
 
const std::string & name () const
 Returns the name of the entity.
 
const std::string & fullName () const
 Returns the full qualifies name of the entity.
 
const SourceInfo::Kindkind () const
 Returns the kind (Namespace, class, enum, member function, etc) of the entity.
 
bool detached () const
 Checks whether the entity is not registered (attached) into a dynamic reflection runtime. More...
 
bool orphan () const
 Checks if the entity has no parent entity. More...
 
void attach (Runtime &runtime)
 Attaches the entity to a given runtime. More...
 
void attach (const std::weak_ptr< Entity > &parent)
 Attaches the entity to the runtime of a given entity and links that enity as parent. More...
 
void addChild (const std::shared_ptr< Entity > &entity)
 Links the given entity as child of the entity. More...
 
bool isChild (const std::shared_ptr< Entity > &entity) const
 Checks if the given entity is a child entity of this entity. More...
 
bool isChild (const Entity &entity) const
 Checks if the given entity is a child entity of this entity. More...
 
bool isChildByName (const std::string &name) const
 Checks if the entity has a child entity with the given name. More...
 
bool isChildByFullName (const std::string &fullName) const
 Checks if the entity has a child entity with the given name. More...
 
EntitygetChildByFullName (const std::string &fullName)
 Returns a child entity given its full name. More...
 
EntitygetChildByName (const std::string &name)
 Returns a child entity given its name. More...
 
std::vector< std::string > getChildrenNamesByKind (const SourceInfo::Kind &kind)
 Returns the names of the child entities with a given kind. More...
 
std::shared_ptr< Entitypointer ()
 Returns the shared pointer holding the entity object.
 

Static Public Member Functions

static std::shared_ptr< Enumcreate (const SourceInfo &sourceInfo, const cpp::typeerasure::TypeInfo &type, const cpp::typeerasure::TypeInfo &underlyingType, const std::vector< std::string > &constantsNames, const std::vector< std::int64_t > &constantsValues)
 Instantiates an enumeration entity given its source information, its type information, and the enumeration constants. More...
 
static EnumfromEntity (const std::shared_ptr< Entity > &entity)
 Returns a reference to an enumeration entity from a pointer to an entity. More...
 

Additional Inherited Members

- Protected Member Functions inherited from cpp::dynamic_reflection::Entity
 Entity (const SourceInfo &sourceInfo)
 

Detailed Description

Stores dynamic reflection information of an enumeration type.

Examples:
examples/reflection/dynamic/plugin.cpp.

Member Function Documentation

static std::shared_ptr<Enum> cpp::dynamic_reflection::Enum::create ( const SourceInfo &  sourceInfo,
const cpp::typeerasure::TypeInfo type,
const cpp::typeerasure::TypeInfo underlyingType,
const std::vector< std::string > &  constantsNames,
const std::vector< std::int64_t > &  constantsValues 
)
static

Instantiates an enumeration entity given its source information, its type information, and the enumeration constants.

Parameters
sourceInfoEnumeration source information
typeEnumeration type information
underlyingTypeEnumeration underlying type type information
constantsNamesEnumeration constants names
Enumerationconstants values
Returns
A shared pointer holding the enumeration entity. The returned entity is detached (See cpp::dynamic_reflection::Runtime::addEntity())
static Enum& cpp::dynamic_reflection::Enum::fromEntity ( const std::shared_ptr< Entity > &  entity)
static

Returns a reference to an enumeration entity from a pointer to an entity.

This function performs an entity cast from a generic entity pointer to a enumeration entity. The behavior is undefined if the entity is not an enumeration (See Entity::kind())

Parameters
entityA shared pointer to an entity
Returns
A reference to a enumeration entity
std::int64_t cpp::dynamic_reflection::Enum::fromString ( const std::string &  name) const

Returns the enumeration value of the constant with the given name.

Parameters
nameEnumeration constant name. The behavior is undefined if the enum has no constant with the given name
bool cpp::dynamic_reflection::Enum::isUnsigned ( ) const

Checks whether the underlying enumeration type is an unsigned integral type.

Returns
True if the enumeration constants values are unsigned integers, false otherwise
const std::string& cpp::dynamic_reflection::Enum::name ( std::size_t  i) const

Returns the name of the i-th enumeration constant.

Parameters
iIndex of the requested enumeration constant. Constants are indexed from top/left from bottom/right, starting at zero. The behavior is undefined if i >= count()
Examples:
examples/reflection/dynamic/plugin.cpp.
const std::string& cpp::dynamic_reflection::Enum::toString ( std::int64_t  value) const

Returns The name of the enumeration constant with the given value.

Parameters
valueEnumeration constant value. The behavior is undefined if the enum has no constant with that value. If there are multiple constants with that value, the first is returned
std::int64_t cpp::dynamic_reflection::Enum::value ( std::size_t  i) const

Returns the value of the i-th enumeration constant.

Enumeration values are converted to signed 64 bit integers to be stored in the Enum object. Users can check the original underlying type with underlyingTypeInfo(), and check if the original values were unsigned with isUnsigned().

Parameters
iIndex of the requested enumeration constant. Constants are indexed from top/left from bottom/right, starting at zero. The behavior is undefined if i >= count()
Examples:
examples/reflection/dynamic/plugin.cpp.

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