You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Exceptions.h: fixes for noexcept, unused vars, std::
Some fixes for `-Wall`-readiness: * Removed `using namespace std;` from the header and added `std::` prefixes where needed (`std::string`) * Replaced `throw ()` in declarations with `noexcept`, as `throw ()` is [deprecated in c++11][1] * Several exception classes had a `file_path` member variable, despite never using it. Removed the unused class member. [1]:<https://en.cppreference.com/w/cpp/language/noexcept_spec>
This commit is contained in:
@@ -32,7 +32,6 @@
|
||||
#define OPENSHOT_EXCEPTIONS_H
|
||||
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
namespace openshot {
|
||||
|
||||
@@ -45,11 +44,11 @@ namespace openshot {
|
||||
class BaseException : public std::exception //: public exception
|
||||
{
|
||||
protected:
|
||||
string m_message;
|
||||
std::string m_message;
|
||||
public:
|
||||
BaseException(string message) : m_message(message) { }
|
||||
virtual ~BaseException() throw () {}
|
||||
virtual const char* what() const throw () {
|
||||
BaseException(std::string message) : m_message(message) { }
|
||||
virtual ~BaseException() noexcept {}
|
||||
virtual const char* what() const noexcept {
|
||||
// return custom message
|
||||
return m_message.c_str();
|
||||
}
|
||||
@@ -59,13 +58,12 @@ namespace openshot {
|
||||
class ChunkNotFound : public BaseException
|
||||
{
|
||||
public:
|
||||
string file_path;
|
||||
int64_t frame_number;
|
||||
int64_t chunk_number;
|
||||
int64_t chunk_frame;
|
||||
ChunkNotFound(string message, int64_t frame_number, int64_t chunk_number, int64_t chunk_frame)
|
||||
ChunkNotFound(std::string message, int64_t frame_number, int64_t chunk_number, int64_t chunk_frame)
|
||||
: BaseException(message), frame_number(frame_number), chunk_number(chunk_number), chunk_frame(chunk_frame) { }
|
||||
virtual ~ChunkNotFound() throw () {}
|
||||
virtual ~ChunkNotFound() noexcept {}
|
||||
};
|
||||
|
||||
|
||||
@@ -73,132 +71,129 @@ namespace openshot {
|
||||
class DecklinkError : public BaseException
|
||||
{
|
||||
public:
|
||||
DecklinkError(string message)
|
||||
DecklinkError(std::string message)
|
||||
: BaseException(message) { }
|
||||
virtual ~DecklinkError() throw () {}
|
||||
virtual ~DecklinkError() noexcept {}
|
||||
};
|
||||
|
||||
/// Exception when decoding audio packet
|
||||
class ErrorDecodingAudio : public BaseException
|
||||
{
|
||||
public:
|
||||
string file_path;
|
||||
int64_t frame_number;
|
||||
ErrorDecodingAudio(string message, int64_t frame_number)
|
||||
ErrorDecodingAudio(std::string message, int64_t frame_number)
|
||||
: BaseException(message), frame_number(frame_number) { }
|
||||
virtual ~ErrorDecodingAudio() throw () {}
|
||||
virtual ~ErrorDecodingAudio() noexcept {}
|
||||
};
|
||||
|
||||
/// Exception when encoding audio packet
|
||||
class ErrorEncodingAudio : public BaseException
|
||||
{
|
||||
public:
|
||||
string file_path;
|
||||
int64_t frame_number;
|
||||
ErrorEncodingAudio(string message, int64_t frame_number)
|
||||
ErrorEncodingAudio(std::string message, int64_t frame_number)
|
||||
: BaseException(message), frame_number(frame_number) { }
|
||||
virtual ~ErrorEncodingAudio() throw () {}
|
||||
virtual ~ErrorEncodingAudio() noexcept {}
|
||||
};
|
||||
|
||||
/// Exception when encoding audio packet
|
||||
class ErrorEncodingVideo : public BaseException
|
||||
{
|
||||
public:
|
||||
string file_path;
|
||||
int64_t frame_number;
|
||||
ErrorEncodingVideo(string message, int64_t frame_number)
|
||||
ErrorEncodingVideo(std::string message, int64_t frame_number)
|
||||
: BaseException(message), frame_number(frame_number) { }
|
||||
virtual ~ErrorEncodingVideo() throw () {}
|
||||
virtual ~ErrorEncodingVideo() noexcept {}
|
||||
};
|
||||
|
||||
/// Exception when an invalid # of audio channels are detected
|
||||
class InvalidChannels : public BaseException
|
||||
{
|
||||
public:
|
||||
string file_path;
|
||||
InvalidChannels(string message, string file_path)
|
||||
std::string file_path;
|
||||
InvalidChannels(std::string message, std::string file_path)
|
||||
: BaseException(message), file_path(file_path) { }
|
||||
virtual ~InvalidChannels() throw () {}
|
||||
virtual ~InvalidChannels() noexcept {}
|
||||
};
|
||||
|
||||
/// Exception when no valid codec is found for a file
|
||||
class InvalidCodec : public BaseException
|
||||
{
|
||||
public:
|
||||
string file_path;
|
||||
InvalidCodec(string message, string file_path)
|
||||
std::string file_path;
|
||||
InvalidCodec(std::string message, std::string file_path)
|
||||
: BaseException(message), file_path(file_path) { }
|
||||
virtual ~InvalidCodec() throw () {}
|
||||
virtual ~InvalidCodec() noexcept {}
|
||||
};
|
||||
|
||||
/// Exception for files that can not be found or opened
|
||||
class InvalidFile : public BaseException
|
||||
{
|
||||
public:
|
||||
string file_path;
|
||||
InvalidFile(string message, string file_path)
|
||||
std::string file_path;
|
||||
InvalidFile(std::string message, std::string file_path)
|
||||
: BaseException(message), file_path(file_path) { }
|
||||
virtual ~InvalidFile() throw () {}
|
||||
virtual ~InvalidFile() noexcept {}
|
||||
};
|
||||
|
||||
/// Exception when no valid format is found for a file
|
||||
class InvalidFormat : public BaseException
|
||||
{
|
||||
public:
|
||||
string file_path;
|
||||
InvalidFormat(string message, string file_path)
|
||||
std::string file_path;
|
||||
InvalidFormat(std::string message, std::string file_path)
|
||||
: BaseException(message), file_path(file_path) { }
|
||||
virtual ~InvalidFormat() throw () {}
|
||||
virtual ~InvalidFormat() noexcept {}
|
||||
};
|
||||
|
||||
/// Exception for invalid JSON
|
||||
class InvalidJSON : public BaseException
|
||||
{
|
||||
public:
|
||||
string file_path;
|
||||
InvalidJSON(string message, string file_path)
|
||||
std::string file_path;
|
||||
InvalidJSON(std::string message, std::string file_path)
|
||||
: BaseException(message), file_path(file_path) { }
|
||||
virtual ~InvalidJSON() throw () {}
|
||||
virtual ~InvalidJSON() noexcept {}
|
||||
};
|
||||
|
||||
/// Exception when invalid encoding options are used
|
||||
class InvalidOptions : public BaseException
|
||||
{
|
||||
public:
|
||||
string file_path;
|
||||
InvalidOptions(string message, string file_path)
|
||||
std::string file_path;
|
||||
InvalidOptions(std::string message, std::string file_path)
|
||||
: BaseException(message), file_path(file_path) { }
|
||||
virtual ~InvalidOptions() throw () {}
|
||||
virtual ~InvalidOptions() noexcept {}
|
||||
};
|
||||
|
||||
/// Exception when invalid sample rate is detected during encoding
|
||||
class InvalidSampleRate : public BaseException
|
||||
{
|
||||
public:
|
||||
string file_path;
|
||||
InvalidSampleRate(string message, string file_path)
|
||||
std::string file_path;
|
||||
InvalidSampleRate(std::string message, std::string file_path)
|
||||
: BaseException(message), file_path(file_path) { }
|
||||
virtual ~InvalidSampleRate() throw () {}
|
||||
virtual ~InvalidSampleRate() noexcept {}
|
||||
};
|
||||
|
||||
/// Exception for missing JSON Change key
|
||||
class InvalidJSONKey : public BaseException
|
||||
{
|
||||
public:
|
||||
string json;
|
||||
InvalidJSONKey(string message, string json)
|
||||
std::string json;
|
||||
InvalidJSONKey(std::string message, std::string json)
|
||||
: BaseException(message), json(json) { }
|
||||
virtual ~InvalidJSONKey() throw () {}
|
||||
virtual ~InvalidJSONKey() noexcept {}
|
||||
};
|
||||
|
||||
/// Exception when no streams are found in the file
|
||||
class NoStreamsFound : public BaseException
|
||||
{
|
||||
public:
|
||||
string file_path;
|
||||
NoStreamsFound(string message, string file_path)
|
||||
std::string file_path;
|
||||
NoStreamsFound(std::string message, std::string file_path)
|
||||
: BaseException(message), file_path(file_path) { }
|
||||
virtual ~NoStreamsFound() throw () {}
|
||||
virtual ~NoStreamsFound() noexcept {}
|
||||
};
|
||||
|
||||
/// Exception for frames that are out of bounds.
|
||||
@@ -207,9 +202,9 @@ namespace openshot {
|
||||
public:
|
||||
int64_t FrameRequested;
|
||||
int64_t MaxFrames;
|
||||
OutOfBoundsFrame(string message, int64_t frame_requested, int64_t max_frames)
|
||||
OutOfBoundsFrame(std::string message, int64_t frame_requested, int64_t max_frames)
|
||||
: BaseException(message), FrameRequested(frame_requested), MaxFrames(max_frames) { }
|
||||
virtual ~OutOfBoundsFrame() throw () {}
|
||||
virtual ~OutOfBoundsFrame() noexcept {}
|
||||
};
|
||||
|
||||
/// Exception for an out of bounds key-frame point.
|
||||
@@ -218,59 +213,59 @@ namespace openshot {
|
||||
public:
|
||||
int PointRequested;
|
||||
int MaxPoints;
|
||||
OutOfBoundsPoint(string message, int point_requested, int max_points)
|
||||
OutOfBoundsPoint(std::string message, int point_requested, int max_points)
|
||||
: BaseException(message), PointRequested(point_requested), MaxPoints(max_points) { }
|
||||
virtual ~OutOfBoundsPoint() throw () {}
|
||||
virtual ~OutOfBoundsPoint() noexcept {}
|
||||
};
|
||||
|
||||
/// Exception when memory could not be allocated
|
||||
class OutOfMemory : public BaseException
|
||||
{
|
||||
public:
|
||||
string file_path;
|
||||
OutOfMemory(string message, string file_path)
|
||||
std::string file_path;
|
||||
OutOfMemory(std::string message, std::string file_path)
|
||||
: BaseException(message), file_path(file_path) { }
|
||||
virtual ~OutOfMemory() throw () {}
|
||||
virtual ~OutOfMemory() noexcept {}
|
||||
};
|
||||
|
||||
/// Exception when a reader is closed, and a frame is requested
|
||||
class ReaderClosed : public BaseException
|
||||
{
|
||||
public:
|
||||
string file_path;
|
||||
ReaderClosed(string message, string file_path)
|
||||
std::string file_path;
|
||||
ReaderClosed(std::string message, std::string file_path)
|
||||
: BaseException(message), file_path(file_path) { }
|
||||
virtual ~ReaderClosed() throw () {}
|
||||
virtual ~ReaderClosed() noexcept {}
|
||||
};
|
||||
|
||||
/// Exception when resample fails
|
||||
class ResampleError : public BaseException
|
||||
{
|
||||
public:
|
||||
string file_path;
|
||||
ResampleError(string message, string file_path)
|
||||
std::string file_path;
|
||||
ResampleError(std::string message, std::string file_path)
|
||||
: BaseException(message), file_path(file_path) { }
|
||||
virtual ~ResampleError() throw () {}
|
||||
virtual ~ResampleError() noexcept {}
|
||||
};
|
||||
|
||||
/// Exception when too many seek attempts happen
|
||||
class TooManySeeks : public BaseException
|
||||
{
|
||||
public:
|
||||
string file_path;
|
||||
TooManySeeks(string message, string file_path)
|
||||
std::string file_path;
|
||||
TooManySeeks(std::string message, std::string file_path)
|
||||
: BaseException(message), file_path(file_path) { }
|
||||
virtual ~TooManySeeks() throw () {}
|
||||
virtual ~TooManySeeks() noexcept {}
|
||||
};
|
||||
|
||||
/// Exception when a writer is closed, and a frame is requested
|
||||
class WriterClosed : public BaseException
|
||||
{
|
||||
public:
|
||||
string file_path;
|
||||
WriterClosed(string message, string file_path)
|
||||
std::string file_path;
|
||||
WriterClosed(std::string message, std::string file_path)
|
||||
: BaseException(message), file_path(file_path) { }
|
||||
virtual ~WriterClosed() throw () {}
|
||||
virtual ~WriterClosed() noexcept {}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user