Gorgon Game Engine
MappedStringEnum< E_ > Class Template Reference

E_ is an enumeration with defined strings. More...

Inheritance diagram for MappedStringEnum< E_ >:
[legend]

Public Member Functions

 MappedStringEnum (const std::string &name, const std::string &help, const std::vector< std::pair< std::string, std::string >> &strings, E_ defval=E_(), bool binary=false)
 strings parameter should contain, name and help of enum entries. More...
 
 MappedStringEnum (const std::string &name, const std::string &help, E_ defval=E_(), bool binary=false)
 This constructor adds all elements without any help. More...
 
virtual void Assign (Data &l, const Data &r) const override
 Assigns the value of the second parameter to the first, reference types can ignore this function. More...
 
virtual Data Parse (const std::string &s) const
 Parses a string into this data. This function is allowed to throw. More...
 
virtual std::string ToString (const Data &d) const
 Converts a data of this type to string. More...
 
- Public Member Functions inherited from EnumType
 EnumType (const std::string &name, const std::string &help, const std::vector< ElementInitializer > &elements, TMP::RTTH *typeinterface)
 
virtual Data Get () const override final
 Returns the value of this static member. More...
 
virtual MemberType GetMemberType () const override
 Returns the type of this member. More...
 
- Public Member Functions inherited from Type
 Type (const std::string &name, const std::string &help, const Any &defaultvalue, TMP::RTTH *typeinterface, bool isref)
 
virtual ~Type ()
 Destructor. More...
 
void AddConstructor (Function::Overload &element)
 Adds the given constructor. More...
 
void AddConstructors (std::initializer_list< Function::Overload * > elements)
 Adds the given constructors. More...
 
void AddInheritance (const Type &type, Inheritance::ConversionFunction from, Inheritance::ConversionFunction to)
 Adds an inheritance parent. More...
 
virtual void AddMember (InstanceMember &member)
 Adds a list of instance members to this type. More...
 
virtual void AddMember (InstanceMember *member)
 Adds a list of instance members to this type. More...
 
virtual void AddMember (StaticMember &member) override
 Adds a static member to this type. More...
 
virtual void AddMember (StaticMember *member) override
 Adds a static member to this type. More...
 
virtual void AddMembers (std::initializer_list< InstanceMember * > newmembers)
 Adds an instance member to this type. More...
 
virtual void AddMembers (std::initializer_list< StaticMember * > newmembers) override
 Adds a list of static members to this type. More...
 
virtual void AddMembers (std::vector< InstanceMember * > newmembers)
 Adds an instance member to this type. More...
 
virtual void AddMembers (std::vector< StaticMember * > newmembers) override
 Adds a list of static members to this type. More...
 
MorphType CanMorphTo (const Type &type) const
 Check if it is possible to morph this type to the other. More...
 
bool Compare (const Data &l, const Data &r) const
 This function compares two instances of this type. Both left and right should of this type. More...
 
Data Construct (const std::vector< Data > &parameters) const
 !Unsafe. Constructs a new object from the given parameters. Requires parameters to be the exact type. More...
 
void Delete (const Data &obj) const
 Deletes the object. More...
 
Any GetDefaultValue () const
 Returns the value of the type. More...
 
const Function::OverloadGetTypeCastingFrom (const Type *other, bool implicit=true) const
 This function returns type casting function from a given type to this one. More...
 
bool IsReferenceType () const
 Returns whether this type is a reference type. More...
 
Data MorphTo (const Type &type, Data source, bool allowtypecast=true) const
 Morphs the given data into the target type. More...
 
 operator const Type * () const
 Converts this type to its pointer. More...
 
bool operator!= (const Type &other) const
 Compares two types. More...
 
bool operator!= (const Type *other) const
 
bool operator== (const Type &other) const
 Compares two types. More...
 
bool operator== (const Type *other) const
 
- Public Member Functions inherited from Namespace
 Namespace (const std::string &name, const std::string &help)
 
const Scripting::FunctionGetFunction (const std::string &name) const
 Convenience function, returns the function with the given name. More...
 
const NamespaceGetNamespace (const std::string &name) const
 Convenience function, returns the namespace with the given name. More...
 
const TypeGetType (const std::string &name) const
 Convenience function, returns the type with the given name. More...
 
Data ValueOf (const std::string &name) const
 Convenience function, returns the value of the symbol with the given name. More...
 
- Public Member Functions inherited from StaticMember
 StaticMember (const std::string &name, const std::string &help)
 
bool IsInstanceable () const
 Whether this member can be used to instantiate an object. More...
 
virtual bool IsInstanceMember () const override final
 Returns if this member is an instance member. More...
 
- Public Member Functions inherited from Member
 Member (const std::string &name, const std::string &help)
 
virtual ~Member ()
 
std::string GetHelp () const
 Returns the help string. Help strings may contain markdown notation. More...
 
std::string GetName () const
 Returns the name of this member. More...
 
const MemberGetOwner () const
 
std::string GetQualifiedName () const
 Returns the namespace qualified name of this member. More...
 

Protected Member Functions

virtual bool compare (const Data &l, const Data &r) const
 This function should compare two instances of the type. More...
 
virtual void deleteobject (const Data &obj) const override
 This function should delete the given object. More...
 
- Protected Member Functions inherited from EnumType
 EnumType (const std::string &name, const std::string &help, Any defval, TMP::RTTH *typeinterface)
 
void add (const ElementInitializer &element)
 
- Protected Member Functions inherited from Member
virtual void SetParent (const Member &parent)
 Changes the parent of the member. More...
 

Additional Inherited Members

- Public Types inherited from Type
enum  MorphType {
  NotPossible, AlreadMatching, UpCasting, DownCasting,
  TypeCasting
}
 There are multiple ways to morph a type to another, this enumeration holds these types. More...
 
- Public Types inherited from StaticMember
enum  MemberType {
  RegularType, EventType, EnumType, Namespace,
  DataMember, Function, Constant
}
 Possible member types. More...
 
- Public Attributes inherited from EnumType
const std::vector< const Scripting::Constant * > & Ordered
 Ordered list of allowed values. More...
 
- Public Attributes inherited from Type
const Scripting::FunctionConstructor
 Constructors of this type. More...
 
const Containers::Hashmap< std::string, const Type, nullptr, std::map, String::CaseInsensitiveLess > & InheritedSymbols
 Inherited symbols. More...
 
const std::map< const Type *, Inheritance > & InheritsFrom
 Inheritance list. More...
 
const InstanceMemberListInstanceMembers
 
const std::map< const Type *, const Type * > & Parents
 Parents of this type. This includes indirect parents as well. More...
 
TMP::RTTHTypeInterface
 Type interface used for this type. More...
 
- Public Attributes inherited from Namespace
const StaticMemberListMembers
 List of static members. More...
 
- Protected Attributes inherited from Type
Scripting::Function constructor
 Constructors of this type. More...
 
Any defaultvalue
 Default value of this type. More...
 
Containers::Hashmap< std::string, const Type, nullptr, std::map, String::CaseInsensitiveLessinheritedsymbols
 Inherited symbols. More...
 
std::map< const Type *, Inheritanceinheritsfrom
 Inheritance list. More...
 
InstanceMemberList instancemembers
 Instance members of this type. More...
 
std::map< const Type *, const Type * > parents
 This lists all parents of this type in the entire hierarchy. More...
 
bool referencetype
 Whether this type is a reference type. More...
 
- Protected Attributes inherited from Namespace
StaticMemberList members
 
- Protected Attributes inherited from Member
std::string help
 Help string of the datamember. More...
 
std::string name
 The name of the datamember. More...
 
const Memberparent
 

Detailed Description

template<class E_>
class Gorgon::Scripting::MappedStringEnum< E_ >

E_ is an enumeration with defined strings.

Constructor & Destructor Documentation

◆ MappedStringEnum() [1/2]

MappedStringEnum ( const std::string &  name,
const std::string &  help,
const std::vector< std::pair< std::string, std::string >> &  strings,
E_  defval = E_(),
bool  binary = false 
)

strings parameter should contain, name and help of enum entries.

Names could be any of the alternative names listed in the enum strings

References Type::AddConstructors(), Type::AddMember(), Type::AddMembers(), Gorgon::Scripting::ConstTag, Gorgon::Scripting::Types::Function(), MAP_COMPARE, and Gorgon::Scripting::MapFunction().

◆ MappedStringEnum() [2/2]

MappedStringEnum ( const std::string &  name,
const std::string &  help,
E_  defval = E_(),
bool  binary = false 
)

This constructor adds all elements without any help.

Consider using the constructor that enables help text for enum items.

Member Function Documentation

◆ Assign()

virtual void Assign ( Data l,
const Data r 
) const
overridevirtual

Assigns the value of the second parameter to the first, reference types can ignore this function.

Implements Type.

References Member::GetName(), Data::GetType(), Data::GetValue(), Data::IsConstant(), Data::IsReference(), and Data::ReferenceValue().

◆ compare()

virtual bool compare ( const Data l,
const Data r 
) const
protectedvirtual

This function should compare two instances of the type.

Not required for reference types as pointers will be compared

Reimplemented from Type.

References Data::GetValue().

◆ deleteobject()

virtual void deleteobject ( const Data ) const
overrideprotectedvirtual

This function should delete the given object.

Implements Type.

References ASSERT, Data::IsConstant(), Data::IsReference(), and Data::ReferenceValue().

◆ Parse()

virtual Data Parse ( const std::string &  ) const
virtual

Parses a string into this data. This function is allowed to throw.

Implements Type.

◆ ToString()

virtual std::string ToString ( const Data ) const
virtual

Converts a data of this type to string.

This function should never throw, if there is no data to display, recommended this play is either [ EMPTY ], or Typename #id

Implements Type.

References Gorgon::String::From(), and Data::GetValue().


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