本文整理汇总了C++中std::type_info::name方法的典型用法代码示例。如果您正苦于以下问题:C++ type_info::name方法的具体用法?C++ type_info::name怎么用?C++ type_info::name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::type_info
的用法示例。
在下文中一共展示了type_info::name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: typeName
void
SignalCaster::registerCast (const std::type_info& type,
SignalCaster::displayer_type displayer,
SignalCaster::caster_type caster,
SignalCaster::tracer_type tracer)
{
if (existsCast (type))
{
// If type name has already been registered for same type, do not throw.
if (type_info_[type.name()] != &type)
{
std::string typeName(type.name());
std::ostringstream os;
os << "cast already registered for typename " << typeName << "\n"
<< "and types differ: " << &type << " != "
<< type_info_[type.name()]
<< ".\n"
<< "A possible reason is that the dynamic"
<< " library defining this type\n"
<< "has been loaded several times, defining different symbols"
<< " for the same type.";
throw ExceptionSignal(ExceptionSignal::GENERIC,
os.str());
}
}
functions_[type.name()] = cast_functions_type(displayer,caster, tracer);
type_info_[type.name()] = &type;
}
示例2: decodeFullName
/// Helper method to BaseClass::decode the type name
std::string BaseClass::decodeFullName(const std::type_info& t)
{
std::string name;
#ifdef __GNUC__
int status;
/* size_t length; */ // although it should, length would not be filled in by the following call
char* allocname = abi::__cxa_demangle(t.name(), 0, /*&length*/0, &status);
if(allocname == 0)
{
std::cerr << "Unable to demangle symbol: " << t.name() << std::endl;
}
else
{
int length = 0;
while(allocname[length] != '\0')
{
length++;
}
name.resize(length);
for(int i=0; i<(int)length; i++)
name[i] = allocname[i];
free(allocname);
}
#else
name = t.name();
#endif
return name;
}
示例3: hasPropertyType
/**
* \retval true: if the given class has the given property
*/
bool RPropertyTypeId::hasPropertyType(const std::type_info& classInfo,
RPropertyTypeId propertyTypeId) {
if (!propertyTypeByObjectMap.contains(classInfo.name())) {
return false;
}
return propertyTypeByObjectMap[classInfo.name()].contains(propertyTypeId);
}
示例4: nameOfType
// declared in src/base/types.h
string nameOfType(const std::type_info& type) {
try {
return TypeMap::instance()[type.name()];
}
catch (EssentiaException&) {
return demangle(type.name());
}
}
示例5: IsEnabled
bool
IsEnabled( const std::type_info &tp, int id )
{
# ifdef NDEBUG // _table enables reports (Release)
return ( _table.find( tp.name() ) != _table.end() );
# else // _table disables reports (Debug)
return ( _table.find( tp.name() ) == _table.end() );
# endif
}
示例6: class_name_from_typeinfo
std::string class_name_from_typeinfo (const std::type_info & info)
{
TypeInfo& ti = TypeInfo::instance();
std::map<std::string, std::string>::const_iterator it =
ti.portable_types.find(info.name());
cf_assert_desc(Common::demangle(info.name()).c_str(), it != ti.portable_types.end() );
return it->second;
}
示例7: addFactory
void PluginService::addFactory(const std::string& id, stub_t stub,
const std::type_info& signature_type,
const std::type_info& return_type)
{
if ( PluginService::debug() ) {
printout(INFO,"PluginService","+++ Declared factory[%s] with signature %s type:%s.",
id.c_str(),signature_type.name(),return_type.name());
}
PluginInterface::instance().add(id.c_str(),stub,signature_type.name(),return_type.name());
}
示例8: qWarning
/**
* Gets all property type IDs that where registered for the given
* class.
*
* \param classInfo The class info, e.g. typeid(ObjectA)
*
* \return a set of property type ID pointers or an empty set if
* the class has no registered property types.
*/
QSet<RPropertyTypeId> RPropertyTypeId::getPropertyTypeIds(
const std::type_info& classInfo) {
if (propertyTypeByObjectMap.contains(classInfo.name())) {
return propertyTypeByObjectMap[classInfo.name()];
}
qWarning() << QString("RPropertyIdRegistry::getPropertyTypeIds: "
"no properties registered for class %1")
.arg(classInfo.name());
return QSet<RPropertyTypeId> ();
}
示例9: countInstances_
Size Embeddable::countInstances_(const std::type_info& type)
throw()
{
// check whether we got a vector with that name
if (instance_vectors_.has(type.name()))
{
// retrieve the size of the coresponding instance vector
return (Size)instance_vectors_[type.name()].size();
}
return 0;
}
示例10: GetTypeName
std::string DefTagMetaData::GetTypeName(const std::type_info& typeInfo)
{
// demangle typename
#ifndef _MSC_VER
int status;
char* ctname = abi::__cxa_demangle(typeInfo.name(), 0, 0, &status);
const std::string tname = ctname;
free(ctname);
#else
const std::string tname(typeInfo.name()); // FIXME?
#endif
return tname;
}
示例11: query
bool ContextRead::query(void *ptr, const std::type_info &objType, void *&pObj)
{
if (type_ptr_obj_ptr_.get() &&
(*type_ptr_obj_ptr_)[ objType.name() ].find(ptr) != (*type_ptr_obj_ptr_)[ objType.name() ].end() )
{
pObj = (*type_ptr_obj_ptr_)[ objType.name() ][ ptr ];
return true;
}
else
{
return false;
}
}
示例12: result
inline std::string demangle(const std::type_info & type)
{
#ifdef __GNUG__
int status;
char * realname = abi::__cxa_demangle(type.name(), 0, 0, &status);
std::string result(realname);
free(realname);
return result;
#else
return std::string("<") + type.name() + std::string(">");
#endif
}
示例13: convert_to
void Variant::convert_to(const std::type_info& info, void* p) const
{
try
{
TRY_CONVERT_TO(std::string);
TRY_CONVERT_TO(long);
TRY_CONVERT_TO(bool);
TRY_CONVERT_TO(float);
TRY_CONVERT_TO(double);
TRY_CONVERT_TO(unsigned long);
TRY_CONVERT_TO(int);
TRY_CONVERT_TO(unsigned int);
TRY_CONVERT_TO(char);
TRY_CONVERT_TO(unsigned char);
TRY_CONVERT_TO(int32_t);
TRY_CONVERT_TO(uint32_t);
}
catch(Poco::SyntaxException& ex)
{
string msg = "Could not convert variant with typeid ";
msg += self->var.type().name();
msg += " to type";
msg += info.name();
msg += "error: ";
msg += ex.what();
msg += ", string value: " + self->var.toString();
throw std::logic_error(msg);
}
string msg = "Could not convert variant with typeid ";
msg += self->var.type().name();
msg += " to type";
msg += info.name();
throw invalid_argument(msg);
}
示例14: query
bool ContextRead::query(void *ptr, const std::type_info &objType, void *&pObj)
{
RCF_ASSERT(mEnabled);
if (mTypeToObjMap.get() &&
(*mTypeToObjMap)[ objType.name() ].find(ptr) != (*mTypeToObjMap)[ objType.name() ].end() )
{
pObj = (*mTypeToObjMap)[ objType.name() ][ ptr ];
return true;
}
else
{
return false;
}
}
示例15: TProtocolException
[[noreturn]] void JSONProtocolReaderCommon::throwUnrecognizableAsIntegral(
folly::StringPiece s,
std::type_info const& type) {
throw TProtocolException(
TProtocolException::INVALID_DATA,
folly::to<std::string>(s, " is not a valid ", type.name()));
}