Re: [Boost-users] [boost::serialization] Convert enumeration tostringand back again

________________________________________ From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Robert Ramey Sent: Saturday, September 16, 2006 2:27 AM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [boost::serialization] Convert enumeration tostringand back again
class param_choice { enum { PARAM_CHOICE_UINT8, PARAM_CHOICE_UINT16, PARAM_CHOICE_UINT32, PARAM_CHOICE_INT8, PARAM_CHOICE_BOOL } m_current_value; template<class Archive> save(Archive &ar, unsigned int version) { std::string svalue; switch(m_current_value){
[Nat] If I were going to do this "by hand," I'd at least want to construct a map. From that I'd populate another for the reverse lookup. But that's probably because I haven't yet read up on Boost.MultiIndex.
case PARAM_CHOICE_UINT8: svalue = "PARAM_CHOICE_UINT8"; ... } ar << BOOST_SERIALIZATION_NVP(svalue); } template<class Archive> load(Archive &ar, unsigned int version){ std::string svalue; ar >> BOOST_SERIALIZATION_NVP(svalue); if(svalue == std::string("PARAM_CHOICE_UINT8") m_current_value = PARAM_CHOICE_UINT8; else if(... ... } };
participants (1)
-
Nat Goodspeed