Example #1
0
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
}
Example #2
0
 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;
     }
 }
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;
}
Example #4
0
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);
}
Example #5
0
 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;
     }
 }
Example #6
0
void Adaptor::RegisterSingleton(const std::type_info& info, BaseHandle singleton)
{
  if(singleton)
  {
    mSingletonContainer.insert(SingletonPair(info.name(), singleton));
  }
}
Example #7
0
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;
}
Example #8
0
bool TypeRegistry::Register( const std::type_info& theTypeInfo, const std::type_info& baseTypeInfo,
                             Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit )
{
  std::string uniqueTypeName  = DemangleClassName(theTypeInfo.name());

  return Register( uniqueTypeName, baseTypeInfo, createInstance, callCreateOnInit );
}
Example #9
0
		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();
			}
		}
Example #10
0
  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;
  }
Example #11
0
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;
}
Example #12
0
 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();
 }
Example #13
0
[[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()));
}
void SingletonService::Register( const std::type_info& info, BaseHandle singleton )
{
  if( singleton )
  {
    mSingletonContainer.insert( SingletonPair( info.name(), singleton ) );
  }
}
Example #15
0
 unsigned register_interface(const std::type_info& info)
   {
     std::string key = info.name();
     unsigned data = ++m_max_key;
     m_interfaces[key] = data;
     return data;
   }
Example #16
0
 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;
   }
Example #17
0
/// Decode the template name (removing namespaces and class name)
std::string Base::decodeTemplateName(const std::type_info& t)
{
    std::string name = t.name();
    const char* realname = NULL;
    char* allocname = strdup(name.c_str());
#ifdef __GNUC__
    int status;
    realname = allocname = abi::__cxa_demangle(allocname, 0, 0, &status);
    if (realname==NULL)
#endif
        realname = allocname;
    int len = strlen(realname);
    char* newname = (char*)malloc(len+1);
    newname[0] = '\0';
    int start = 0;
    int dest = 0;
    int i = 0;
    char cprev = '\0';
    //std::cout << "name = "<<realname<<std::endl;
    while (i < len && realname[i]!='<')
        ++i;
    start = i+1; ++i;
    for (; i<len; i++)
    {
        char c = realname[i];
        //if (c == '<') break;
        if (c == ':') // && cprev == ':')
        {
            start = i+1;
        }
        else if (c == ' ' && i >= 5 && realname[i-5] == 'c' && realname[i-4] == 'l' && realname[i-3] == 'a' && realname[i-2] == 's' && realname[i-1] == 's')
        {
            start = i+1;
        }
        else if (c != ':' && c != '_' && (c < 'a' || c > 'z') && (c < 'A' || c > 'Z'))
        {
            // write result
            while (start <= i)
            {
                newname[dest++] = realname[start++];
                newname[dest] = 0;
            }
        }
        cprev = c;
        //std::cout << "i = "<<i<<" start = "<<start<<" dest = "<<dest<<" newname = "<<newname<<std::endl;
    }
    while (start < i)
    {
        newname[dest++] = realname[start++];
        newname[dest] = 0;
    }
    newname[dest] = '\0';
    //std::cout << "newname = "<<newname<<std::endl;
    name = newname;
    free(newname);
    //if (allocname)
    //    free(allocname);
    return name;
}
Example #18
0
 dump_context::callback_data lookup_callback(const std::type_info& info) const
   {
     std::string key = info.name();
     callback_map::const_iterator found = m_callbacks.find(key);
     if (found == m_callbacks.end())
       throw persistent_illegal_type(key);
     return found->second;
   }
Example #19
0
 void
 SignalCaster::unregisterCast (const std::type_info& type)
 {
   size_t n = functions_.erase(type.name ());
   if (0 == n) // erase did not find element
     // TODO: throw Cast not registered exception
     throw ExceptionSignal(ExceptionSignal::GENERIC);
 }
Example #20
0
 unsigned lookup_interface(const std::type_info& info) const
   {
     std::string key = info.name();
     interface_map::const_iterator found = m_interfaces.find(key);
     if (found == m_interfaces.end())
       throw persistent_illegal_type(key);
     return found->second;
   }
Example #21
0
void ContextRead::add(void *ptr, const std::type_info &objType, void *pObj)
{
    RCF_ASSERT(bEnabled_);
    if (type_ptr_obj_ptr_.get() == NULL)
    {
        type_ptr_obj_ptr_.reset( new std::map<std::string, std::map< void *, void * > >() );
    }
    (*type_ptr_obj_ptr_)[ objType.name() ][ ptr ] = pObj;
}
Example #22
0
    bool table::is_column(const std::string& column_name,
                          const std::type_info& type) const
    {
        assert(has_column(column_name));

        const auto& c = m_columns.at(column_name);
        assert(c->type_hash());
        return (*c->type_hash()) == type.hash_code();
    }
Example #23
0
 void ContextRead::add(void *ptr, const std::type_info &objType, void *pObj)
 {
     RCF_ASSERT(mEnabled);
     if (mTypeToObjMap.get() == NULL)
     {
         mTypeToObjMap.reset( new std::map<std::string, std::map< void *, void * > >() );
     }
     (*mTypeToObjMap)[ objType.name() ][ ptr ] = pObj;
 }
Example #24
0
void Adaptor::RegisterSingleton(const std::type_info& info, Dali::BaseHandle singleton)
{
  mToolkitAdaptor.mFunctionsCalled.RegisterSingleton = true;

  if(singleton)
  {
    mSingletonContainer.insert(SingletonPair(info.name(), singleton));
  }
}
Example #25
0
Type::Type(const std::type_info& typeInfo)
{
	int iStatus;
	char* sRealName = abi::__cxa_demangle(typeInfo.name(), 0, 0, &iStatus);

	msName = sRealName;
	msFullName = sRealName;
	free(sRealName);
}
Example #26
0
std::string
typestr(std::type_info const& info)
{
  std::size_t n = 0;
  char* buf = abi::__cxa_demangle(info.name(), nullptr, &n, 0);
  std::string result(buf, n);
  std::free(buf);
  return result;
}
Example #27
0
/**
 * @return The demangled (human readable) version of the name() string for std::type_info
 */
inline std::string demangleTypeInfo(const std::type_info& aTypeInfo)
{
	int status;
	char* realname;
	realname = abi::__cxa_demangle(aTypeInfo.name(), 0, 0, &status);
	std::string result(realname);
	std::free(realname);
	return result;
}
Example #28
0
inline type_info::type_info(std::type_info const& id)
    : m_base_type(
#  ifdef BOOST_PYTHON_TYPE_ID_NAME
        id.name()
#  else
        &id
#  endif
        )
{
}
Example #29
0
std::string BaseClass::decodeTypeName(const std::type_info& type)
{
	std::string name;
#ifdef __GNUC__
	int status;
	char* allocname = abi::__cxa_demangle(type.name(), 0, 0, &status);
	if(allocname)
		name = allocname;
	else
		std::cerr << "Unable to demangle symbol: " << type.name() << std::endl;
#else
	name = type.name();
#endif
	helper::replaceAll<std::string>(name, "class ", "");
	helper::replaceAll<std::string>(name, "struct ", "");
	helper::replaceAll<std::string>(name, " ", "");

	return name;
}
Example #30
0
 virtual std::size_t calc_hash() const
 {
     std::size_t seed = 0;
     boost::hash_combine(seed, obj_is_const);
     boost::hash_combine(seed, ptr_is_const);
     boost::hash_combine(seed, is_ref);
     boost::hash_combine(seed, is_ptr);
     boost::hash_combine(seed, std::string(info->name()));
     return seed;
 }