From a3e28c2d1a1c85351ef5fe4e50ec75db6f4199c4 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 8 Feb 2017 08:57:22 +0100 Subject: [PATCH] tag/Tag: move tag_name_parse() to ParseName.cxx --- Makefile.am | 1 + src/SongFilter.cxx | 2 +- src/SongSave.cxx | 1 + src/command/DatabaseCommands.cxx | 2 +- src/command/TagCommands.cxx | 2 +- src/db/plugins/simple/DatabaseSave.cxx | 2 +- src/decoder/plugins/OpusTags.cxx | 2 +- src/playlist/cue/CueParser.cxx | 2 +- src/tag/ApeTag.cxx | 2 +- src/tag/Config.cxx | 2 +- src/tag/Format.cxx | 1 + src/tag/ParseName.cxx | 55 ++++++++++++++++++++++++++ src/tag/ParseName.hxx | 44 +++++++++++++++++++++ src/tag/Tag.cxx | 32 --------------- src/tag/Tag.hxx | 18 --------- 15 files changed, 110 insertions(+), 58 deletions(-) create mode 100644 src/tag/ParseName.cxx create mode 100644 src/tag/ParseName.hxx diff --git a/Makefile.am b/Makefile.am index d3b4b763b..24e1a3948 100644 --- a/Makefile.am +++ b/Makefile.am @@ -913,6 +913,7 @@ libtag_a_SOURCES =\ src/tag/Mask.hxx \ src/tag/Settings.cxx src/tag/Settings.hxx \ src/tag/Config.cxx src/tag/Config.hxx \ + src/tag/ParseName.cxx src/tag/ParseName.hxx \ src/tag/Names.c \ src/tag/FixString.cxx src/tag/FixString.hxx \ src/tag/Pool.cxx src/tag/Pool.hxx \ diff --git a/src/SongFilter.cxx b/src/SongFilter.cxx index d2bbc9b32..61acefb85 100644 --- a/src/SongFilter.cxx +++ b/src/SongFilter.cxx @@ -21,7 +21,7 @@ #include "SongFilter.hxx" #include "db/LightSong.hxx" #include "DetachedSong.hxx" -#include "tag/Tag.hxx" +#include "tag/ParseName.hxx" #include "util/ConstBuffer.hxx" #include "util/StringAPI.hxx" #include "util/ASCII.hxx" diff --git a/src/SongSave.cxx b/src/SongSave.cxx index 92e1c83a3..983fd7586 100644 --- a/src/SongSave.cxx +++ b/src/SongSave.cxx @@ -24,6 +24,7 @@ #include "TagSave.hxx" #include "fs/io/TextFile.hxx" #include "fs/io/BufferedOutputStream.hxx" +#include "tag/ParseName.hxx" #include "tag/Tag.hxx" #include "tag/Builder.hxx" #include "util/StringUtil.hxx" diff --git a/src/command/DatabaseCommands.cxx b/src/command/DatabaseCommands.cxx index 42f79b8e2..7647ac5d3 100644 --- a/src/command/DatabaseCommands.cxx +++ b/src/command/DatabaseCommands.cxx @@ -28,7 +28,7 @@ #include "CommandError.hxx" #include "client/Client.hxx" #include "client/Response.hxx" -#include "tag/Tag.hxx" +#include "tag/ParseName.hxx" #include "util/ConstBuffer.hxx" #include "util/StringAPI.hxx" #include "SongFilter.hxx" diff --git a/src/command/TagCommands.cxx b/src/command/TagCommands.cxx index 1862c5ab5..9c4bab46c 100644 --- a/src/command/TagCommands.cxx +++ b/src/command/TagCommands.cxx @@ -22,7 +22,7 @@ #include "Request.hxx" #include "client/Client.hxx" #include "client/Response.hxx" -#include "tag/Tag.hxx" +#include "tag/ParseName.hxx" #include "Partition.hxx" #include "util/ConstBuffer.hxx" diff --git a/src/db/plugins/simple/DatabaseSave.cxx b/src/db/plugins/simple/DatabaseSave.cxx index d16f08a67..790a2e1cc 100644 --- a/src/db/plugins/simple/DatabaseSave.cxx +++ b/src/db/plugins/simple/DatabaseSave.cxx @@ -24,7 +24,7 @@ #include "DirectorySave.hxx" #include "fs/io/BufferedOutputStream.hxx" #include "fs/io/TextFile.hxx" -#include "tag/Tag.hxx" +#include "tag/ParseName.hxx" #include "tag/Settings.hxx" #include "fs/Charset.hxx" #include "util/StringCompare.hxx" diff --git a/src/decoder/plugins/OpusTags.cxx b/src/decoder/plugins/OpusTags.cxx index 630ddb1f3..2ecc816a4 100644 --- a/src/decoder/plugins/OpusTags.cxx +++ b/src/decoder/plugins/OpusTags.cxx @@ -22,7 +22,7 @@ #include "OpusReader.hxx" #include "lib/xiph/XiphTags.hxx" #include "tag/Handler.hxx" -#include "tag/Tag.hxx" +#include "tag/ParseName.hxx" #include "ReplayGainInfo.hxx" #include diff --git a/src/playlist/cue/CueParser.cxx b/src/playlist/cue/CueParser.cxx index 4e511be85..7695c67fc 100644 --- a/src/playlist/cue/CueParser.cxx +++ b/src/playlist/cue/CueParser.cxx @@ -19,10 +19,10 @@ #include "config.h" #include "CueParser.hxx" +#include "tag/ParseName.hxx" #include "util/Alloc.hxx" #include "util/StringUtil.hxx" #include "util/CharUtil.hxx" -#include "tag/Tag.hxx" #include #include diff --git a/src/tag/ApeTag.cxx b/src/tag/ApeTag.cxx index 6e5a88a8f..ff143e7cd 100644 --- a/src/tag/ApeTag.cxx +++ b/src/tag/ApeTag.cxx @@ -20,7 +20,7 @@ #include "config.h" #include "ApeTag.hxx" #include "ApeLoader.hxx" -#include "Tag.hxx" +#include "ParseName.hxx" #include "Table.hxx" #include "Handler.hxx" #include "util/StringView.hxx" diff --git a/src/tag/Config.cxx b/src/tag/Config.cxx index 8a691efd0..6135cbed8 100644 --- a/src/tag/Config.cxx +++ b/src/tag/Config.cxx @@ -20,7 +20,7 @@ #include "config.h" #include "Config.hxx" #include "Settings.hxx" -#include "Tag.hxx" +#include "ParseName.hxx" #include "config/ConfigGlobal.hxx" #include "config/ConfigOption.hxx" #include "system/FatalError.hxx" diff --git a/src/tag/Format.cxx b/src/tag/Format.cxx index 1164d961c..8019d6ef8 100644 --- a/src/tag/Format.cxx +++ b/src/tag/Format.cxx @@ -20,6 +20,7 @@ #include "config.h" #include "Format.hxx" #include "Tag.hxx" +#include "ParseName.hxx" #include "util/format.h" #include "util/StringUtil.hxx" diff --git a/src/tag/ParseName.cxx b/src/tag/ParseName.cxx new file mode 100644 index 000000000..eb78929a4 --- /dev/null +++ b/src/tag/ParseName.cxx @@ -0,0 +1,55 @@ +/* + * Copyright 2003-2017 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "config.h" +#include "ParseName.hxx" +#include "util/ASCII.hxx" + +#include +#include + +TagType +tag_name_parse(const char *name) +{ + assert(name != nullptr); + + for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i) { + assert(tag_item_names[i] != nullptr); + + if (strcmp(name, tag_item_names[i]) == 0) + return (TagType)i; + } + + return TAG_NUM_OF_ITEM_TYPES; +} + +TagType +tag_name_parse_i(const char *name) +{ + assert(name != nullptr); + + for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i) { + assert(tag_item_names[i] != nullptr); + + if (StringEqualsCaseASCII(name, tag_item_names[i])) + return (TagType)i; + } + + return TAG_NUM_OF_ITEM_TYPES; +} diff --git a/src/tag/ParseName.hxx b/src/tag/ParseName.hxx new file mode 100644 index 000000000..80f328e91 --- /dev/null +++ b/src/tag/ParseName.hxx @@ -0,0 +1,44 @@ +/* + * Copyright 2003-2017 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef MPD_TAG_PARSE_NAME_HXX +#define MPD_TAG_PARSE_NAME_HXX + +#include "Type.h" +#include "Compiler.h" + +/** + * Parse the string, and convert it into a #TagType. Returns + * #TAG_NUM_OF_ITEM_TYPES if the string could not be recognized. + */ +gcc_pure +TagType +tag_name_parse(const char *name); + +/** + * Parse the string, and convert it into a #TagType. Returns + * #TAG_NUM_OF_ITEM_TYPES if the string could not be recognized. + * + * Case does not matter. + */ +gcc_pure +TagType +tag_name_parse_i(const char *name); + +#endif diff --git a/src/tag/Tag.cxx b/src/tag/Tag.cxx index 85732d2e8..000652c24 100644 --- a/src/tag/Tag.cxx +++ b/src/tag/Tag.cxx @@ -21,40 +21,8 @@ #include "Tag.hxx" #include "Pool.hxx" #include "Builder.hxx" -#include "util/ASCII.hxx" #include -#include - -TagType -tag_name_parse(const char *name) -{ - assert(name != nullptr); - - for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i) { - assert(tag_item_names[i] != nullptr); - - if (strcmp(name, tag_item_names[i]) == 0) - return (TagType)i; - } - - return TAG_NUM_OF_ITEM_TYPES; -} - -TagType -tag_name_parse_i(const char *name) -{ - assert(name != nullptr); - - for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i) { - assert(tag_item_names[i] != nullptr); - - if (StringEqualsCaseASCII(name, tag_item_names[i])) - return (TagType)i; - } - - return TAG_NUM_OF_ITEM_TYPES; -} void Tag::Clear() diff --git a/src/tag/Tag.hxx b/src/tag/Tag.hxx index 9320e767e..98039c367 100644 --- a/src/tag/Tag.hxx +++ b/src/tag/Tag.hxx @@ -196,22 +196,4 @@ struct Tag { } }; -/** - * Parse the string, and convert it into a #TagType. Returns - * #TAG_NUM_OF_ITEM_TYPES if the string could not be recognized. - */ -gcc_pure -TagType -tag_name_parse(const char *name); - -/** - * Parse the string, and convert it into a #TagType. Returns - * #TAG_NUM_OF_ITEM_TYPES if the string could not be recognized. - * - * Case does not matter. - */ -gcc_pure -TagType -tag_name_parse_i(const char *name); - #endif