forked from mirror/openmw-tes3mp
Killed str_error, std::runtime_error does the job
This commit is contained in:
parent
2407f21c47
commit
053074babb
13 changed files with 28 additions and 50 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <SDL_image.h>
|
#include <SDL_image.h>
|
||||||
#include "../../tools/str_exception.hpp"
|
#include <stdexcept>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
using namespace Mangle::Rend2D;
|
using namespace Mangle::Rend2D;
|
||||||
|
@ -70,7 +70,7 @@ int SDL_Sprite::height() { return surface->h; }
|
||||||
SDLDriver::SDLDriver() : display(NULL), realDisp(NULL), softDouble(false)
|
SDLDriver::SDLDriver() : display(NULL), realDisp(NULL), softDouble(false)
|
||||||
{
|
{
|
||||||
if (SDL_InitSubSystem( SDL_INIT_VIDEO ) == -1)
|
if (SDL_InitSubSystem( SDL_INIT_VIDEO ) == -1)
|
||||||
throw str_exception("Error initializing SDL video");
|
throw std::runtime_error("Error initializing SDL video");
|
||||||
}
|
}
|
||||||
SDLDriver::~SDLDriver()
|
SDLDriver::~SDLDriver()
|
||||||
{
|
{
|
||||||
|
@ -94,7 +94,7 @@ void SDLDriver::setVideoMode(int width, int height, int bpp, bool fullscreen)
|
||||||
// Create the surface and check it
|
// Create the surface and check it
|
||||||
realDisp = SDL_SetVideoMode(width, height, bpp, flags);
|
realDisp = SDL_SetVideoMode(width, height, bpp, flags);
|
||||||
if(realDisp == NULL)
|
if(realDisp == NULL)
|
||||||
throw str_exception("Failed setting SDL video mode");
|
throw std::runtime_error("Failed setting SDL video mode");
|
||||||
|
|
||||||
// Code for software double buffering. I haven't found this to be
|
// Code for software double buffering. I haven't found this to be
|
||||||
// any speed advantage at all in windowed mode (it's slower, as one
|
// any speed advantage at all in windowed mode (it's slower, as one
|
||||||
|
@ -160,7 +160,7 @@ Sprite* SDLDriver::loadImage(const std::string &file)
|
||||||
SDL_Surface *surf = IMG_Load(file.c_str());
|
SDL_Surface *surf = IMG_Load(file.c_str());
|
||||||
surf = convertImage(surf);
|
surf = convertImage(surf);
|
||||||
if(surf == NULL)
|
if(surf == NULL)
|
||||||
throw str_exception("SDL failed to load image file '" + file + "'");
|
throw std::runtime_error("SDL failed to load image file '" + file + "'");
|
||||||
return spriteFromSDL(surf);
|
return spriteFromSDL(surf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ Sprite* SDLDriver::loadImage(SDL_RWops *src, bool autoFree)
|
||||||
SDL_Surface *surf = IMG_Load_RW(src, autoFree);
|
SDL_Surface *surf = IMG_Load_RW(src, autoFree);
|
||||||
surf = convertImage(surf);
|
surf = convertImage(surf);
|
||||||
if(surf == NULL)
|
if(surf == NULL)
|
||||||
throw str_exception("SDL failed to load image");
|
throw std::runtime_error("SDL failed to load image");
|
||||||
return spriteFromSDL(surf);
|
return spriteFromSDL(surf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#define MANGLE_SOUND_SOURCE_SPLICE_H
|
#define MANGLE_SOUND_SOURCE_SPLICE_H
|
||||||
|
|
||||||
#include "../source.hpp"
|
#include "../source.hpp"
|
||||||
#include "../../tools/str_exception.hpp"
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -79,7 +79,7 @@ namespace Mangle
|
||||||
if(catchAll)
|
if(catchAll)
|
||||||
return catchAll->load(file);
|
return catchAll->load(file);
|
||||||
|
|
||||||
throw str_exception("No handler for sound file " + file);
|
throw std::runtime_error("No handler for sound file " + file);
|
||||||
}
|
}
|
||||||
|
|
||||||
SampleSourcePtr load(Stream::StreamPtr input) { assert(0); }
|
SampleSourcePtr load(Stream::StreamPtr input) { assert(0); }
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include "openal_out.hpp"
|
#include "openal_out.hpp"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
#include "../../stream/filters/buffer_stream.hpp"
|
#include "../../stream/filters/buffer_stream.hpp"
|
||||||
#include "../../tools/str_exception.hpp"
|
|
||||||
|
|
||||||
#include "al.h"
|
#include "al.h"
|
||||||
#include "alc.h"
|
#include "alc.h"
|
||||||
|
@ -26,7 +26,7 @@ static char tmp_buffer[BSIZE];
|
||||||
const int STREAM_BUF_NUM = 4;
|
const int STREAM_BUF_NUM = 4;
|
||||||
|
|
||||||
static void fail(const std::string &msg)
|
static void fail(const std::string &msg)
|
||||||
{ throw str_exception("OpenAL exception: " + msg); }
|
{ throw std::runtime_error("OpenAL exception: " + msg); }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Check for AL error. Since we're always calling this with string
|
Check for AL error. Since we're always calling this with string
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
#include "audiere_source.hpp"
|
#include "audiere_source.hpp"
|
||||||
|
|
||||||
#include "../../stream/clients/audiere_file.hpp"
|
#include "../../stream/clients/audiere_file.hpp"
|
||||||
#include "../../tools/str_exception.hpp"
|
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
using namespace Mangle::Stream;
|
using namespace Mangle::Stream;
|
||||||
|
|
||||||
static void fail(const std::string &msg)
|
static void fail(const std::string &msg)
|
||||||
{ throw str_exception("Audiere exception: " + msg); }
|
{ throw std::runtime_error("Audiere exception: " + msg); }
|
||||||
|
|
||||||
using namespace audiere;
|
using namespace audiere;
|
||||||
using namespace Mangle::Sound;
|
using namespace Mangle::Sound;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "ffmpeg_source.hpp"
|
#include "ffmpeg_source.hpp"
|
||||||
|
|
||||||
#include "../../tools/str_exception.hpp"
|
#include <stdexcept>
|
||||||
|
|
||||||
using namespace Mangle::Sound;
|
using namespace Mangle::Sound;
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ using namespace Mangle::Sound;
|
||||||
static uint8_t outBuf[AVCODEC_MAX_AUDIO_FRAME_SIZE];
|
static uint8_t outBuf[AVCODEC_MAX_AUDIO_FRAME_SIZE];
|
||||||
|
|
||||||
static void fail(const std::string &msg)
|
static void fail(const std::string &msg)
|
||||||
{ throw str_exception("FFMpeg exception: " + msg); }
|
{ throw std::runtime_error("FFMpeg exception: " + msg); }
|
||||||
|
|
||||||
// --- Loader ---
|
// --- Loader ---
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#include "libsndfile.hpp"
|
#include "libsndfile.hpp"
|
||||||
|
|
||||||
#include "../../tools/str_exception.hpp"
|
#include <stdexcept>
|
||||||
#include <sndfile.h>
|
#include <sndfile.h>
|
||||||
|
|
||||||
using namespace Mangle::Stream;
|
using namespace Mangle::Stream;
|
||||||
|
|
||||||
static void fail(const std::string &msg)
|
static void fail(const std::string &msg)
|
||||||
{ throw str_exception("Mangle::libsndfile: " + msg); }
|
{ throw std::runtime_error("Mangle::libsndfile: " + msg); }
|
||||||
|
|
||||||
using namespace Mangle::Sound;
|
using namespace Mangle::Sound;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "mpg123_source.hpp"
|
#include "mpg123_source.hpp"
|
||||||
|
|
||||||
#include "../../tools/str_exception.hpp"
|
#include <stdexcept>
|
||||||
|
|
||||||
#include <mpg123.h>
|
#include <mpg123.h>
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ using namespace Mangle::Stream;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void fail(const std::string &msg)
|
static void fail(const std::string &msg)
|
||||||
{ throw str_exception("Mangle::Mpg123 exception: " + msg); }
|
{ throw std::runtime_error("Mangle::Mpg123 exception: " + msg); }
|
||||||
|
|
||||||
static void checkError(int err, void *mh = NULL)
|
static void checkError(int err, void *mh = NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
#include "wav_source.hpp"
|
#include "wav_source.hpp"
|
||||||
|
|
||||||
#include "../../tools/str_exception.hpp"
|
|
||||||
#include "../../stream/servers/file_stream.hpp"
|
#include "../../stream/servers/file_stream.hpp"
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
using namespace Mangle::Stream;
|
using namespace Mangle::Stream;
|
||||||
using namespace Mangle::Sound;
|
using namespace Mangle::Sound;
|
||||||
|
|
||||||
static void fail(const std::string &msg)
|
static void fail(const std::string &msg)
|
||||||
{ throw str_exception("Mangle::Wav exception: " + msg); }
|
{ throw std::runtime_error("Mangle::Wav exception: " + msg); }
|
||||||
|
|
||||||
void WavSource::getInfo(int32_t *pRate, int32_t *pChannels, int32_t *pBits)
|
void WavSource::getInfo(int32_t *pRate, int32_t *pChannels, int32_t *pBits)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include "std_stream.hpp"
|
#include "std_stream.hpp"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
namespace Mangle {
|
namespace Mangle {
|
||||||
namespace Stream {
|
namespace Stream {
|
||||||
|
@ -20,7 +21,7 @@ class FileStream : public StdStream
|
||||||
file.open(name.c_str(), std::ios::binary);
|
file.open(name.c_str(), std::ios::binary);
|
||||||
|
|
||||||
if(file.fail())
|
if(file.fail())
|
||||||
throw str_exception("FileStream: failed to open file " + name);
|
throw std::runtime_error("FileStream: failed to open file " + name);
|
||||||
}
|
}
|
||||||
~FileStream() { file.close(); }
|
~FileStream() { file.close(); }
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,7 +30,7 @@ class OutFileStream : public StdOStream
|
||||||
file.open(name.c_str(), mode);
|
file.open(name.c_str(), mode);
|
||||||
|
|
||||||
if(file.fail())
|
if(file.fail())
|
||||||
throw str_exception("OutFileStream: failed to open file " + name);
|
throw std::runtime_error("OutFileStream: failed to open file " + name);
|
||||||
}
|
}
|
||||||
~OutFileStream() { file.close(); }
|
~OutFileStream() { file.close(); }
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "../stream.hpp"
|
#include "../stream.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "../../tools/str_exception.hpp"
|
#include <stdexcept>
|
||||||
|
|
||||||
namespace Mangle {
|
namespace Mangle {
|
||||||
namespace Stream {
|
namespace Stream {
|
||||||
|
@ -15,7 +15,7 @@ class StdOStream : public Stream
|
||||||
std::ostream *inf;
|
std::ostream *inf;
|
||||||
|
|
||||||
static void fail(const std::string &msg)
|
static void fail(const std::string &msg)
|
||||||
{ throw str_exception("StdOStream: " + msg); }
|
{ throw std::runtime_error("StdOStream: " + msg); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StdOStream(std::ostream *_inf)
|
StdOStream(std::ostream *_inf)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "../stream.hpp"
|
#include "../stream.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "../../tools/str_exception.hpp"
|
#include <stdexcept>
|
||||||
|
|
||||||
namespace Mangle {
|
namespace Mangle {
|
||||||
namespace Stream {
|
namespace Stream {
|
||||||
|
@ -15,7 +15,7 @@ class StdStream : public Stream
|
||||||
std::istream *inf;
|
std::istream *inf;
|
||||||
|
|
||||||
static void fail(const std::string &msg)
|
static void fail(const std::string &msg)
|
||||||
{ throw str_exception("StdStream: " + msg); }
|
{ throw std::runtime_error("StdStream: " + msg); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StdStream(std::istream *_inf)
|
StdStream(std::istream *_inf)
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
#ifndef __STR_EXCEPTION_H
|
|
||||||
#define __STR_EXCEPTION_H
|
|
||||||
|
|
||||||
#include <exception>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
/** @brief A simple exception that takes and holds a string
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
|
|
||||||
throw str_exception("message");
|
|
||||||
|
|
||||||
*/
|
|
||||||
class str_exception : public std::exception
|
|
||||||
{
|
|
||||||
std::string msg;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
str_exception(const std::string &m) : msg(m) {}
|
|
||||||
~str_exception() throw() {}
|
|
||||||
const char* what() const throw() { return msg.c_str(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
Reference in a new issue