From: spog Date: Sun, 9 Jul 2006 22:14:47 +0000 (+0000) Subject: experimental string converter class X-Git-Tag: xonotic-v0.7.0~16^2~12^2~203 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=c7987cc0be539b26153f1b4acc2b317c9d663d97;p=xonotic%2Fnetradiant.git experimental string converter class git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/trunk@91 8a3a26a2-13c4-0310-b231-cf6edde360e5 --- diff --git a/radiant/dialog.cpp b/radiant/dialog.cpp index 0240e675..c3ef12bf 100644 --- a/radiant/dialog.cpp +++ b/radiant/dialog.cpp @@ -170,18 +170,31 @@ void IntRadioExport(GtkRadioButton& widget, const IntImportCallback& importCallb } typedef ImportExport IntRadioImportExport; +template +class StringFromType +{ + StringOutputStream value; +public: + StringFromType(const Type& type) + { + value << Formatter(type); + } + operator const char*() const + { + return value.c_str(); + } +}; + +typedef StringFromType LocaleToUTF8; +typedef StringFromType UTF8ToLocale; void TextEntryImport(GtkEntry& widget, const char* text) { - StringOutputStream value(64); - value << ConvertLocaleToUTF8(text); - gtk_entry_set_text(&widget, value.c_str()); + gtk_entry_set_text(&widget, LocaleToUTF8(text)); } void TextEntryExport(GtkEntry& widget, const StringImportCallback& importCallback) { - StringOutputStream value(64); - value << ConvertUTF8ToLocale(gtk_entry_get_text(&widget)); - importCallback(value.c_str()); + importCallback(UTF8ToLocale(gtk_entry_get_text(&widget))); } typedef ImportExport TextEntryImportExport;