2018-03-06 23:09:15 +01:00
|
|
|
#ifndef TAG_PARSER_ID3GENRES_H
|
|
|
|
#define TAG_PARSER_ID3GENRES_H
|
2015-04-22 19:22:01 +02:00
|
|
|
|
2016-08-29 15:43:05 +02:00
|
|
|
#include "../global.h"
|
|
|
|
|
2019-03-13 19:06:42 +01:00
|
|
|
#include <cstdint>
|
2021-01-30 21:53:06 +01:00
|
|
|
#include <string_view>
|
2015-04-22 19:22:01 +02:00
|
|
|
|
2018-03-07 01:17:50 +01:00
|
|
|
namespace TagParser {
|
2015-04-22 19:22:01 +02:00
|
|
|
|
2018-03-07 01:17:50 +01:00
|
|
|
class TAG_PARSER_EXPORT Id3Genres {
|
2015-04-22 19:22:01 +02:00
|
|
|
public:
|
2021-01-30 21:53:06 +01:00
|
|
|
static inline std::string_view stringFromIndex(int index);
|
|
|
|
static int indexFromString(std::string_view genre);
|
2016-02-23 20:33:00 +01:00
|
|
|
static constexpr int genreCount();
|
2019-02-13 18:06:02 +01:00
|
|
|
static constexpr int emptyGenreIndex();
|
|
|
|
static constexpr bool isEmptyGenre(int index);
|
2016-02-23 20:33:00 +01:00
|
|
|
static constexpr bool isIndexSupported(int index);
|
2015-04-22 19:22:01 +02:00
|
|
|
|
|
|
|
private:
|
2021-01-30 21:53:06 +01:00
|
|
|
static const std::string_view *genreNames();
|
2015-04-22 19:22:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns the genre name for the specified numerical denotation as C-style string.
|
|
|
|
*/
|
2021-01-30 21:53:06 +01:00
|
|
|
inline std::string_view Id3Genres::stringFromIndex(int index)
|
2015-04-22 19:22:01 +02:00
|
|
|
{
|
2021-01-30 21:53:06 +01:00
|
|
|
return isIndexSupported(index) ? genreNames()[index] : std::string_view();
|
2015-04-22 19:22:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
2016-02-23 20:33:00 +01:00
|
|
|
* \brief Returns the number of supported genres.
|
2015-04-22 19:22:01 +02:00
|
|
|
*/
|
2016-02-23 20:33:00 +01:00
|
|
|
constexpr int Id3Genres::genreCount()
|
2015-04-22 19:22:01 +02:00
|
|
|
{
|
2016-02-23 20:33:00 +01:00
|
|
|
return 192;
|
2015-04-22 19:22:01 +02:00
|
|
|
}
|
|
|
|
|
2019-02-13 18:06:02 +01:00
|
|
|
/*!
|
|
|
|
* \brief Returns the preferred genre index to indicate that no genre is set at all.
|
|
|
|
* \remarks Apparently some files use 255 to indicate the genre information is missing although this
|
2021-07-02 03:00:50 +02:00
|
|
|
* is not explicitly specified on [ID3.org](http://id3.org/ID3v1).
|
2019-02-13 18:06:02 +01:00
|
|
|
*/
|
|
|
|
constexpr int Id3Genres::emptyGenreIndex()
|
|
|
|
{
|
|
|
|
return 255;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns whether the genre \a index indicates the genre field is not set at all.
|
|
|
|
*/
|
|
|
|
constexpr bool Id3Genres::isEmptyGenre(int index)
|
|
|
|
{
|
|
|
|
return index == emptyGenreIndex();
|
|
|
|
}
|
|
|
|
|
2015-04-22 19:22:01 +02:00
|
|
|
/*!
|
2016-02-23 20:33:00 +01:00
|
|
|
* \brief Returns an indication whether the specified numerical denotation is
|
|
|
|
* supported by this class.
|
2015-04-22 19:22:01 +02:00
|
|
|
*/
|
2016-02-23 20:33:00 +01:00
|
|
|
constexpr bool Id3Genres::isIndexSupported(int index)
|
2015-04-22 19:22:01 +02:00
|
|
|
{
|
2016-02-23 20:33:00 +01:00
|
|
|
return index >= 0 && index < genreCount();
|
2015-04-22 19:22:01 +02:00
|
|
|
}
|
|
|
|
|
2018-03-07 01:17:50 +01:00
|
|
|
} // namespace TagParser
|
2015-04-22 19:22:01 +02:00
|
|
|
|
2018-03-06 23:09:15 +01:00
|
|
|
#endif // TAG_PARSER_ID3GENRES_H
|