Target type is neither std::istream`able nor std::wistream`a

Forum for posting problems using QxOrm library

Target type is neither std::istream`able nor std::wistream`a

Postby gianks » Sun Jul 24, 2016 9:08 pm

Hi all,
trying to register a setter for a protected member i'm obtaining the following:
Code: Select all
In file included from /usr/include/boost/iterator/iterator_categories.hpp:22:0,
                 from /usr/include/boost/unordered/detail/util.hpp:17,
                 from /usr/include/boost/unordered/detail/buckets.hpp:15,
                 from /usr/include/boost/unordered/detail/table.hpp:15,
                 from /usr/include/boost/unordered/detail/equivalent.hpp:15,
                 from /usr/include/boost/unordered/unordered_map.hpp:18,
                 from /usr/include/boost/unordered_map.hpp:17,
                 from /usr/local/include/QxPrecompiled.h:110,
                 from /usr/local/include/QxOrm.h:58,
                 from Headers/GSS/QxOrm/precompiled.h:4:
/usr/include/boost/lexical_cast/detail/converter_lexical.hpp: In instantiation of ‘struct boost::detail::deduce_target_char_impl<boost::detail::deduce_character_type_later<NGS::GSS::GssLiveSource::SrcEnable> >’:
/usr/include/boost/lexical_cast/detail/converter_lexical.hpp:269:89:   required from ‘struct boost::detail::deduce_target_char<NGS::GSS::GssLiveSource::SrcEnable>’
/usr/include/boost/lexical_cast/detail/converter_lexical.hpp:403:92:   required from ‘struct boost::detail::lexical_cast_stream_traits<std::__cxx11::basic_string<char>, NGS::GSS::GssLiveSource::SrcEnable>’
/usr/include/boost/lexical_cast/detail/converter_lexical.hpp:465:15:   required from ‘struct boost::detail::lexical_converter_impl<NGS::GSS::GssLiveSource::SrcEnable, std::__cxx11::basic_string<char> >’
/usr/include/boost/lexical_cast/try_lexical_convert.hpp:173:44:   required from ‘bool boost::conversion::detail::try_lexical_convert(const Source&, Target&) [with Target = NGS::GSS::GssLiveSource::SrcEnable; Source = std::__cxx11::basic_string<char>]’
/usr/include/boost/lexical_cast.hpp:41:60:   required from ‘Target boost::lexical_cast(const Source&) [with Target = NGS::GSS::GssLiveSource::SrcEnable; Source = std::__cxx11::basic_string<char>]’
/usr/local/include/QxFunction/QxParameters.h:80:92:   required from ‘qx_bool qx::function::detail::get_param_1(const QString&, P&, const qx::IxFunction*) [with P = NGS::GSS::GssLiveSource::SrcEnable; qx_bool = qx::QxBool]’
/usr/local/include/QxFunction/QxFunction_1.h:89:10:   required from ‘static qx_bool qx::QxFunction_1<Owner, R, P1>::QxInvokerFct<T, true>::invoke(void*, const T&, boost::any*, const qx::QxFunction_1<Owner, R, P1>*) [with T = QString; Owner = NGS::GSS::GssLiveSource; R = NGS::GSS::GssLiveSource*; P1 = NGS::GSS::GssLiveSource::SrcEnable; qx_bool = qx::QxBool]’
/usr/local/include/QxFunction/QxFunction_1.h:63:4:   required from ‘qx_bool qx::QxFunction_1<Owner, R, P1>::invoke(void*, const QString&, boost::any*) const [with Owner = NGS::GSS::GssLiveSource; R = NGS::GSS::GssLiveSource*; P1 = NGS::GSS::GssLiveSource::SrcEnable; qx_bool = qx::QxBool]’
src/QxOrm/ORM_LiveSource.cpp:41:1:   required from here
/usr/include/boost/lexical_cast/detail/converter_lexical.hpp:242:13: error: static assertion failed: Target type is neither std::istream`able nor std::wistream`able
             BOOST_STATIC_ASSERT_MSG((result_t::value || boost::has_right_shift<std::basic_istream<wchar_t>, T >::value),


The setter is taking an ENUM as the field is of that type. Shall i register the enum somehow?
Thanks
gianks
 
Posts: 45
Joined: Mon Jul 04, 2016 1:04 pm

Re: Target type is neither std::istream`able nor std::wistre

Postby qxorm » Mon Jul 25, 2016 8:18 am

Hello,

In this case, you have to specialize boost::lexical_cast<T>, here is a working example :
Code: Select all
// 1- The enum definition
struct test_enum
{
   enum e_my_enum
   {
      e_my_enum_0 = 0,
      e_my_enum_1 = 1,
      e_my_enum_2 = 2
   };
};

// 2- The boost::lexical_cast<T> specialization
namespace boost {

   template<>
   test_enum::e_my_enum lexical_cast(const std::string & s)
   {
      return static_cast<test_enum::e_my_enum>(boost::lexical_cast<int>(s));
   }

} // namespace boost

// 3- The function we want to register in QxOrm context with an enum type as parameter (in your case, your setter)
int test_fct_with_enum(test_enum::e_my_enum e) { return static_cast<int>(e); }

// 4- Register the function in QxOrm context
qx::IxFunction_ptr pFctXXX = qx::function::bind_fct_1<void, int, test_enum::e_my_enum>(& test_fct_with_enum);

// 5- Call the function using introspection engine of QxOrm library
boost::any any_ret;
bInvoke = pFctXXX->invoke(QString::number(static_cast<int>(test_enum::e_my_enum_2)), & any_ret);
// Here, any_ret contains a int type (corresponding to test_fct_with_enum() return value) with value = 2
qxorm
Site Admin
 
Posts: 481
Joined: Mon Apr 12, 2010 7:45 am

Re: Target type is neither std::istream`able nor std::wistre

Postby gianks » Mon Jul 25, 2016 3:38 pm

Many Thanks!
gianks
 
Posts: 45
Joined: Mon Jul 04, 2016 1:04 pm


Return to QxOrm - Help

Who is online

Users browsing this forum: No registered users and 13 guests

cron