From f54d00ce601bb1a0b8a9eb8c6d2e44b55dc03313 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Sat, 6 May 2017 00:48:23 +0200 Subject: [PATCH] Base::Type extension to get Type by key --- src/Base/Type.cpp | 8 ++++++++ src/Base/Type.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/Base/Type.cpp b/src/Base/Type.cpp index 7c9848712a..789cb1481d 100644 --- a/src/Base/Type.cpp +++ b/src/Base/Type.cpp @@ -184,6 +184,14 @@ Type Type::fromName(const char *name) return Type::badType(); } +Type Type::fromKey(unsigned int key) +{ + if(key < typedata.size()) + return typedata[key]->type; + else + return Type::badType(); +} + const char *Type::getName(void) const { return typedata[index]->name.c_str(); diff --git a/src/Base/Type.h b/src/Base/Type.h index 50bc86cf68..38ecf12281 100644 --- a/src/Base/Type.h +++ b/src/Base/Type.h @@ -92,6 +92,7 @@ public: typedef void * (*instantiationMethod)(void); static Type fromName(const char *name); + static Type fromKey(unsigned int key); const char *getName(void) const; const Type getParent(void) const; bool isDerivedFrom(const Type type) const;