Example #1
0
inline
void
asuset(
  str_cref spgnam,
  int const& numsgp,
  str_ref pgname,
  int const& msym,
  arr_ref<float, 3> rrsym,
  int& msymp,
  int& mlaue,
  bool const& lprint)
{
  ccp4_ftn_logical lprint_ = lprint;
  asuset_(
    spgnam.elems(),
    &numsgp,
    pgname.elems(),
    &msym,
    rrsym.begin(),
    &msymp,
    &mlaue,
    &lprint_,
    spgnam.len(),
    pgname.len());
}
 inline
 int
 len_trim(
   str_cref c)
 {
   return static_cast<int>(
     utils::find_trailing_blank_padding(c.elems(), c.len()));
 }
 inline
 int
 ichar(
   str_cref c)
 {
   if (c.len() == 0) {
     std::ostringstream o;
     o << "ichar() argument must be a one-character string,"
       << " but actual string length is " << c.len() << ".";
     throw std::runtime_error(o.str());
   }
   return static_cast<int>(c[0]);
 }
Example #4
0
inline
void
symfr2(
  str_cref icol,
  int const& i1,
  int& ns,
  arr_ref<float, 3> rot)
{
  symfr2_(
    icol.elems(),
    &i1,
    &ns,
    rot.begin(),
    icol.len());
}
Example #5
0
	LibraryUnixImpl( str_cref alias, str_cref path ) :
		m_handle( NULL ),
		m_alias( alias ),
		m_path( path )
	{
		if( !( m_handle = dlopen( path.c_str(), RTLD_LAZY | RTLD_GLOBAL ) ) )
		{
			std::ostringstream oss;
			oss << "Failed to open library " << alias
				<< " at " << path << "\n\t" << dlerror();

			throw std::invalid_argument( oss.str() );
		}
	}
Example #6
0
ObjectInfoPtr ConfigObjectLoader::getObjectInfo( expr_cref expr, str_cref name ) const
{
	if( !name.empty() )
	{
		ObjectInfoPtr obj;

		// already found.
		if( Utility::mapLookup( m_objects, name, obj ) )
		{
			return obj;
		}
	}

	if( expr.type() == EObject ) // it's an object expression
	{
		std::string className = expr.value();
		ClassInfoPtr classInfo = getClassInfo( className );
		BuilderPtr builder = classInfo->createBuilder( name, expr );
        ObjectInfoPtr obj( new ObjectInfo( name, expr, *classInfo, builder ) );

        // It needs to be in the map before we bind its parameters so a circular reference can be detected
        m_objects[name] = obj;
        builder->bindParams( *this );
		return obj;
	}
	else if( expr.type() == EVariable )
	{
		// this could recurse indefinitely with circular reference..

		// NOTE: if anything throws here, let ParamBinderBase manage the context of the error.

		std::string objName;
		expr_cref expr2 = underlying( expr, &objName );
		return getObjectInfo( expr2, objName );
	}
	else // this isn't a class. It might be a map or list or whatever but isn't an object
	{
		std::ostringstream oss;
		oss << expr.value() << " is not an object";

		// Do not throw TypeError here. If it isn't an object it can't be a proxy either
		throw std::invalid_argument( oss.str() );
	}

}