input/InputStream: add "noexcept"

This commit is contained in:
Max Kellermann 2017-12-26 11:31:05 +01:00
parent 82a79565de
commit daeb7ae949
9 changed files with 34 additions and 33 deletions

View File

@ -21,15 +21,15 @@
#include "IcyInputStream.hxx" #include "IcyInputStream.hxx"
#include "tag/Tag.hxx" #include "tag/Tag.hxx"
IcyInputStream::IcyInputStream(InputStream *_input) IcyInputStream::IcyInputStream(InputStream *_input) noexcept
:ProxyInputStream(_input) :ProxyInputStream(_input)
{ {
} }
IcyInputStream::~IcyInputStream() = default; IcyInputStream::~IcyInputStream() noexcept = default;
void void
IcyInputStream::Update() IcyInputStream::Update() noexcept
{ {
ProxyInputStream::Update(); ProxyInputStream::Update();

View File

@ -47,22 +47,22 @@ class IcyInputStream final : public ProxyInputStream {
offset_type override_offset = 0; offset_type override_offset = 0;
public: public:
IcyInputStream(InputStream *_input); IcyInputStream(InputStream *_input) noexcept;
virtual ~IcyInputStream(); virtual ~IcyInputStream() noexcept;
IcyInputStream(const IcyInputStream &) = delete; IcyInputStream(const IcyInputStream &) = delete;
IcyInputStream &operator=(const IcyInputStream &) = delete; IcyInputStream &operator=(const IcyInputStream &) = delete;
void Enable(size_t _data_size) { void Enable(size_t _data_size) noexcept {
parser.Start(_data_size); parser.Start(_data_size);
} }
bool IsEnabled() const { bool IsEnabled() const noexcept {
return parser.IsDefined(); return parser.IsDefined();
} }
/* virtual methods from InputStream */ /* virtual methods from InputStream */
void Update() override; void Update() noexcept override;
std::unique_ptr<Tag> ReadTag() override; std::unique_ptr<Tag> ReadTag() override;
size_t Read(void *ptr, size_t size) override; size_t Read(void *ptr, size_t size) override;
}; };

View File

@ -69,7 +69,8 @@ input_stream_global_init(EventLoop &event_loop)
} }
} }
void input_stream_global_finish(void) void
input_stream_global_finish() noexcept
{ {
input_plugins_for_each_enabled(plugin) input_plugins_for_each_enabled(plugin)
if (plugin->finish != nullptr) if (plugin->finish != nullptr)

View File

@ -32,6 +32,6 @@ input_stream_global_init(EventLoop &event_loop);
* Deinitializes this library and all #InputStream implementations. * Deinitializes this library and all #InputStream implementations.
*/ */
void void
input_stream_global_finish(); input_stream_global_finish() noexcept;
#endif #endif

View File

@ -27,7 +27,7 @@
#include <assert.h> #include <assert.h>
InputStream::~InputStream() InputStream::~InputStream() noexcept
{ {
} }
@ -37,12 +37,12 @@ InputStream::Check()
} }
void void
InputStream::Update() InputStream::Update() noexcept
{ {
} }
void void
InputStream::SetReady() InputStream::SetReady() noexcept
{ {
assert(!ready); assert(!ready);
@ -51,7 +51,7 @@ InputStream::SetReady()
} }
void void
InputStream::WaitReady() InputStream::WaitReady() noexcept
{ {
while (true) { while (true) {
Update(); Update();
@ -63,7 +63,7 @@ InputStream::WaitReady()
} }
void void
InputStream::LockWaitReady() InputStream::LockWaitReady() noexcept
{ {
const std::lock_guard<Mutex> protect(mutex); const std::lock_guard<Mutex> protect(mutex);
WaitReady(); WaitReady();

View File

@ -107,7 +107,7 @@ public:
* *
* The caller must not lock the mutex. * The caller must not lock the mutex.
*/ */
virtual ~InputStream(); virtual ~InputStream() noexcept;
/** /**
* Opens a new input stream. You may not access it until the "ready" * Opens a new input stream. You may not access it until the "ready"
@ -138,15 +138,15 @@ public:
* *
* No lock necessary for this method. * No lock necessary for this method.
*/ */
const char *GetURI() const { const char *GetURI() const noexcept {
return uri.c_str(); return uri.c_str();
} }
void Lock() { void Lock() noexcept {
mutex.lock(); mutex.lock();
} }
void Unlock() { void Unlock() noexcept {
mutex.unlock(); mutex.unlock();
} }
@ -160,9 +160,9 @@ public:
* Update the public attributes. Call before accessing attributes * Update the public attributes. Call before accessing attributes
* such as "ready" or "offset". * such as "ready" or "offset".
*/ */
virtual void Update(); virtual void Update() noexcept;
void SetReady(); void SetReady() noexcept;
/** /**
* Return whether the stream is ready for reading and whether * Return whether the stream is ready for reading and whether
@ -174,13 +174,13 @@ public:
return ready; return ready;
} }
void WaitReady(); void WaitReady() noexcept;
/** /**
* Wrapper for WaitReady() which locks and unlocks the mutex; * Wrapper for WaitReady() which locks and unlocks the mutex;
* the caller must not be holding it already. * the caller must not be holding it already.
*/ */
void LockWaitReady(); void LockWaitReady() noexcept;
gcc_pure gcc_pure
bool HasMimeType() const noexcept { bool HasMimeType() const noexcept {
@ -201,13 +201,13 @@ public:
} }
gcc_nonnull_all gcc_nonnull_all
void SetMimeType(const char *_mime) { void SetMimeType(const char *_mime) noexcept {
assert(!ready); assert(!ready);
mime = _mime; mime = _mime;
} }
void SetMimeType(std::string &&_mime) { void SetMimeType(std::string &&_mime) noexcept {
assert(!ready); assert(!ready);
mime = std::move(_mime); mime = std::move(_mime);

View File

@ -21,11 +21,11 @@
#include "ProxyInputStream.hxx" #include "ProxyInputStream.hxx"
#include "tag/Tag.hxx" #include "tag/Tag.hxx"
ProxyInputStream::ProxyInputStream(InputStream *_input) ProxyInputStream::ProxyInputStream(InputStream *_input) noexcept
:InputStream(_input->GetURI(), _input->mutex, _input->cond), :InputStream(_input->GetURI(), _input->mutex, _input->cond),
input(*_input) {} input(*_input) {}
ProxyInputStream::~ProxyInputStream() ProxyInputStream::~ProxyInputStream() noexcept
{ {
delete &input; delete &input;
} }
@ -57,7 +57,7 @@ ProxyInputStream::Check()
} }
void void
ProxyInputStream::Update() ProxyInputStream::Update() noexcept
{ {
input.Update(); input.Update();
CopyAttributes(); CopyAttributes();

View File

@ -35,16 +35,16 @@ protected:
public: public:
gcc_nonnull_all gcc_nonnull_all
ProxyInputStream(InputStream *_input); ProxyInputStream(InputStream *_input) noexcept;
virtual ~ProxyInputStream(); virtual ~ProxyInputStream() noexcept;
ProxyInputStream(const ProxyInputStream &) = delete; ProxyInputStream(const ProxyInputStream &) = delete;
ProxyInputStream &operator=(const ProxyInputStream &) = delete; ProxyInputStream &operator=(const ProxyInputStream &) = delete;
/* virtual methods from InputStream */ /* virtual methods from InputStream */
void Check() override; void Check() override;
void Update() override; void Update() noexcept override;
void Seek(offset_type new_offset) override; void Seek(offset_type new_offset) override;
bool IsEOF() noexcept override; bool IsEOF() noexcept override;
std::unique_ptr<Tag> ReadTag() override; std::unique_ptr<Tag> ReadTag() override;

View File

@ -53,7 +53,7 @@ public:
/* virtual methods from InputStream */ /* virtual methods from InputStream */
void Update() override { void Update() noexcept override {
if (!ReadingFromBuffer()) if (!ReadingFromBuffer())
ProxyInputStream::Update(); ProxyInputStream::Update();
} }
@ -70,7 +70,7 @@ private:
* Are we currently reading from the buffer, and does the * Are we currently reading from the buffer, and does the
* buffer contain more data for the next read operation? * buffer contain more data for the next read operation?
*/ */
bool ReadingFromBuffer() const { bool ReadingFromBuffer() const noexcept {
return tail > 0 && offset < input.GetOffset(); return tail > 0 && offset < input.GetOffset();
} }
}; };