Tag Parser: id3/id3genres.h Source File

Tag Parser 12.5.3 C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags

Loading...
Searching...
No Matches
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_view>
8
9namespace TagParser {
10
11 class TAG_PARSER_EXPORT Id3Genres {
12public:
13 static inline std::string_view stringFromIndex(int index);
14 static int indexFromString(std::string_view 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
20private:
21 static const std::string_view *genreNames();
22};
23
27 inline std::string_view Id3Genres::stringFromIndex(int index)
28{
29 return isIndexSupported(index) ? genreNames()[index] : std::string_view();
30}
31
35 constexpr int Id3Genres::genreCount()
36{
37 return 192;
38}
39
45 constexpr int Id3Genres::emptyGenreIndex()
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 vice versa.
Definition id3genres.h:11
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::isIndexSupported
static constexpr bool isIndexSupported(int index)
Returns an indication whether the specified numerical denotation is supported by this class.
Definition id3genres.h:62
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::genreCount
static constexpr int genreCount()
Returns the number of supported genres.
Definition id3genres.h:35
TagParser::Id3Genres::indexFromString
static int indexFromString(std::string_view genre)
Returns the numerical denotation of the specified genre or -1 if genre is unknown.
Definition id3genres.cpp:42
TagParser::Id3Genres::stringFromIndex
static std::string_view stringFromIndex(int index)
Returns the genre name for the specified numerical denotation.
Definition id3genres.h:27
global.h
TAG_PARSER_EXPORT
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
Definition global.h:14
TagParser
Contains all classes and functions of the TagInfo library.
Definition aaccodebook.h:10