Tag Parser  9.1.3
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
id3genres.h
Go to the documentation of this file.
1 #ifndef TAG_PARSER_ID3GENRES_H
2 #define TAG_PARSER_ID3GENRES_H
3 
4 #include "../global.h"
5 
6 #include <cstdint>
7 #include <string>
8 
9 namespace TagParser {
10 
12 public:
13  static inline const char *stringFromIndex(int index);
14  static int indexFromString(const std::string &genre);
15  static constexpr int genreCount();
16  static constexpr int emptyGenreIndex();
17  static constexpr bool isEmptyGenre(int index);
18  static constexpr bool isIndexSupported(int index);
19 
20 private:
21  static const char *const *genreNames();
22 };
23 
27 inline const char *Id3Genres::stringFromIndex(int index)
28 {
29  return isIndexSupported(index) ? genreNames()[index] : nullptr;
30 }
31 
35 constexpr int Id3Genres::genreCount()
36 {
37  return 192;
38 }
39 
46 {
47  return 255;
48 }
49 
53 constexpr bool Id3Genres::isEmptyGenre(int index)
54 {
55  return index == emptyGenreIndex();
56 }
57 
62 constexpr bool Id3Genres::isIndexSupported(int index)
63 {
64  return index >= 0 && index < genreCount();
65 }
66 
67 } // namespace TagParser
68 
69 #endif // TAG_PARSER_ID3GENRES_H
TagParser::Id3Genres
The Id3Genres class converts pre-defined ID3 genres to strings and vise versa.
Definition: id3genres.h:11
TagParser
Contains all classes and functions of the TagInfo library.
Definition: aaccodebook.h:10
TagParser::MatroskaTagIds::genre
constexpr const TAG_PARSER_EXPORT char * genre()
Definition: matroskatagid.h:214
TagParser::Id3Genres::emptyGenreIndex
static constexpr int emptyGenreIndex()
Returns the preferred genre index to indicate that no genre is set at all.
Definition: id3genres.h:45
TagParser::Id3Genres::isEmptyGenre
static constexpr bool isEmptyGenre(int index)
Returns whether the genre index indicates the genre field is not set at all.
Definition: id3genres.h:53
TagParser::Id3Genres::genreCount
static constexpr int genreCount()
Returns the number of supported genres.
Definition: id3genres.h:35
TagParser::Id3Genres::isIndexSupported
static constexpr bool isIndexSupported(int index)
Returns an indication whether the specified numerical denotation is supported by this class.
Definition: id3genres.h:62
TAG_PARSER_EXPORT
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
TagParser::Id3Genres::stringFromIndex
static const char * stringFromIndex(int index)
Returns the genre name for the specified numerical denotation as C-style string.
Definition: id3genres.h:27