IcyMetaDataParser: add "noexcept"
This commit is contained in:
@@ -31,7 +31,7 @@
|
|||||||
static constexpr Domain icy_metadata_domain("icy_metadata");
|
static constexpr Domain icy_metadata_domain("icy_metadata");
|
||||||
|
|
||||||
void
|
void
|
||||||
IcyMetaDataParser::Reset()
|
IcyMetaDataParser::Reset() noexcept
|
||||||
{
|
{
|
||||||
if (!IsDefined())
|
if (!IsDefined())
|
||||||
return;
|
return;
|
||||||
@@ -46,7 +46,7 @@ IcyMetaDataParser::Reset()
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
IcyMetaDataParser::Data(size_t length)
|
IcyMetaDataParser::Data(size_t length) noexcept
|
||||||
{
|
{
|
||||||
assert(length > 0);
|
assert(length > 0);
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ IcyMetaDataParser::Data(size_t length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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);
|
size_t length = strlen(value);
|
||||||
|
|
||||||
@@ -81,7 +81,8 @@ icy_add_item(TagBuilder &tag, TagType type, const char *value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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)
|
if (strcmp(name, "StreamTitle") == 0)
|
||||||
icy_add_item(tag, TAG_TITLE, value);
|
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.
|
* that also fails, return #end.
|
||||||
*/
|
*/
|
||||||
static char *
|
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, '\'');
|
char *fallback = std::find(p, end, '\'');
|
||||||
if (fallback >= end - 1 || fallback[1] == ';')
|
if (fallback >= end - 1 || fallback[1] == ';')
|
||||||
@@ -116,7 +117,7 @@ find_end_quote(char *p, char *const end)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static std::unique_ptr<Tag>
|
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(p != nullptr);
|
||||||
assert(end != nullptr);
|
assert(end != nullptr);
|
||||||
@@ -165,7 +166,7 @@ icy_parse_tag(char *p, char *const end)
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
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;
|
const unsigned char *p = (const unsigned char *)data;
|
||||||
|
|
||||||
@@ -223,7 +224,7 @@ IcyMetaDataParser::Meta(const void *data, size_t length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
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 *const dest0 = (uint8_t *)data;
|
||||||
uint8_t *dest = dest0;
|
uint8_t *dest = dest0;
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
struct Tag;
|
struct Tag;
|
||||||
|
|
||||||
class IcyMetaDataParser {
|
class IcyMetaDataParser {
|
||||||
size_t data_size, data_rest;
|
size_t data_size = 0, data_rest;
|
||||||
|
|
||||||
size_t meta_size, meta_position;
|
size_t meta_size, meta_position;
|
||||||
char *meta_data;
|
char *meta_data;
|
||||||
@@ -33,8 +33,7 @@ class IcyMetaDataParser {
|
|||||||
Tag *tag;
|
Tag *tag;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IcyMetaDataParser():data_size(0) {}
|
~IcyMetaDataParser() noexcept {
|
||||||
~IcyMetaDataParser() {
|
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,7 +41,7 @@ public:
|
|||||||
* Initialize an enabled icy_metadata object with the specified
|
* Initialize an enabled icy_metadata object with the specified
|
||||||
* data_size (from the icy-metaint HTTP response header).
|
* 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;
|
data_size = data_rest = _data_size;
|
||||||
meta_size = 0;
|
meta_size = 0;
|
||||||
tag = nullptr;
|
tag = nullptr;
|
||||||
@@ -51,12 +50,12 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Resets the icy_metadata. Call this after rewinding the stream.
|
* Resets the icy_metadata. Call this after rewinding the stream.
|
||||||
*/
|
*/
|
||||||
void Reset();
|
void Reset() noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the icy_metadata object is enabled.
|
* Checks whether the icy_metadata object is enabled.
|
||||||
*/
|
*/
|
||||||
bool IsDefined() const {
|
bool IsDefined() const noexcept {
|
||||||
return data_size > 0;
|
return data_size > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,23 +65,23 @@ public:
|
|||||||
* return value is smaller than "length", the caller should invoke
|
* return value is smaller than "length", the caller should invoke
|
||||||
* icy_meta().
|
* 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
|
* Reads metadata from the stream. Returns the number of bytes
|
||||||
* consumed. If the return value is smaller than "length", the caller
|
* consumed. If the return value is smaller than "length", the caller
|
||||||
* should invoke icy_data().
|
* 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.
|
* Parse data and eliminate metadata.
|
||||||
*
|
*
|
||||||
* @return the number of data bytes remaining in the buffer
|
* @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 *result = tag;
|
||||||
tag = nullptr;
|
tag = nullptr;
|
||||||
return result;
|
return result;
|
||||||
|
Reference in New Issue
Block a user