I am developing GUI application via wxWidgets. It has 2 parts: GUI part and "Logic" part. I want to have Logic part totally independent on wxWidgets. But one component in the GUI returning wxVariant and I need to use it in the Logic part.
So I am looking for a way to "convert" wxVariant to boost::variant
wxVariant works like this:
wxVariant v("37");
int i = v.GetInteger(); //i==37
So I am thinking something like
string s = methodReturningWxVariant().GetString();
boost::variant bV(s);
//later in code e.g
bV.GetInt();
bV.GetBool();
Is it possible to use boost::Variant (or boost::Any) like this?
wxAny
? If need you need to, then consider doing a check onwxAny
before assigning value toboost::variant
... – Sargassumboost::[V/v]ariant
-- it is a template class that needs to know the types in advance. The similarity in name is mostly accidental, in fact, wxWdgets will be replacing wxVariant with wxAny at some point to avoid this. In related news, Boost.Any is a little closer, but it still doesn't let you parse and unparse strings, af far as I know. – Fluoroscope