本文整理汇总了C++中type_info类的典型用法代码示例。如果您正苦于以下问题:C++ type_info类的具体用法?C++ type_info怎么用?C++ type_info使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了type_info类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ReleaseWaiter
void CSynchInvoker::ReleaseWaiter(const type_info& info, const string& id)
{
Key key(id, info.name());
CLock lock(m_synchronizer);
assert(m_key2Waiter.end() != m_key2Waiter.find(key));
m_key2Waiter.erase(key);
}
开发者ID:ifzz,项目名称:FDK,代码行数:7,代码来源:SynchInvoker.cpp
示例2: GetClassName
static string GetClassName(const type_info& info)
{
const char* name = info.name();
// __cxa_demangle requires an output buffer
// allocated with malloc(). Provide it.
size_t len = 1024;
char *buf = (char*)malloc(len);
assert(buf != 0);
int status = 0;
char *res = 0;
#ifdef HAVE_GCC_ABI_DEMANGLE
res = abi::__cxa_demangle(name, buf, &len, &status);
#endif
if (res && status == 0)
{
string ret = res;
free(res);
return ret;
}
else
{
if (res) free(res);
else free(buf);
return name;
}
}
开发者ID:koenk,项目名称:mgsim,代码行数:30,代码来源:MGSystem.cpp
示例3: getCacheFolder
// Generate a cache path. This must be different for different settings in order
// to prevent cache hits on different settings.
string CacheHelper::getCacheFolder(string filename,
const type_info& dataType) const {
string dataTypeName = dataType.name();
dataTypeName.erase(
boost::remove_if(dataTypeName, ::isdigit), dataTypeName.end());
string basePath = "cache/" + m_datasetPath +
"/" + dataTypeName;
if(dataType == typeid(DatasetManager)) {
return basePath + "/";
}
stringstream cacheNameStream;
cacheNameStream <<
"_" << m_settings->get<string>("image.type") <<
"_" << m_settings->get<float>("image.smoothingSigma") <<
"_" << m_settings->get<string>("features.type") <<
"_" << m_settings->get<vector<int> >("features.gridSpacing")[0] <<
"_" << m_settings->get<vector<int> >("features.patchSize")[0];
if(dataType == typeid(ImageFeatures)) {
return basePath + cacheNameStream.str() + "/";
}
cacheNameStream <<
"_" << m_settings->get<int>("codebook.textonImages") <<
"_" << m_settings->get<int>("codebook.codewords") <<
"_" << m_settings->get<string>("histogram.type") <<
"_" << m_settings->get<int>("histogram.pyramidLevels");
return basePath + cacheNameStream.str() + "/";
}
开发者ID:mdqyy,项目名称:DetectingNature,代码行数:36,代码来源:CacheHelper.cpp
示例4: typeid
void CException::x_ThrowSanityCheck(const type_info& expected_type,
const char* human_name) const
{
const type_info& actual_type = typeid(*this);
if (actual_type != expected_type) {
ERR_POST_X(14, Warning << "CException::Throw(): throwing object of type "
<< actual_type.name() << " as " << expected_type.name()
<< " [" << human_name << ']');
}
}
开发者ID:swuecho,项目名称:igblast,代码行数:10,代码来源:ncbiexpt.cpp
示例5: Response
void CSynchInvoker::Response(const type_info& info, const CFxEventInfo& eventInfo, void* pData)
{
Key key(eventInfo.ID, info.name());
CLock lock(m_synchronizer);
auto it = m_key2Waiter.find(key);
if (m_key2Waiter.end() != it)
{
IWaiter* pWaiter = it->second;
pWaiter->VResponse(eventInfo, pData);
}
}
开发者ID:ifzz,项目名称:FDK,代码行数:11,代码来源:SynchInvoker.cpp
示例6: demangle
const string demangle(const type_info &ti)
{
const size_t __mangle_buff_size = 1024;
int status;
size_t __mangle_buff_len = __mangle_buff_size;
char __mangle_buff[__mangle_buff_size];
/*
Назначение третьего (__length) и четвертого (__status) аргументов неясно: в случае очевидной ошибки нехватки памяти происходит крушение процесса (Segmentation fault или Bus error). Ситуация, при которой хотя бы один из аргументов был изменен не наблюдалась
*/
const char *mangled_name = abi::__cxa_demangle(ti.name(), __mangle_buff, &__mangle_buff_len, &status);
return (mangled_name ? mangled_name : "<not_demangled>");
}
开发者ID:dyomas,项目名称:pyhrol,代码行数:13,代码来源:demangling.cpp
示例7: name
string
TypeInfoHelper::getClassName( const type_info &info )
{
static const string classPrefix( "class " );
string name( info.name() );
bool has_class_prefix = 0 ==
#if CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST
name.compare( classPrefix, 0, classPrefix.length() );
#else
name.compare( 0, classPrefix.length(), classPrefix );
#endif
return has_class_prefix ? name.substr( classPrefix.length() ) : name;
}
开发者ID:looncraz,项目名称:haiku,代码行数:15,代码来源:TypeInfoHelper.cpp
示例8: GetTypeName
/**
* Returns a human-readable type name of a type_info object.
*
* @param ti A type_info object.
* @returns The type name of the object.
*/
String Utility::GetTypeName(const type_info& ti)
{
String klass = ti.name();
#ifdef HAVE_GCC_ABI_DEMANGLE
int status;
char *realname = abi::__cxa_demangle(klass.CStr(), 0, 0, &status);
if (realname != NULL) {
klass = String(realname);
free(realname);
}
#endif /* HAVE_GCC_ABI_DEMANGLE */
return klass;
}
开发者ID:h4ck3rm1k3,项目名称:strawberry,代码行数:22,代码来源:utility.cpp
示例9: get_type_name
std::string get_type_name(const type_info& info)
{
std::string type_name = info.name();
typedef std::string::size_type size_type;
//TODO: handle case of other than MSVC compilers
static const std::string msvc_typeid_prefix = "class ";
size_type pos = type_name.find(msvc_typeid_prefix);
if (std::string::npos != pos )
{
size_type start_pos = pos + msvc_typeid_prefix.size();
type_name = std::string(type_name, start_pos, type_name.size() - start_pos);
}
return type_name;
}
开发者ID:rgde,项目名称:rgdengine,代码行数:18,代码来源:Composite.cpp
示例10: ClassName
string
ClassName( const type_info& inTypeid )
{
string result = inTypeid.name();
#ifdef __GNUC__
int err = 0;
char* name = abi::__cxa_demangle( result.c_str(), 0, 0, &err );
if( name )
{
result = name;
::free( name );
}
#endif // __GNUC__
// To obtain a useful representation of the class name, we need to do some
// processing that removes white space and compiler specific additions.
// First, remove white space between template arguments and <> brackets.
static struct
{
const char* original,
* replacement;
} replacementTable[] =
{
{ ", ", "," },
{ "< ", "<" },
{ " >", ">" },
{ "class ", "" },
{ "struct ", "" },
{ "enum ", "" },
};
size_t pos;
for( size_t r = 0; r < sizeof( replacementTable ) / sizeof( *replacementTable ); ++r )
{
string original = replacementTable[r].original;
while( string::npos != ( pos = result.find( original ) ) )
result = result.replace( pos, original.length(), replacementTable[r].replacement );
}
return result;
}
开发者ID:griffinmilsap,项目名称:hitest,代码行数:41,代码来源:ClassName.cpp
示例11: insert
void insert(to_python_function_t f, type_info source_t, PyTypeObject const* (*to_python_target_type)())
{
# ifdef BOOST_PYTHON_TRACE_REGISTRY
std::cout << "inserting to_python " << source_t << "\n";
# endif
entry* slot = get(source_t);
assert(slot->m_to_python == 0); // we have a problem otherwise
if (slot->m_to_python != 0)
{
std::string msg = (
std::string("to-Python converter for ")
+ source_t.name()
+ " already registered; second conversion method ignored."
);
if ( ::PyErr_Warn( NULL, const_cast<char*>(msg.c_str()) ) )
{
throw_error_already_set();
}
}
slot->m_to_python = f;
slot->m_to_python_target_type = to_python_target_type;
}
开发者ID:bk5115545,项目名称:omegalib,代码行数:24,代码来源:registry.cpp
示例12: function_is_not_defined
void function_is_not_defined(const char* function,const char* file,unsigned int line,const type_info& type) {
const string error = format("%s:%s:%d: Function not defined by %s",file,function,line,type.name());
if (error_callback) {
error_callback(error);
#ifdef _WIN32
throw RuntimeError("error callback returned: "+error);
#endif
} else
throw RuntimeError(error);
}
开发者ID:Haider-BA,项目名称:geode,代码行数:10,代码来源:debug.cpp
示例13:
bool type_info::operator== (const type_info &rhs) const
{
return !before (rhs) && !rhs.before (*this);
}
开发者ID:Quna,项目名称:mspdev,代码行数:4,代码来源:typeinfo.cpp
示例14: throw
NotFoundException::NotFoundException(const type_info& cppType) throw()
{
msg = "Cannot find Type with id ";
msg += cppType.name();
}
开发者ID:gaurav1981,项目名称:eXtendedMirror,代码行数:5,代码来源:NotFoundException.cpp
示例15: return
RET type_info::operator != (const type_info& other) const
{
return (strcmp(name(), other.name()) != 0);
}
开发者ID:eladraz,项目名称:XDK,代码行数:4,代码来源:typeInfo.cpp
示例16:
bool type_info::operator == (type_info const& rhs) const
{
return this == &rhs || cpprtl::rtti::aux_::strzcmp(this->name(), rhs.name());
}
开发者ID:133a,项目名称:project_ntke_cpprtl,代码行数:4,代码来源:rtti_type_info.cpp
示例17: listen
void EventService::listen(const type_info& ti, const EventCallback& cb)
{
_listeners[ti.hash_code()].push_back(cb);
}
开发者ID:TinyMan,项目名称:warfare-of-heroes,代码行数:4,代码来源:EventService.cpp
示例18: warn_if_not_overridden
void warn_if_not_overridden(const char* function,const char* file,unsigned int line,const type_info& type) {
Log::cerr<<format("*** GEODE_WARNING: %s:%s:%d: Function not overridden by %s",file,function,line,type.name())<<endl;
}
开发者ID:Haider-BA,项目名称:geode,代码行数:3,代码来源:debug.cpp
示例19: before
int type_info::before(const type_info& other) const
{
return (strcmp(name(), other.name()) < 0);
}
开发者ID:eladraz,项目名称:XDK,代码行数:4,代码来源:typeInfo.cpp
示例20: TEST_BEGIN
#include <elm/enum_info.h>
using namespace elm;
typedef enum {
a,
b,
c
} my_enum;
namespace elm { template <> struct type_info<my_enum>: public enum_info<my_enum> { }; }
TEST_BEGIN(enum_info)
// enumeration test
type_info<my_enum>::iterator i = type_info<my_enum>::begin();
CHECK(i != type_info<my_enum>::end());
CHECK(i.name() == "a");
CHECK(i.value() == int(a));
i++;
CHECK(i != type_info<my_enum>::end());
CHECK(i.name() == "b");
CHECK(i.value() == int(b));
i++;
CHECK(i != type_info<my_enum>::end());
CHECK(i.name() == "c");
CHECK(i.value() == int(c));
i++;
CHECK(i == type_info<my_enum>::end());
// IO test
开发者ID:alexjordan,项目名称:otawa,代码行数:31,代码来源:test_enum_info.cpp
注:本文中的type_info类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论