xo-reflect: + TypeDescr::lookup_by_name()
This commit is contained in:
parent
8a20796fe9
commit
6fc1fff9dc
2 changed files with 15 additions and 0 deletions
|
|
@ -190,6 +190,8 @@ namespace xo {
|
|||
std::unique_ptr<TypeDescrExtra> tdextra);
|
||||
|
||||
/* print table of reflected types to os */
|
||||
/** lookup type by canonical name **/
|
||||
static TypeDescr lookup_by_name(const std::string & canonical_name);
|
||||
static void print_reflected_types(std::ostream & os);
|
||||
|
||||
TypeId id() const { return id_; }
|
||||
|
|
|
|||
|
|
@ -146,6 +146,19 @@ namespace xo {
|
|||
return new_slot.get();
|
||||
} /*require*/
|
||||
|
||||
TypeDescr
|
||||
TypeDescrBase::lookup_by_name(const std::string & name) {
|
||||
auto ix = s_canonical_type_table_map.find(name);
|
||||
|
||||
if (ix == s_canonical_type_table_map.end()) {
|
||||
throw std::runtime_error(tostr("TypeDescrBase::lookup_by_name"
|
||||
": no registered type with canonical name T",
|
||||
xtag("T", name)));
|
||||
}
|
||||
|
||||
return ix->second;
|
||||
} /*lookup_by_name*/
|
||||
|
||||
void
|
||||
TypeDescrBase::print_reflected_types(std::ostream & os)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue