diff options
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | configure.in | 3 | ||||
-rw-r--r-- | glib/glibmm/ustring.cc | 12 | ||||
-rw-r--r-- | glib/src/convert.ccg | 4 | ||||
-rw-r--r-- | glib/src/convert.hg | 2 | ||||
-rw-r--r-- | glib/src/date.ccg | 11 |
6 files changed, 30 insertions, 4 deletions
@@ -2,6 +2,8 @@ 2006-05-11 Murray Cumming <murrayc@murrayc.com> + glib/glibmm/ustring.cc: + * glib/src/date.ccg: * glib/src/convert.ccg: * glib/src/convert.hg: Added #ifdefed versions for the case that exceptions are disabled. diff --git a/configure.in b/configure.in index 41de1267..43f1f1a0 100644 --- a/configure.in +++ b/configure.in @@ -245,6 +245,9 @@ fi GLIBMM_ARG_ENABLE_API_PROPERTIES() GLIBMM_ARG_ENABLE_API_VFUNCS() +# Offer the ability to omit some API from the library, +# to reduce the code size: +GLIBMM_ARG_ENABLE_API_EXCEPTIONS() # Dummy conditional just to make automake-1.4 happy. # We need an always-false condition in docs/Makefile.am. diff --git a/glib/glibmm/ustring.cc b/glib/glibmm/ustring.cc index 788658ae..36d709da 100644 --- a/glib/glibmm/ustring.cc +++ b/glib/glibmm/ustring.cc @@ -1193,13 +1193,25 @@ std::istream& operator>>(std::istream& is, Glib::ustring& utf8_string) { std::string locale_string; is >> locale_string; + + #ifdef GLIBMM_EXCEPTIONS_ENABLED utf8_string = Glib::locale_to_utf8(locale_string); + #else + std::auto_ptr<Glib::Error> error; //TODO: Check this? + utf8_string = Glib::locale_to_utf8(locale_string, error); + #endif //GLIBMM_EXCEPTIONS_ENABLED return is; } std::ostream& operator<<(std::ostream& os, const Glib::ustring& utf8_string) { + #ifdef GLIBMM_EXCEPTIONS_ENABLED os << Glib::locale_from_utf8(utf8_string); + #else + std::auto_ptr<Glib::Error> error; //TODO: Check this? + os << Glib::locale_from_utf8(utf8_string, error); + #endif //GLIBMM_EXCEPTIONS_ENABLED + return os; } diff --git a/glib/src/convert.ccg b/glib/src/convert.ccg index 47fb5712..9a4dae14 100644 --- a/glib/src/convert.ccg +++ b/glib/src/convert.ccg @@ -47,8 +47,6 @@ IConv::IConv(const std::string& to_codeset, const std::string& from_codeset) #ifdef GLIBMM_EXCEPTIONS_ENABLED if(gerror) ::Glib::Error::throw_exception(gerror); - #else - error = ::Glib::Error::throw_exception(gerror); #endif //GLIBMM_EXCEPTIONS_ENABLED } } @@ -127,7 +125,7 @@ std::string convert(const std::string& str, #else std::string convert(const std::string& str, const std::string& to_codeset, - const std::string& from_codeset std::auto_ptr<Glib::Error>& error) + const std::string& from_codeset, std::auto_ptr<Glib::Error>& error) #endif //GLIBMM_EXCEPTIONS_ENABLED { gsize bytes_written = 0; diff --git a/glib/src/convert.hg b/glib/src/convert.hg index 2315bc6b..cfa326bf 100644 --- a/glib/src/convert.hg +++ b/glib/src/convert.hg @@ -220,7 +220,7 @@ std::string locale_from_utf8(const Glib::ustring& utf8_string, std::auto_ptr<Gli #ifdef GLIBMM_EXCEPTIONS_ENABLED Glib::ustring filename_to_utf8(const std::string& opsys_string); #else -Glib::ustring filename_to_utf8(const std::string& opsys_string) +Glib::ustring filename_to_utf8(const std::string& opsys_string, std::auto_ptr<Glib::Error>& error); #endif //GLIBMM_EXCEPTIONS_ENABLED /** Converts a string from UTF-8 to the encoding used for filenames. diff --git a/glib/src/date.ccg b/glib/src/date.ccg index 0bf5c632..7ed7e0ca 100644 --- a/glib/src/date.ccg +++ b/glib/src/date.ccg @@ -261,7 +261,13 @@ Glib::ustring Date::format_string(const Glib::ustring& format) const struct tm tm_data; g_date_to_struct_tm(&gobject_, &tm_data); + #ifdef GLIBMM_EXCEPTIONS_ENABLED const std::string locale_format = locale_from_utf8(format); + #else + std::auto_ptr<Glib::Error> error; //TODO: Check it? + const std::string locale_format = locale_from_utf8(format, error); + #endif //GLIBMM_EXCEPTIONS_ENABLED + gsize bufsize = std::max<gsize>(2 * locale_format.size(), 128); do @@ -276,7 +282,12 @@ Glib::ustring Date::format_string(const Glib::ustring& format) const if(len != 0 || buf.get()[0] == '\0') { g_assert(len < bufsize); + #ifdef GLIBMM_EXCEPTIONS_ENABLED return locale_to_utf8(std::string(buf.get(), len)); + #else + std::auto_ptr<Glib::Error> error; //TODO: Check it? + return locale_to_utf8(std::string(buf.get(), len), error); + #endif //GLIBMM_EXCEPTIONS_ENABLED } } while((bufsize *= 2) <= 65536); |