tag/Names: convert to C++
This commit is contained in:
parent
148aca23be
commit
a302d34f6d
|
@ -2,6 +2,7 @@
|
|||
// Copyright The Music Player Daemon Project
|
||||
|
||||
#include "TagPrint.hxx"
|
||||
#include "tag/Names.hxx"
|
||||
#include "tag/Tag.hxx"
|
||||
#include "tag/Settings.hxx"
|
||||
#include "client/Response.hxx"
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Copyright The Music Player Daemon Project
|
||||
|
||||
#include "TagSave.hxx"
|
||||
#include "tag/Names.hxx"
|
||||
#include "tag/Tag.hxx"
|
||||
#include "io/BufferedOutputStream.hxx"
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "protocol/RangeArg.hxx"
|
||||
#include "client/Client.hxx"
|
||||
#include "client/Response.hxx"
|
||||
#include "tag/Names.hxx"
|
||||
#include "tag/ParseName.hxx"
|
||||
#include "util/Exception.hxx"
|
||||
#include "util/StringAPI.hxx"
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "client/Response.hxx"
|
||||
#include "Partition.hxx"
|
||||
#include "song/LightSong.hxx"
|
||||
#include "tag/Names.hxx"
|
||||
#include "tag/Tag.hxx"
|
||||
#include "LightDirectory.hxx"
|
||||
#include "PlaylistInfo.hxx"
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "lib/fmt/RuntimeError.hxx"
|
||||
#include "io/BufferedOutputStream.hxx"
|
||||
#include "io/LineReader.hxx"
|
||||
#include "tag/Names.hxx"
|
||||
#include "tag/ParseName.hxx"
|
||||
#include "tag/Settings.hxx"
|
||||
#include "fs/Charset.hxx"
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#define __STDC_CONSTANT_MACROS
|
||||
|
||||
#include "FfmpegMetaData.hxx"
|
||||
#include "tag/Names.hxx"
|
||||
#include "tag/Table.hxx"
|
||||
#include "tag/Handler.hxx"
|
||||
#include "tag/Id3MusicBrainz.hxx"
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "FlacEncoderPlugin.hxx"
|
||||
#include "../EncoderAPI.hxx"
|
||||
#include "tag/Names.hxx"
|
||||
#include "pcm/AudioFormat.hxx"
|
||||
#include "pcm/Buffer.hxx"
|
||||
#include "lib/fmt/RuntimeError.hxx"
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "OpusEncoderPlugin.hxx"
|
||||
#include "OggEncoder.hxx"
|
||||
#include "tag/Names.hxx"
|
||||
#include "pcm/AudioFormat.hxx"
|
||||
#include "util/ByteOrder.hxx"
|
||||
#include "util/StringUtil.hxx"
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "OggEncoder.hxx"
|
||||
#include "lib/fmt/RuntimeError.hxx"
|
||||
#include "lib/xiph/VorbisComment.hxx"
|
||||
#include "tag/Names.hxx"
|
||||
#include "pcm/AudioFormat.hxx"
|
||||
#include "config/Domain.hxx"
|
||||
#include "util/StringUtil.hxx"
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "ScanVorbisComment.hxx"
|
||||
#include "XiphTags.hxx"
|
||||
#include "tag/Names.hxx"
|
||||
#include "tag/Table.hxx"
|
||||
#include "tag/Handler.hxx"
|
||||
#include "tag/VorbisComment.hxx"
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "TagSongFilter.hxx"
|
||||
#include "Escape.hxx"
|
||||
#include "LightSong.hxx"
|
||||
#include "tag/Names.hxx"
|
||||
#include "tag/Tag.hxx"
|
||||
#include "tag/Fallback.hxx"
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
// Copyright The Music Player Daemon Project
|
||||
|
||||
#include "Type.h"
|
||||
#include "Names.hxx"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <map>
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
// Copyright The Music Player Daemon Project
|
||||
|
||||
#include "Type.h"
|
||||
|
||||
const char *const tag_item_names[TAG_NUM_OF_ITEM_TYPES] = {
|
||||
[TAG_ARTIST] = "Artist",
|
||||
[TAG_ARTIST_SORT] = "ArtistSort",
|
||||
[TAG_ALBUM] = "Album",
|
||||
[TAG_ALBUM_SORT] = "AlbumSort",
|
||||
[TAG_ALBUM_ARTIST] = "AlbumArtist",
|
||||
[TAG_ALBUM_ARTIST_SORT] = "AlbumArtistSort",
|
||||
[TAG_TITLE] = "Title",
|
||||
[TAG_TITLE_SORT] = "TitleSort",
|
||||
[TAG_TRACK] = "Track",
|
||||
[TAG_NAME] = "Name",
|
||||
[TAG_GENRE] = "Genre",
|
||||
[TAG_MOOD] = "Mood",
|
||||
[TAG_DATE] = "Date",
|
||||
[TAG_ORIGINAL_DATE] = "OriginalDate",
|
||||
[TAG_COMPOSER] = "Composer",
|
||||
[TAG_COMPOSERSORT] = "ComposerSort",
|
||||
[TAG_PERFORMER] = "Performer",
|
||||
[TAG_CONDUCTOR] = "Conductor",
|
||||
[TAG_WORK] = "Work",
|
||||
[TAG_MOVEMENT] = "Movement",
|
||||
[TAG_MOVEMENTNUMBER] = "MovementNumber",
|
||||
[TAG_ENSEMBLE] = "Ensemble",
|
||||
[TAG_LOCATION] = "Location",
|
||||
[TAG_GROUPING] = "Grouping",
|
||||
[TAG_COMMENT] = "Comment",
|
||||
[TAG_DISC] = "Disc",
|
||||
[TAG_LABEL] = "Label",
|
||||
|
||||
/* MusicBrainz tags from http://musicbrainz.org/doc/MusicBrainzTag */
|
||||
[TAG_MUSICBRAINZ_ARTISTID] = "MUSICBRAINZ_ARTISTID",
|
||||
[TAG_MUSICBRAINZ_ALBUMID] = "MUSICBRAINZ_ALBUMID",
|
||||
[TAG_MUSICBRAINZ_ALBUMARTISTID] = "MUSICBRAINZ_ALBUMARTISTID",
|
||||
[TAG_MUSICBRAINZ_TRACKID] = "MUSICBRAINZ_TRACKID",
|
||||
[TAG_MUSICBRAINZ_RELEASETRACKID] = "MUSICBRAINZ_RELEASETRACKID",
|
||||
[TAG_MUSICBRAINZ_WORKID] = "MUSICBRAINZ_WORKID",
|
||||
};
|
|
@ -0,0 +1,69 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
// Copyright The Music Player Daemon Project
|
||||
|
||||
#include "Names.hxx"
|
||||
#include "Table.hxx"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
static constexpr struct tag_table tag_item_names_init[] = {
|
||||
{"Artist", TAG_ARTIST},
|
||||
{"ArtistSort", TAG_ARTIST_SORT},
|
||||
{"Album", TAG_ALBUM},
|
||||
{"AlbumSort", TAG_ALBUM_SORT},
|
||||
{"AlbumArtist", TAG_ALBUM_ARTIST},
|
||||
{"AlbumArtistSort", TAG_ALBUM_ARTIST_SORT},
|
||||
{"Title", TAG_TITLE},
|
||||
{"TitleSort", TAG_TITLE_SORT},
|
||||
{"Track", TAG_TRACK},
|
||||
{"Name", TAG_NAME},
|
||||
{"Genre", TAG_GENRE},
|
||||
{"Mood", TAG_MOOD},
|
||||
{"Date", TAG_DATE},
|
||||
{"OriginalDate", TAG_ORIGINAL_DATE},
|
||||
{"Composer", TAG_COMPOSER},
|
||||
{"ComposerSort", TAG_COMPOSERSORT},
|
||||
{"Performer", TAG_PERFORMER},
|
||||
{"Conductor", TAG_CONDUCTOR},
|
||||
{"Work", TAG_WORK},
|
||||
{"Movement", TAG_MOVEMENT},
|
||||
{"MovementNumber", TAG_MOVEMENTNUMBER},
|
||||
{"Ensemble", TAG_ENSEMBLE},
|
||||
{"Location", TAG_LOCATION},
|
||||
{"Grouping", TAG_GROUPING},
|
||||
{"Comment", TAG_COMMENT},
|
||||
{"Disc", TAG_DISC},
|
||||
{"Label", TAG_LABEL},
|
||||
|
||||
/* MusicBrainz tags from http://musicbrainz.org/doc/MusicBrainzTag */
|
||||
{"MUSICBRAINZ_ARTISTID", TAG_MUSICBRAINZ_ARTISTID},
|
||||
{"MUSICBRAINZ_ALBUMID", TAG_MUSICBRAINZ_ALBUMID},
|
||||
{"MUSICBRAINZ_ALBUMARTISTID", TAG_MUSICBRAINZ_ALBUMARTISTID},
|
||||
{"MUSICBRAINZ_TRACKID", TAG_MUSICBRAINZ_TRACKID},
|
||||
{"MUSICBRAINZ_RELEASETRACKID", TAG_MUSICBRAINZ_RELEASETRACKID},
|
||||
{"MUSICBRAINZ_WORKID", TAG_MUSICBRAINZ_WORKID},
|
||||
};
|
||||
|
||||
/**
|
||||
* This function converts the #tag_item_names_init array to an
|
||||
* associative array at compile time. This is a kludge because C++20
|
||||
* doesn't support designated initializers for arrays, unlike C99.
|
||||
*/
|
||||
static constexpr auto
|
||||
MakeTagNames() noexcept
|
||||
{
|
||||
std::array<const char *, TAG_NUM_OF_ITEM_TYPES> result{};
|
||||
|
||||
static_assert(std::size(tag_item_names_init) == result.size());
|
||||
|
||||
for (const auto &i : tag_item_names_init) {
|
||||
/* no duplicates allowed */
|
||||
assert(result[i.type] == nullptr);
|
||||
|
||||
result[i.type] = i.name;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
constinit const std::array<const char *, TAG_NUM_OF_ITEM_TYPES> tag_item_names = MakeTagNames();
|
|
@ -0,0 +1,14 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
// Copyright The Music Player Daemon Project
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Type.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
/**
|
||||
* An array of strings, which map the #TagType to its machine
|
||||
* readable name (specific to the MPD protocol).
|
||||
*/
|
||||
extern const std::array<const char *, TAG_NUM_OF_ITEM_TYPES> tag_item_names;
|
|
@ -2,6 +2,7 @@
|
|||
// Copyright The Music Player Daemon Project
|
||||
|
||||
#include "ParseName.hxx"
|
||||
#include "Names.hxx"
|
||||
#include "util/ASCII.hxx"
|
||||
#include "util/StringCompare.hxx"
|
||||
|
||||
|
|
|
@ -57,10 +57,4 @@ enum TagType
|
|||
TAG_NUM_OF_ITEM_TYPES
|
||||
};
|
||||
|
||||
/**
|
||||
* An array of strings, which map the #TagType to its machine
|
||||
* readable name (specific to the MPD protocol).
|
||||
*/
|
||||
extern const char *const tag_item_names[];
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
generate_parse_name = executable(
|
||||
'GenParseName',
|
||||
'GenParseName.cxx',
|
||||
'Names.c',
|
||||
'Names.cxx',
|
||||
native: true,
|
||||
)
|
||||
|
||||
|
@ -22,7 +22,7 @@ tag_sources = [
|
|||
'Config.cxx',
|
||||
'ParseName.cxx',
|
||||
parse_name_cxx,
|
||||
'Names.c',
|
||||
'Names.cxx',
|
||||
'FixString.cxx',
|
||||
'Pool.cxx',
|
||||
'Table.cxx',
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "DumpDecoderClient.hxx"
|
||||
#include "decoder/DecoderAPI.hxx"
|
||||
#include "input/InputStream.hxx"
|
||||
#include "tag/Names.hxx"
|
||||
#include "util/StringBuffer.hxx"
|
||||
#include "util/Compiler.h"
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "input/InputStream.hxx"
|
||||
#include "tag/Handler.hxx"
|
||||
#include "tag/Generic.hxx"
|
||||
#include "tag/Names.hxx"
|
||||
#include "fs/Path.hxx"
|
||||
#include "fs/NarrowPath.hxx"
|
||||
#include "pcm/AudioFormat.hxx"
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "SongLoader.hxx"
|
||||
#include "client/Client.hxx"
|
||||
#include "tag/Builder.hxx"
|
||||
#include "tag/Names.hxx"
|
||||
#include "tag/Tag.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "fs/AllocatedPath.hxx"
|
||||
|
|
Loading…
Reference in New Issue