Sha256: 4eb6d458a3607620c683beb96030e472ca50065b788c0d4a3dd39d15062f5b3e

Contents?: true

Size: 1.15 KB

Versions: 36

Compression:

Stored size: 1.15 KB

Contents

#ifndef Rice__detail__from_ruby__ipp_
#define Rice__detail__from_ruby__ipp_

#include "../Data_Type.hpp"
#include "../String.hpp"
#include "demangle.hpp"
#include <typeinfo>

template<typename T>
T Rice::detail::from_ruby_<T>::
convert(Rice::Object x)
{
  if(rb_type(x.value()) == T_DATA)
  {
    return *Data_Type<T>::from_ruby(x);
  }
  else
  {
    std::string s("Unable to convert ");
    s += x.class_of().name().c_str();
    s += " to ";
    s += demangle(typeid(T).name());
    throw std::invalid_argument(s.c_str());
  }
}

template<typename T>
T * Rice::detail::from_ruby_<T *>::
convert(Rice::Object x)
{
  if(rb_type(x.value()) == T_DATA)
  {
    return Data_Type<T>::from_ruby(x);
  }
  else
  {
    std::string s("Unable to convert ");
    s += x.class_of().name().c_str();
    s += " to ";
    s += demangle(typeid(T *).name());
    throw std::invalid_argument(s.c_str());
  }
}

template<typename T>
T const * Rice::detail::from_ruby_<T const *>::
convert(Rice::Object x)
{
  return from_ruby<T *>(x);
}

template<typename T>
T & Rice::detail::from_ruby_<T &>::
convert(Rice::Object x)
{
  return *from_ruby<T *>(x);
}

#endif // Rice__detail__from_ruby__ipp_

Version data entries

36 entries across 36 versions & 6 rubygems

Version Path
rice-3.0.0 rice/detail/from_ruby.ipp
rice2-2.2.1 rice/detail/from_ruby.ipp
rice2-2.2.0 rice/detail/from_ruby.ipp
rice-2.2.0 rice/detail/from_ruby.ipp
rice-2.1.3 rice/detail/from_ruby.ipp
rice-2.1.2 rice/detail/from_ruby.ipp
rice-2.1.1 rice/detail/from_ruby.ipp
rice-2.1.0 rice/detail/from_ruby.ipp
rice-2.0.0 rice/detail/from_ruby.ipp
rice-1.7.0 rice/detail/from_ruby.ipp
rice-1.6.3 rice/detail/from_ruby.ipp
jameskilton-rice-1.2.0 rice/detail/from_ruby.ipp
rice-1.6.2 rice/detail/from_ruby.ipp
rice-1.6.1 rice/detail/from_ruby.ipp
rice-1.6.0 rice/detail/from_ruby.ipp
rice-1.6.0.pre rice/detail/from_ruby.ipp
rice-1.5.3 rice/detail/from_ruby.ipp
rice-1.5.2 rice/detail/from_ruby.ipp
keyme-rice-1.5.1.keyme1 rice/detail/from_ruby.ipp
keyme-rice-1.5.1.keyme rice/detail/from_ruby.ipp