tag/Builder: add "noexcept"

This commit is contained in:
Max Kellermann 2018-01-20 19:41:25 +01:00
parent ea8642dec9
commit f686e838fe
2 changed files with 32 additions and 32 deletions

View File

@ -31,7 +31,7 @@
#include <assert.h>
#include <stdlib.h>
TagBuilder::TagBuilder(const Tag &other)
TagBuilder::TagBuilder(const Tag &other) noexcept
:duration(other.duration), has_playlist(other.has_playlist)
{
items.reserve(other.num_items);
@ -42,7 +42,7 @@ TagBuilder::TagBuilder(const Tag &other)
tag_pool_lock.unlock();
}
TagBuilder::TagBuilder(Tag &&other)
TagBuilder::TagBuilder(Tag &&other) noexcept
:duration(other.duration), has_playlist(other.has_playlist)
{
/* move all TagItem pointers from the Tag object; we don't
@ -58,7 +58,7 @@ TagBuilder::TagBuilder(Tag &&other)
}
TagBuilder &
TagBuilder::operator=(const TagBuilder &other)
TagBuilder::operator=(const TagBuilder &other) noexcept
{
/* copy all attributes */
duration = other.duration;
@ -75,7 +75,7 @@ TagBuilder::operator=(const TagBuilder &other)
}
TagBuilder &
TagBuilder::operator=(TagBuilder &&other)
TagBuilder::operator=(TagBuilder &&other) noexcept
{
duration = other.duration;
has_playlist = other.has_playlist;
@ -85,7 +85,7 @@ TagBuilder::operator=(TagBuilder &&other)
}
TagBuilder &
TagBuilder::operator=(Tag &&other)
TagBuilder::operator=(Tag &&other) noexcept
{
duration = other.duration;
has_playlist = other.has_playlist;
@ -106,7 +106,7 @@ TagBuilder::operator=(Tag &&other)
}
void
TagBuilder::Clear()
TagBuilder::Clear() noexcept
{
duration = SignedSongTime::Negative();
has_playlist = false;
@ -114,7 +114,7 @@ TagBuilder::Clear()
}
void
TagBuilder::Commit(Tag &tag)
TagBuilder::Commit(Tag &tag) noexcept
{
tag.Clear();
@ -137,7 +137,7 @@ TagBuilder::Commit(Tag &tag)
}
Tag
TagBuilder::Commit()
TagBuilder::Commit() noexcept
{
Tag tag;
Commit(tag);
@ -145,7 +145,7 @@ TagBuilder::Commit()
}
std::unique_ptr<Tag>
TagBuilder::CommitNew()
TagBuilder::CommitNew() noexcept
{
std::unique_ptr<Tag> tag(new Tag());
Commit(*tag);
@ -163,7 +163,7 @@ TagBuilder::HasType(TagType type) const noexcept
}
void
TagBuilder::Complement(const Tag &other)
TagBuilder::Complement(const Tag &other) noexcept
{
if (duration.IsNegative())
duration = other.duration;
@ -189,7 +189,7 @@ TagBuilder::Complement(const Tag &other)
}
inline void
TagBuilder::AddItemInternal(TagType type, StringView value)
TagBuilder::AddItemInternal(TagType type, StringView value) noexcept
{
assert(!value.empty());
@ -207,7 +207,7 @@ TagBuilder::AddItemInternal(TagType type, StringView value)
}
void
TagBuilder::AddItem(TagType type, StringView value)
TagBuilder::AddItem(TagType type, StringView value) noexcept
{
if (value.empty() || !IsTagEnabled(type))
return;
@ -216,7 +216,7 @@ TagBuilder::AddItem(TagType type, StringView value)
}
void
TagBuilder::AddItem(TagType type, const char *value)
TagBuilder::AddItem(TagType type, const char *value) noexcept
{
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
@ -227,7 +227,7 @@ TagBuilder::AddItem(TagType type, const char *value)
}
void
TagBuilder::AddEmptyItem(TagType type)
TagBuilder::AddEmptyItem(TagType type) noexcept
{
tag_pool_lock.lock();
auto i = tag_pool_get_item(type, "");

View File

@ -56,19 +56,19 @@ public:
*/
TagBuilder() = default;
~TagBuilder() {
~TagBuilder() noexcept {
Clear();
}
TagBuilder(const TagBuilder &other) = delete;
explicit TagBuilder(const Tag &other);
explicit TagBuilder(Tag &&other);
explicit TagBuilder(const Tag &other) noexcept;
explicit TagBuilder(Tag &&other) noexcept;
TagBuilder &operator=(const TagBuilder &other);
TagBuilder &operator=(TagBuilder &&other);
TagBuilder &operator=(const TagBuilder &other) noexcept;
TagBuilder &operator=(TagBuilder &&other) noexcept;
TagBuilder &operator=(Tag &&other);
TagBuilder &operator=(Tag &&other) noexcept;
/**
* Returns true if the tag contains no items. This ignores
@ -86,36 +86,36 @@ public:
return !duration.IsNegative() || has_playlist || !empty();
}
void Clear();
void Clear() noexcept;
/**
* Move this object to the given #Tag instance. This object
* is empty afterwards.
*/
void Commit(Tag &tag);
void Commit(Tag &tag) noexcept;
/**
* Create a new #Tag instance from data in this object. This
* object is empty afterwards.
*/
Tag Commit();
Tag Commit() noexcept;
/**
* Create a new #Tag instance from data in this object. The
* returned object is owned by the caller. This object is
* empty afterwards.
*/
std::unique_ptr<Tag> CommitNew();
std::unique_ptr<Tag> CommitNew() noexcept;
void SetDuration(SignedSongTime _duration) {
void SetDuration(SignedSongTime _duration) noexcept {
duration = _duration;
}
void SetHasPlaylist(bool _has_playlist) {
void SetHasPlaylist(bool _has_playlist) noexcept {
has_playlist = _has_playlist;
}
void Reserve(unsigned n) {
void Reserve(unsigned n) noexcept {
items.reserve(n);
}
@ -130,7 +130,7 @@ public:
* Copy attributes and items from the other object that do not
* exist in this object.
*/
void Complement(const Tag &other);
void Complement(const Tag &other) noexcept;
/**
* Appends a new tag item.
@ -140,7 +140,7 @@ public:
* @param length the length of #value
*/
gcc_nonnull_all
void AddItem(TagType type, StringView value);
void AddItem(TagType type, StringView value) noexcept;
/**
* Appends a new tag item.
@ -149,14 +149,14 @@ public:
* @param value the value of the tag item (null-terminated)
*/
gcc_nonnull_all
void AddItem(TagType type, const char *value);
void AddItem(TagType type, const char *value) noexcept;
/**
* Appends a new tag item with an empty value. Do not use
* this unless you know what you're doing - because usually,
* empty values are discarded.
*/
void AddEmptyItem(TagType type);
void AddEmptyItem(TagType type) noexcept;
/**
* Removes all tag items.
@ -170,7 +170,7 @@ public:
private:
gcc_nonnull_all
void AddItemInternal(TagType type, StringView value);
void AddItemInternal(TagType type, StringView value) noexcept;
};
#endif