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


C++ std::type_info类代码示例

本文整理汇总了C++中std::type_info的典型用法代码示例。如果您正苦于以下问题:C++ type_info类的具体用法?C++ type_info怎么用?C++ type_info使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了type_info类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: demangle

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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: RegisterSingleton

void Adaptor::RegisterSingleton(const std::type_info& info, BaseHandle singleton)
{
  if(singleton)
  {
    mSingletonContainer.insert(SingletonPair(info.name(), singleton));
  }
}
开发者ID:Tarnyko,项目名称:dali-adaptor,代码行数:7,代码来源:adaptor-impl.cpp

示例7: Register

bool TypeRegistry::Register( const std::string& uniqueTypeName, const std::type_info& baseTypeInfo,
                             Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit )
{
  bool ret = false;

  std::string baseTypeName    = DemangleClassName(baseTypeInfo.name());

  RegistryMap::iterator iter = mRegistryLut.find(uniqueTypeName);

  if( iter == mRegistryLut.end() )
  {
    mRegistryLut[uniqueTypeName] = Dali::TypeInfo(new Internal::TypeInfo(uniqueTypeName, baseTypeName, createInstance));
    ret = true;
    DALI_LOG_INFO( gLogFilter, Debug::Concise, "Type Registration %s(%s)\n", uniqueTypeName.c_str(), baseTypeName.c_str());
  }
  else
  {
    DALI_LOG_WARNING("Duplicate name for TypeRegistry for '%s'\n", + uniqueTypeName.c_str());
    DALI_ASSERT_ALWAYS(!"Duplicate type name for Type Registation");
  }

  if( callCreateOnInit )
  {
    mInitFunctions.push_back(createInstance);
  }

  return ret;
}
开发者ID:mettalla,项目名称:dali,代码行数:28,代码来源:type-registry-impl.cpp

示例8: tmp

		void connection::connection_specific_reset(std::type_info const &type, connection_specific_data *ptr)
		{
			std::auto_ptr<connection_specific_data> tmp(ptr);
			if(ptr && typeid(*ptr)!=type) {
				throw cppdb_error(
					std::string("cppdb::connection_specific::Inconsistent pointer type")
					+ typeid(*ptr).name() 
					+ " and std::type_info reference:"
					+ type.name()
				);
			}
			for(data::conn_specific_type::iterator p=d->conn_specific.begin();p!=d->conn_specific.end();++p) {
				if(typeid(**p) == type) {
					delete *p;
					if(ptr)
						*p = tmp.release();
					else
						d->conn_specific.erase(p);
					return;
				}
			}
			if(ptr) {
				d->conn_specific.push_back(0);
				d->conn_specific.back() = tmp.release();
			}
		}
开发者ID:guangzhuwu,项目名称:p2streaming,代码行数:26,代码来源:backend.cpp

示例9: name_of

  std::string
  name_of(const std::type_info &ti)
  {
    const static std::string typename_notavailable = "N/A";

    const char* mangled = ti.name();

    if (!mangled)
    {
      return typename_notavailable;
    }

    int status;

    char* demangled = abi::__cxa_demangle(mangled, 0, 0, &status);

    std::string rv;

    if (status != 0)
      rv = mangled;
    else
      rv = demangled ? demangled : typename_notavailable;

    std::free(demangled);
    return rv;
  }
开发者ID:eitanme,项目名称:object_recognition,代码行数:26,代码来源:utils.cpp

示例10: demangle

std::string demangle(const std::type_info& id) {
    int status;
    char* unmangled = abi::__cxa_demangle(id.name(), 0, 0, &status);
    std::string realname = unmangled;
    free(unmangled);
    return realname;
}
开发者ID:DominikMS,项目名称:sol,代码行数:7,代码来源:demangle.hpp

示例11: isTypeRegistered

 bool Registry::isTypeRegistered(const std::type_info &ti)
 {
     ReadLock lock(mReadWriteMutex); 
     RCF_UNUSED_VARIABLE(lock);
     Rtti typeRtti = ti.name();
     return mRttiToTypename.find(typeRtti) != mRttiToTypename.end();
 }
开发者ID:Jack-Tsue,项目名称:OnlineWhiteBoard,代码行数:7,代码来源:Registry.cpp

示例12: 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

示例13: Register

void SingletonService::Register( const std::type_info& info, BaseHandle singleton )
{
  if( singleton )
  {
    mSingletonContainer.insert( SingletonPair( info.name(), singleton ) );
  }
}
开发者ID:mettalla,项目名称:dali,代码行数:7,代码来源:toolkit-singleton-service.cpp

示例14: register_interface

 unsigned register_interface(const std::type_info& info)
   {
     std::string key = info.name();
     unsigned data = ++m_max_key;
     m_interfaces[key] = data;
     return data;
   }
开发者ID:evpo,项目名称:EncryptPad,代码行数:7,代码来源:persistent_contexts.cpp

示例15: register_callback

 unsigned register_callback(const std::type_info& info, dump_context::dump_callback callback)
   {
     std::string key = info.name();
     unsigned data = ++m_max_key;
     m_callbacks[key] = std::make_pair(data,callback);
     return data;
   }
开发者ID:evpo,项目名称:EncryptPad,代码行数:7,代码来源:persistent_contexts.cpp


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