static int yield_typecompstrname(hal_object_ptr o, foreach_args_t *args) { size_t len; switch(args->user_arg1) { case T_USER: if(o.comp->type == TYPE_USER) { len = strlen(args->user_ptr1); if(strncmp(args->user_ptr1, hh_get_name(&o.comp->hdr), len) == 0 ) { args->result = strdup(hh_get_name(&o.comp->hdr)); return 1; } } break; case T_INST: if (is_instantiable(o.comp)) { len = strlen(args->user_ptr1); if(strncmp(args->user_ptr1, hh_get_name(&o.comp->hdr), len) == 0 ) { args->result = strdup(hh_get_name(&o.comp->hdr)); return 1; } } break; case T_RT: if(o.comp->type == TYPE_RT) { len = strlen(args->user_ptr1); if(strncmp(args->user_ptr1, hh_get_name(&o.comp->hdr), len) == 0 ) { args->result = strdup(hh_get_name(&o.comp->hdr)); return 1; } } break; default: // out of range error return -1; } return 0; }
void instantiator::validate(const field_definition& fd) const { const auto sn(fd.name().simple()); if (fd.name().simple().empty()) { BOOST_LOG_SEV(lg, error) << empty_simple_name; BOOST_THROW_EXCEPTION(instantiation_error(empty_simple_name)); } if (!is_instantiable(fd)) { BOOST_LOG_SEV(lg, error) << field_not_instantiable << sn; BOOST_THROW_EXCEPTION(instantiation_error(field_not_instantiable + sn)); } if (!fd.name().qualified().empty()) { BOOST_LOG_SEV(lg, error) << qualified_name_not_empty << sn; BOOST_THROW_EXCEPTION( instantiation_error(qualified_name_not_empty + sn)); } if (fd.definition_type() == field_definition_types::global_template) { if (!fd.ownership_hierarchy().facet_name().empty()) { BOOST_LOG_SEV(lg, error) << facet_name_not_empty << sn; BOOST_THROW_EXCEPTION( instantiation_error(facet_name_not_empty + sn)); } if (!fd.ownership_hierarchy().formatter_name().empty()) { BOOST_LOG_SEV(lg, error) << formatter_name_not_empty << sn; BOOST_THROW_EXCEPTION( instantiation_error(formatter_name_not_empty + sn)); } if (!fd.ownership_hierarchy().formatter_group_name().empty()) { BOOST_LOG_SEV(lg, error) << formatter_group_not_empty << sn; BOOST_THROW_EXCEPTION( instantiation_error(formatter_group_not_empty + sn)); } } if (fd.definition_type() == field_definition_types::facet_template) { if (!fd.ownership_hierarchy().facet_name().empty()) { BOOST_LOG_SEV(lg, error) << facet_name_not_empty << sn; BOOST_THROW_EXCEPTION( instantiation_error(facet_name_not_empty + sn)); } if (!fd.ownership_hierarchy().formatter_group_name().empty()) { BOOST_LOG_SEV(lg, error) << formatter_group_not_empty << sn; BOOST_THROW_EXCEPTION( instantiation_error(formatter_group_not_empty + sn)); } if (!fd.ownership_hierarchy().formatter_name().empty()) { BOOST_LOG_SEV(lg, error) << formatter_name_not_empty << sn; BOOST_THROW_EXCEPTION( instantiation_error(formatter_name_not_empty + sn)); } } if (fd.definition_type() == field_definition_types::formatter_template) { if (!fd.ownership_hierarchy().formatter_name().empty()) { BOOST_LOG_SEV(lg, error) << formatter_name_not_empty << sn; BOOST_THROW_EXCEPTION( instantiation_error(formatter_name_not_empty + sn)); } } }