Tag Parser  8.2.0
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 <c++utilities/conversion/types.h>
7 
8 #include <string>
9 
10 namespace TagParser {
11 
13 public:
14  static inline const char *stringFromIndex(int index);
15  static int indexFromString(const std::string &genre);
16  static constexpr int genreCount();
17  static constexpr int emptyGenreIndex();
18  static constexpr bool isEmptyGenre(int index);
19  static constexpr bool isIndexSupported(int index);
20 
21 private:
22  static const char **genreNames();
23 };
24 
28 inline const char *Id3Genres::stringFromIndex(int index)
29 {
30  return isIndexSupported(index) ? genreNames()[index] : nullptr;
31 }
32 
36 constexpr int Id3Genres::genreCount()
37 {
38  return 192;
39 }
40 
47 {
48  return 255;
49 }
50 
54 constexpr bool Id3Genres::isEmptyGenre(int index)
55 {
56  return index == emptyGenreIndex();
57 }
58 
63 constexpr bool Id3Genres::isIndexSupported(int index)
64 {
65  return index >= 0 && index < genreCount();
66 }
67 
68 } // namespace TagParser
69 
70 #endif // TAG_PARSER_ID3GENRES_H
static const char * stringFromIndex(int index)
Returns the genre name for the specified numerical denotation as C-style string.
Definition: id3genres.h:28
static constexpr int genreCount()
Returns the number of supported genres.
Definition: id3genres.h:36
static constexpr int emptyGenreIndex()
Returns the preferred genre index to indicate that no genre is set at all.
Definition: id3genres.h:46
constexpr TAG_PARSER_EXPORT const char * genre()
The Id3Genres class converts pre-defined ID3 genres to strings and vise versa.
Definition: id3genres.h:12
static constexpr bool isEmptyGenre(int index)
Returns whether the genre index indicates the genre field is not set at all.
Definition: id3genres.h:54
static constexpr bool isIndexSupported(int index)
Returns an indication whether the specified numerical denotation is supported by this class.
Definition: id3genres.h:63
Contains all classes and functions of the TagInfo library.
Definition: aaccodebook.h:9
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.