tagparser/id3/id3genres.h

51 lines
1.1 KiB
C
Raw Normal View History

#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"
2015-04-22 19:22:01 +02:00
#include <c++utilities/conversion/types.h>
#include <string>
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:
2018-07-10 14:11:11 +02:00
static inline const char *stringFromIndex(int index);
2015-04-22 19:22:01 +02:00
static int indexFromString(const std::string &genre);
2016-02-23 20:33:00 +01:00
static constexpr int genreCount();
static constexpr bool isIndexSupported(int index);
2015-04-22 19:22:01 +02:00
private:
static const char **genreNames();
};
/*!
* \brief Returns the genre name for the specified numerical denotation as C-style string.
*/
inline const char *Id3Genres::stringFromIndex(int index)
{
return isIndexSupported(index) ? genreNames()[index] : nullptr;
}
/*!
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
}
/*!
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
#endif // TAG_PARSER_ID3GENRES_H