⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 classtype.cc

📁 C++ Reflection & Service Library
💻 CC
字号:
/* C++ Reflection & Serice Library * Copyright (C) 2003  Marcus Perlick * mailto: riffraff@users.sf.net *  * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. *  * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Lesser General Public License for more details. *  * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA * * This file is part of the "C++ Reflection & Serice Library" */#include "ClassType.hh"#include "Exception.hh"namespace rfl {  void  ClassType::avStartCall( av_alist& avList, 			  void* fnPtr,			  void *retVal ) const  {    Exception x( X_AV_STRUCT_RETVAL,		 _("returning class types (%s) from a reflected function is "\		   "not yet supported."),		 getName().c_str() );    throw x;  }  void  ClassType::avPutArg( av_alist& avList, void* arg ) const  {    Exception x( X_AV_STRUCT_ARG,		 _("passing class types (%s) to a reflected funtion is not "\		   "yet supported.") );    throw x;  }  int  ClassType::getElmIdx( const mpu::String& name ) const  {    MemberList::const_iterator end = mbrs_.end();    for ( MemberList::const_iterator it = mbrs_.begin(); it != end; ++it ) {      if ( it->name_ == name )	return it - mbrs_.begin();    }    return -1;  }  const Type&  ClassType::getElmType( std::size_t idx ) const  {    assert( idx < mbrs_.size() );    assert( mbrs_[ idx ].type_ != 0 );    return *(mbrs_[ idx ].type_);  }  void*  ClassType::getElmAddr( void* obj, std::size_t idx ) const  {    assert( idx < mbrs_.size() );    return (char*)obj + mbrs_[ idx ].offset_;  }  unsigned long  ClassType::hash( void ) const  {    unsigned long ret = ID_CLASS;    BaseClassList::const_iterator bEnd = bases_.end();    for ( BaseClassList::const_iterator it = bases_.begin();	  it != bEnd;	  ++it )    {      updateHash( ret, it->offset_ );      assert( it->type_ != 0 );      updateHash( ret, it->type_->hash() );    }    MemberList::const_iterator mEnd = mbrs_.end();    for ( MemberList::const_iterator it = mbrs_.begin(); it != mEnd; ++it ) {      updateHash( ret, it->offset_ );      assert( it->type_ != 0 );      updateHash( ret, it->type_->hash() );    }    return ret;  }  bool  ClassType::operator==( const Type& type ) const  {    if ( type.getId() != ID_CLASS )      return false;    const ClassType& cty = static_cast<const ClassType&>(type);    if ( bases_.size() != cty.bases_.size() )      return false;    if ( mbrs_.size() != cty.mbrs_.size() )      return false;    BaseClassList::const_iterator bEnd = bases_.end();    BaseClassList::const_iterator ctyBIt = cty.bases_.begin();    for ( BaseClassList::const_iterator it = bases_.begin();	  it != bEnd;	  ++it, ++ctyBIt )    {      if ( it->offset_ != ctyBIt->offset_ )	return false;      if ( *(it->type_) != *(ctyBIt->type_) )	return false;    }    MemberList::const_iterator mEnd = mbrs_.end();    MemberList::const_iterator ctyMIt = cty.mbrs_.begin();    for ( MemberList::const_iterator it = mbrs_.begin(); it != mEnd; ++it ) {      if ( it->offset_ != ctyMIt->offset_ )	return false;            if ( *(it->type_) != *(ctyMIt->type_) )	return false;    }    return true;  }} // namespace rfl

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -