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); }
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; } }
// 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() + "/"; }
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 << ']'); } }
//Проверка совпадения типов bool CheckClassesType( const type_info& type1, const type_info& type2 ) { if( type1 != type2 ) { Log(HW) << "warning: request type " << type2.name() << " but native typename is " << type1.name() << term; return false; } return true; }
void CObject::ThrowNullPointerException(const type_info& type) { if ( sx_abort_on_null ) { Abort(); } NCBI_EXCEPTION_VAR(ex, CCoreException, eNullPtr, string("Attempt to access NULL pointer: ")+type.name()); ex.SetSeverity(eDiag_Critical); NCBI_EXCEPTION_THROW(ex); }
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); } }
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>"); }
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; }
/** * 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; }
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; }
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; }
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; }
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); }
bool type_info::operator== (const type_info &rhs) const { return !before (rhs) && !rhs.before (*this); }
NotFoundException::NotFoundException(const type_info& cppType) throw() { msg = "Cannot find Type with id "; msg += cppType.name(); }
RET type_info::operator != (const type_info& other) const { return (strcmp(name(), other.name()) != 0); }
bool type_info::operator == (type_info const& rhs) const { return this == &rhs || cpprtl::rtti::aux_::strzcmp(this->name(), rhs.name()); }
void EventService::listen(const type_info& ti, const EventCallback& cb) { _listeners[ti.hash_code()].push_back(cb); }
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; }
int type_info::before(const type_info& other) const { return (strcmp(name(), other.name()) < 0); }
#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
int SimDynamicDataPlugin::registerData(const char *lpszName, const type_info &infType, void *lpvOffset, int iRows, int iCols) { int iSize, iRelativeOffset; char szDup[BUFSIZ]; strcpy(szDup, lpszName); char *lpszUpper = strupr(szDup); assert(pDataCurrent); // Make sure this data field does not exist in the current data block if (pDataCurrent->findElem(lpszUpper) == pDataCurrent->elements.end()) { char szTmp[BUFSIZ]; Persistent::AbstractClass::convertClassName(infType.name(), szTmp); int type = getType(strupr(szTmp)); switch (BASETYPE(type)) { case DATATYPE_CHAR : iSize = type & DATAQUALIFIER_PTR ? sizeof(int) : sizeof(char); break; case DATATYPE_BOOL : iSize = sizeof(bool); break; case DATATYPE_SHORT : iSize = sizeof(short); break; case DATATYPE_INT : iSize = sizeof(int); break; case DATATYPE_LONG : iSize = sizeof(long); break; case DATATYPE_FLOAT : iSize = sizeof(float); break; case DATATYPE_DOUBLE : iSize = sizeof(double); break; case DATATYPE_TSMATERIALPROP : iSize = sizeof(TS::DefaultMaterialProps::MaterialProps); break; default : return DATAERROR_INVALIDTYPE; } // Get the relative offset position (offset of item within structure // minus offset of beginning of structure) iRelativeOffset = (char *)lpvOffset - (char *)pDataCurrent->lpvBase; // Add the new data element to our list of elements pDataCurrent->addElem(strupr(szDup), iRelativeOffset, type, iSize, iRows, iCols); return (DATAERROR_NOERROR); } return (DATAERROR_NOTFOUND); }
void did_not_raise(const type_info& error, const char* message) { throw AssertionError(message?message:format("Expected %s, but function completed normally",error.name())); }