IcyMetaDataParser: add "noexcept"

This commit is contained in:
Max Kellermann 2017-12-20 15:05:14 +01:00
parent 25fa3ccade
commit 6b77ee9a5e
2 changed files with 18 additions and 18 deletions

View File

@ -31,7 +31,7 @@
static constexpr Domain icy_metadata_domain("icy_metadata");
void
IcyMetaDataParser::Reset()
IcyMetaDataParser::Reset() noexcept
{
if (!IsDefined())
return;
@ -46,7 +46,7 @@ IcyMetaDataParser::Reset()
}
size_t
IcyMetaDataParser::Data(size_t length)
IcyMetaDataParser::Data(size_t length) noexcept
{
assert(length > 0);
@ -66,7 +66,7 @@ IcyMetaDataParser::Data(size_t length)
}
static void
icy_add_item(TagBuilder &tag, TagType type, const char *value)
icy_add_item(TagBuilder &tag, TagType type, const char *value) noexcept
{
size_t length = strlen(value);
@ -81,7 +81,8 @@ icy_add_item(TagBuilder &tag, TagType type, const char *value)
}
static void
icy_parse_tag_item(TagBuilder &tag, const char *name, const char *value)
icy_parse_tag_item(TagBuilder &tag,
const char *name, const char *value) noexcept
{
if (strcmp(name, "StreamTitle") == 0)
icy_add_item(tag, TAG_TITLE, value);
@ -96,7 +97,7 @@ icy_parse_tag_item(TagBuilder &tag, const char *name, const char *value)
* that also fails, return #end.
*/
static char *
find_end_quote(char *p, char *const end)
find_end_quote(char *p, char *const end) noexcept
{
char *fallback = std::find(p, end, '\'');
if (fallback >= end - 1 || fallback[1] == ';')
@ -116,7 +117,7 @@ find_end_quote(char *p, char *const end)
}
static std::unique_ptr<Tag>
icy_parse_tag(char *p, char *const end)
icy_parse_tag(char *p, char *const end) noexcept
{
assert(p != nullptr);
assert(end != nullptr);
@ -165,7 +166,7 @@ icy_parse_tag(char *p, char *const end)
}
size_t
IcyMetaDataParser::Meta(const void *data, size_t length)
IcyMetaDataParser::Meta(const void *data, size_t length) noexcept
{
const unsigned char *p = (const unsigned char *)data;
@ -223,7 +224,7 @@ IcyMetaDataParser::Meta(const void *data, size_t length)
}
size_t
IcyMetaDataParser::ParseInPlace(void *data, size_t length)
IcyMetaDataParser::ParseInPlace(void *data, size_t length) noexcept
{
uint8_t *const dest0 = (uint8_t *)data;
uint8_t *dest = dest0;

View File

@ -25,7 +25,7 @@
struct Tag;
class IcyMetaDataParser {
size_t data_size, data_rest;
size_t data_size = 0, data_rest;
size_t meta_size, meta_position;
char *meta_data;
@ -33,8 +33,7 @@ class IcyMetaDataParser {
Tag *tag;
public:
IcyMetaDataParser():data_size(0) {}
~IcyMetaDataParser() {
~IcyMetaDataParser() noexcept {
Reset();
}
@ -42,7 +41,7 @@ public:
* Initialize an enabled icy_metadata object with the specified
* data_size (from the icy-metaint HTTP response header).
*/
void Start(size_t _data_size) {
void Start(size_t _data_size) noexcept {
data_size = data_rest = _data_size;
meta_size = 0;
tag = nullptr;
@ -51,12 +50,12 @@ public:
/**
* Resets the icy_metadata. Call this after rewinding the stream.
*/
void Reset();
void Reset() noexcept;
/**
* Checks whether the icy_metadata object is enabled.
*/
bool IsDefined() const {
bool IsDefined() const noexcept {
return data_size > 0;
}
@ -66,23 +65,23 @@ public:
* return value is smaller than "length", the caller should invoke
* icy_meta().
*/
size_t Data(size_t length);
size_t Data(size_t length) noexcept;
/**
* Reads metadata from the stream. Returns the number of bytes
* consumed. If the return value is smaller than "length", the caller
* should invoke icy_data().
*/
size_t Meta(const void *data, size_t length);
size_t Meta(const void *data, size_t length) noexcept;
/**
* Parse data and eliminate metadata.
*
* @return the number of data bytes remaining in the buffer
*/
size_t ParseInPlace(void *data, size_t length);
size_t ParseInPlace(void *data, size_t length) noexcept;
Tag *ReadTag() {
Tag *ReadTag() noexcept {
Tag *result = tag;
tag = nullptr;
return result;