当前位置: 首页>>代码示例>>C++>>正文


C++ type_info::name方法代码示例

本文整理汇总了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;
  }
开发者ID:aclodic,项目名称:dynamic-graph,代码行数:28,代码来源:signal-caster.cpp

示例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;
}
开发者ID:conanhung,项目名称:sofa_rc1,代码行数:29,代码来源:BaseClass.cpp

示例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);
}
开发者ID:VixMobile,项目名称:qcad,代码行数:10,代码来源:RPropertyTypeId.cpp

示例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());
  }
}
开发者ID:Maplestorys,项目名称:essentia,代码行数:9,代码来源:essentia.cpp

示例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
    }
开发者ID:BackupTheBerlios,项目名称:utgs-svn,代码行数:9,代码来源:ErrorMessage.cpp

示例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;
}
开发者ID:andrealani,项目名称:coolfluid3,代码行数:10,代码来源:TypeInfo.cpp

示例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());
}
开发者ID:vvolkl,项目名称:DD4hep,代码行数:10,代码来源:Plugins.cpp

示例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> ();
}
开发者ID:fallenwind,项目名称:qcad,代码行数:20,代码来源:RPropertyTypeId.cpp

示例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;
	}
开发者ID:Indicator,项目名称:raptorx-zy,代码行数:12,代码来源:embeddable.C

示例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;
}
开发者ID:DoctorEmmettBrown,项目名称:spring,代码行数:13,代码来源:DefinitionTag.cpp

示例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;
     }
 }
开发者ID:mkotsbak,项目名称:librcf-cpp,代码行数:13,代码来源:Stream.cpp

示例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
}
开发者ID:podusowski,项目名称:CakeDi,代码行数:13,代码来源:Log.hpp

示例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);
}
开发者ID:kirichoi,项目名称:roadrunner,代码行数:50,代码来源:Variant.cpp

示例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;
     }
 }
开发者ID:MorelM35,项目名称:ESIR_MorKaneGame,代码行数:14,代码来源:Stream.cpp

示例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()));
}
开发者ID:facebook,项目名称:fbthrift,代码行数:7,代码来源:JSONProtocolCommon.cpp


注:本文中的std::type_info::name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。