I got a class:

class X
{
private:
  std::wstring text_;
public:
  std::wstring text() const { return text_; }
  void set_text(const std::string& text) { text_ = from_utf8(text); }
  void set_text(const std::wstring& text) { text_ = text; }
};

I'm trying to use it as a property:

BOOST_PYTHON_MODULE(test)
{
  class_<X>("X")
    .add_property("text", &X::text, <what here?>)
  ;
}

What should I write to get following behavior:

>>> x = X()
>>> x.text = "abc" # I want X::set_text(const std::string&) to be invoked here
>>> x.text = u"abc" # Here I expect X::set_text(const std::wstring&) to be 
called

-- 
Ilya.
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
https://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to