From: <man...@us...> - 2013-07-03 00:32:14
|
Revision: 2481 http://sourceforge.net/p/modplug/code/2481 Author: manxorist Date: 2013-07-03 00:32:07 +0000 (Wed, 03 Jul 2013) Log Message: ----------- [Ref] libopenmpt: Simplify openmpt::exception. Modified Paths: -------------- trunk/OpenMPT/libopenmpt/libopenmpt.hpp trunk/OpenMPT/libopenmpt/libopenmpt_c.cpp trunk/OpenMPT/libopenmpt/libopenmpt_cxx.cpp trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp trunk/OpenMPT/libopenmpt/libopenmpt_version.cpp trunk/OpenMPT/openmpt123/openmpt123.hpp Modified: trunk/OpenMPT/libopenmpt/libopenmpt.hpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.hpp 2013-07-02 23:46:46 UTC (rev 2480) +++ trunk/OpenMPT/libopenmpt/libopenmpt.hpp 2013-07-03 00:32:07 UTC (rev 2481) @@ -12,10 +12,10 @@ #include "libopenmpt_config.h" -#include <exception> #include <iostream> #include <istream> #include <ostream> +#include <stdexcept> #include <string> #include <vector> @@ -23,12 +23,9 @@ namespace openmpt { -class LIBOPENMPT_CXX_API exception : public std::exception { +class LIBOPENMPT_CXX_API exception : public std::runtime_error { public: - exception() throw(); - virtual ~exception() throw(); -public: - virtual const char * what() const throw(); + exception( const std::string & text ); }; // class exception LIBOPENMPT_CXX_API std::uint32_t get_library_version(); Modified: trunk/OpenMPT/libopenmpt/libopenmpt_c.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_c.cpp 2013-07-02 23:46:46 UTC (rev 2480) +++ trunk/OpenMPT/libopenmpt/libopenmpt_c.cpp 2013-07-03 00:32:07 UTC (rev 2481) @@ -182,7 +182,7 @@ #define OPENMPT_INTERFACE_CHECK_SOUNDFILE( mod ) \ do { \ if ( !(mod) ) { \ - throw openmpt::exception_message("module * not valid"); \ + throw openmpt::exception("module * not valid"); \ } \ } while(0) \ /**/ @@ -190,7 +190,7 @@ #define OPENMPT_INTERFACE_CHECK_POINTER( value ) \ do { \ if ( !(value) ) { \ - throw openmpt::exception_message("null pointer"); \ + throw openmpt::exception("null pointer"); \ } \ } while(0) \ /**/ Modified: trunk/OpenMPT/libopenmpt/libopenmpt_cxx.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_cxx.cpp 2013-07-02 23:46:46 UTC (rev 2480) +++ trunk/OpenMPT/libopenmpt/libopenmpt_cxx.cpp 2013-07-03 00:32:07 UTC (rev 2481) @@ -21,18 +21,10 @@ namespace openmpt { -exception::exception() throw() { +exception::exception( const std::string & text ) : std::runtime_error( text ) { return; } -exception::~exception() throw() { - return; -} - -const char * exception::what() const throw() { - return ""; -} - std::uint32_t get_library_version() { return openmpt::version::get_library_version(); } Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2013-07-02 23:46:46 UTC (rev 2480) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2013-07-03 00:32:07 UTC (rev 2481) @@ -27,16 +27,6 @@ namespace openmpt { -exception_message::exception_message( const char * text_ ) throw() : text(text_) { - return; -} -exception_message::~exception_message() throw() { - return; -} -const char * exception_message::what() const throw() { - return text; -} - log_interface::log_interface() { return; } @@ -114,7 +104,7 @@ } else if ( length >= 1 ) { return SRCMODE_NEAREST; } else { - throw openmpt::exception_message("negative filter length"); + throw openmpt::exception("negative filter length"); return SRCMODE_POLYPHASE; } } @@ -134,7 +124,7 @@ case SRCMODE_DEFAULT: return 8; default: - throw openmpt::exception_message("unknown interpolation filter length set internally"); + throw openmpt::exception("unknown interpolation filter length set internally"); break; } } @@ -168,7 +158,7 @@ } void module_impl::load( CSoundFile & sndFile, const FileReader & file ) { if ( !sndFile.Create( file, CSoundFile::loadCompleteModule ) ) { - throw openmpt::exception_message("error loading file"); + throw openmpt::exception("error loading file"); } } void module_impl::load( const FileReader & file ) { @@ -316,7 +306,7 @@ case module::RENDER_VOLUMERAMP_DOWN_MICROSECONDS: { return m_sndFile->m_MixerSettings.GetVolumeRampDownMicroseconds(); } break; - default: throw openmpt::exception_message("unknown render param"); break; + default: throw openmpt::exception("unknown render param"); break; } return 0; } @@ -362,13 +352,13 @@ m_sndFile->SetMixerSettings( newsettings ); } } break; - default: throw openmpt::exception_message("unknown render param"); break; + default: throw openmpt::exception("unknown render param"); break; } } std::size_t module_impl::read( std::int32_t samplerate, std::size_t count, std::int16_t * mono ) { if ( !mono ) { - throw openmpt::exception_message("null pointer"); + throw openmpt::exception("null pointer"); } apply_mixer_settings( samplerate, 1, false ); count = read_wrapper( count, mono, 0, 0, 0 ); @@ -377,7 +367,7 @@ } std::size_t module_impl::read( std::int32_t samplerate, std::size_t count, std::int16_t * left, std::int16_t * right ) { if ( !left || !right ) { - throw openmpt::exception_message("null pointer"); + throw openmpt::exception("null pointer"); } apply_mixer_settings( samplerate, 2, false ); count = read_wrapper( count, left, right, 0, 0 ); @@ -386,7 +376,7 @@ } std::size_t module_impl::read( std::int32_t samplerate, std::size_t count, std::int16_t * left, std::int16_t * right, std::int16_t * rear_left, std::int16_t * rear_right ) { if ( !left || !right || !rear_left || !rear_right ) { - throw openmpt::exception_message("null pointer"); + throw openmpt::exception("null pointer"); } apply_mixer_settings( samplerate, 4, false ); count = read_wrapper( count, left, right, rear_left, rear_right ); @@ -395,7 +385,7 @@ } std::size_t module_impl::read( std::int32_t samplerate, std::size_t count, float * mono ) { if ( !mono ) { - throw openmpt::exception_message("null pointer"); + throw openmpt::exception("null pointer"); } apply_mixer_settings( samplerate, 1, true ); count = read_wrapper( count, mono, 0, 0, 0 ); @@ -404,7 +394,7 @@ } std::size_t module_impl::read( std::int32_t samplerate, std::size_t count, float * left, float * right ) { if ( !left || !right ) { - throw openmpt::exception_message("null pointer"); + throw openmpt::exception("null pointer"); } apply_mixer_settings( samplerate, 2, true ); count = read_wrapper( count, left, right, 0, 0 ); @@ -413,7 +403,7 @@ } std::size_t module_impl::read( std::int32_t samplerate, std::size_t count, float * left, float * right, float * rear_left, float * rear_right ) { if ( !left || !right || !rear_left || !rear_right ) { - throw openmpt::exception_message("null pointer"); + throw openmpt::exception("null pointer"); } apply_mixer_settings( samplerate, 4, true ); count = read_wrapper( count, left, right, rear_left, rear_right ); @@ -646,39 +636,45 @@ } std::string module_impl::ctl_get_string( const std::string & ctl ) const { if ( ctl == "" ) { - throw openmpt::exception_message("unknown ctl"); + throw openmpt::exception("unknown ctl"); } - throw openmpt::exception_message("unknown ctl"); + throw openmpt::exception("unknown ctl"); } double module_impl::ctl_get_double( const std::string & ctl ) const { if ( ctl == "" ) { - throw openmpt::exception_message("unknown ctl"); + throw openmpt::exception("unknown ctl"); } - throw openmpt::exception_message("unknown ctl"); + throw openmpt::exception("unknown ctl"); } std::int64_t module_impl::ctl_get_int64( const std::string & ctl ) const { if ( ctl == "" ) { - throw openmpt::exception_message("unknown ctl"); + throw openmpt::exception("unknown ctl"); } - throw openmpt::exception_message("unknown ctl"); + throw openmpt::exception("unknown ctl"); } void module_impl::ctl_set( const std::string & ctl, const std::string & value ) { if ( ctl == "" ) { - throw openmpt::exception_message("unknown ctl"); + throw openmpt::exception("unknown ctl: " + ctl + " := " + value); } - throw openmpt::exception_message("unknown ctl"); + throw openmpt::exception("unknown ctl: " + ctl + " := " + value); } void module_impl::ctl_set( const std::string & ctl, double value ) { + std::ostringstream str; + str << value; + std::string strval = str.str(); if ( ctl == "" ) { - throw openmpt::exception_message("unknown ctl"); + throw openmpt::exception("unknown ctl: " + ctl + " := " + strval); } - throw openmpt::exception_message("unknown ctl"); + throw openmpt::exception("unknown ctl: " + ctl + " := " + strval); } void module_impl::ctl_set( const std::string & ctl, std::int64_t value ) { + std::ostringstream str; + str << value; + std::string strval = str.str(); if ( ctl == "" ) { - throw openmpt::exception_message("unknown ctl"); + throw openmpt::exception("unknown ctl: " + ctl + " := " + strval); } - throw openmpt::exception_message("unknown ctl"); + throw openmpt::exception("unknown ctl: " + ctl + " := " + strval); } } // namespace openmpt Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp 2013-07-02 23:46:46 UTC (rev 2480) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp 2013-07-03 00:32:07 UTC (rev 2481) @@ -31,17 +31,6 @@ } // namespace version -// has to be exported for type_info lookup to work -class LIBOPENMPT_CXX_API exception_message : public exception { -public: - exception_message( const char * text_ ) throw(); - virtual ~exception_message() throw(); -public: - virtual const char * what() const throw(); -private: - const char * text; -}; // class exception_message - class log_interface { protected: log_interface(); Modified: trunk/OpenMPT/libopenmpt/libopenmpt_version.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_version.cpp 2013-07-02 23:46:46 UTC (rev 2480) +++ trunk/OpenMPT/libopenmpt/libopenmpt_version.cpp 2013-07-03 00:32:07 UTC (rev 2481) @@ -110,11 +110,7 @@ // has to be exported for type_info lookup to work class LIBOPENMPT_CXX_API version_mismatch : public openmpt::exception { public: - version_mismatch() throw() { } - virtual ~version_mismatch() throw() { } - virtual const char * what() const throw() { - return "API and header version mismatch"; - } + version_mismatch() : openmpt::exception("API and header version mismatch") { } }; // class version_mismatch void version_compatible_or_throw( std::int32_t api_version ) { Modified: trunk/OpenMPT/openmpt123/openmpt123.hpp =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123.hpp 2013-07-02 23:46:46 UTC (rev 2480) +++ trunk/OpenMPT/openmpt123/openmpt123.hpp 2013-07-03 00:32:07 UTC (rev 2481) @@ -15,11 +15,7 @@ namespace openmpt123 { struct exception : public openmpt::exception { - exception( const char * text_ ) throw() : text(text_) { } - virtual const char * what() const throw() { - return text; - } - const char * text; + exception( const char * text ) : openmpt::exception(text) { } }; struct show_help_exception { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |