Oh dear. So simple and obvious. Hannu Vuolasaho
---------------------------------------- Date: Sun, 20 May 2012 20:16:36 +0200 From: [email protected] To: [email protected] Subject: Re: Using std string when ustring is not available. Am 20.05.2012 16:15, schrieb Hannu Vuolasaho: > > Hello everyone! > > I'm thinking of supporting UTF-8 in my small console application and ustring > would be quite useful and using gtkmm there is possibility to add GUI also. > However some systems might not have gtkmm installed and in that case I'd like > to fall back to std string. > > Is this behaviour achievable some kind of wrapper class easily? > I'm thinking something like: > #ifdef HAVE_GTKMM > class myString: public ustring{ > .... > #else > class myString:public std::string{ > ... > #endif > and myString would act like stdstring or ustring. > Or what kind solution would be good? > > best regards, > Hannu Vuolasaho > I don't think public inheritance of std::string is a good idea. ustring doesn't either, for various reasons. Without further research, I suggest two options: 1. Create your own class which doesn't inherit from either one but contains an instance and mimics the interface -- basically doing what ustring does with regard to std::string. 2. Since ustring and std::string have very similar interfaces, you might get away with a preprocessor-dependant typedef like #ifdef HAVE_GTKMM typedef Glib::ustring mystring; #else typedef std::string mystring; #endif Regards, Florian Philipp _______________________________________________ gtkmm-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/gtkmm-list _______________________________________________ gtkmm-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/gtkmm-list
