Upgraded code to switch to C++17. Tested on Debian Buster
This commit is contained in:
@@ -29,21 +29,21 @@ namespace MetaData
|
||||
|
||||
using MetadataMap = std::map<std::string, std::string>;
|
||||
|
||||
boost::optional<std::string>
|
||||
std::optional<std::string>
|
||||
findFirstValueOf(const MetadataMap& metadataMap, std::initializer_list<std::string> tags)
|
||||
{
|
||||
auto it = std::find_first_of(std::cbegin(metadataMap), std::cend(metadataMap), std::cbegin(tags), std::cend(tags), [](const auto& it, const auto& str) { return it.first == str; });
|
||||
if (it == std::cend(metadataMap))
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
|
||||
return stringTrim(it->second);
|
||||
}
|
||||
|
||||
static
|
||||
boost::optional<Album>
|
||||
std::optional<Album>
|
||||
getAlbum(const MetadataMap& metadataMap)
|
||||
{
|
||||
boost::optional<Album> res;
|
||||
std::optional<Album> res;
|
||||
|
||||
auto album {findFirstValueOf(metadataMap, {"ALBUM"})};
|
||||
if (!album)
|
||||
@@ -115,8 +115,8 @@ getArtists(const MetadataMap& metadataMap)
|
||||
return artists;
|
||||
}
|
||||
|
||||
boost::optional<Track>
|
||||
AvFormat::parse(const boost::filesystem::path& p, bool debug)
|
||||
std::optional<Track>
|
||||
AvFormat::parse(const std::filesystem::path& p, bool debug)
|
||||
{
|
||||
Track track;
|
||||
|
||||
@@ -215,7 +215,7 @@ AvFormat::parse(const boost::filesystem::path& p, bool debug)
|
||||
}
|
||||
catch(Av::MediaFileException& e)
|
||||
{
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return track;
|
||||
|
||||
@@ -19,9 +19,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "MetaData.hpp"
|
||||
|
||||
namespace MetaData
|
||||
@@ -31,7 +28,7 @@ namespace MetaData
|
||||
class AvFormat : public Parser
|
||||
{
|
||||
public:
|
||||
boost::optional<Track> parse(const boost::filesystem::path& p, bool debug = false) override;
|
||||
std::optional<Track> parse(const std::filesystem::path& p, bool debug = false) override;
|
||||
};
|
||||
|
||||
} // namespace MetaData
|
||||
|
||||
+10
-11
@@ -20,12 +20,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <filesystem>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
namespace MetaData
|
||||
{
|
||||
using Clusters = std::map<std::string /* type */, std::set<std::string> /* names */>;
|
||||
@@ -54,15 +53,15 @@ namespace MetaData
|
||||
std::string title;
|
||||
std::string musicBrainzTrackID;
|
||||
std::string musicBrainzRecordID;
|
||||
boost::optional<Album> album;
|
||||
std::optional<Album> album;
|
||||
Clusters clusters;
|
||||
std::chrono::milliseconds duration {};
|
||||
boost::optional<std::size_t> trackNumber;
|
||||
boost::optional<std::size_t> totalTrack;
|
||||
boost::optional<std::size_t> discNumber;
|
||||
boost::optional<std::size_t> totalDisc;
|
||||
boost::optional<int> year;
|
||||
boost::optional<int> originalYear;
|
||||
std::optional<std::size_t> trackNumber;
|
||||
std::optional<std::size_t> totalTrack;
|
||||
std::optional<std::size_t> discNumber;
|
||||
std::optional<std::size_t> totalDisc;
|
||||
std::optional<int> year;
|
||||
std::optional<int> originalYear;
|
||||
bool hasCover {false};
|
||||
std::vector<AudioStream> audioStreams;
|
||||
std::string acoustID;
|
||||
@@ -73,7 +72,7 @@ namespace MetaData
|
||||
class Parser
|
||||
{
|
||||
public:
|
||||
virtual boost::optional<Track> parse(const boost::filesystem::path& p, bool debug = false) = 0;
|
||||
virtual std::optional<Track> parse(const std::filesystem::path& p, bool debug = false) = 0;
|
||||
|
||||
void setClusterTypeNames(const std::set<std::string>& clusterTypeNames) { _clusterTypeNames = clusterTypeNames; }
|
||||
|
||||
|
||||
@@ -126,10 +126,10 @@ getAlbumArtists(const TagLib::PropertyMap& properties)
|
||||
}
|
||||
|
||||
static
|
||||
boost::optional<Album>
|
||||
std::optional<Album>
|
||||
getAlbum(const TagLib::PropertyMap& properties)
|
||||
{
|
||||
boost::optional<Album> res;
|
||||
std::optional<Album> res;
|
||||
|
||||
std::vector<std::string> albumName {getPropertyValues(properties, "ALBUM")};
|
||||
if (albumName.empty())
|
||||
@@ -145,8 +145,8 @@ getAlbum(const TagLib::PropertyMap& properties)
|
||||
return res;
|
||||
}
|
||||
|
||||
boost::optional<Track>
|
||||
TagLibParser::parse(const boost::filesystem::path& p, bool debug)
|
||||
std::optional<Track>
|
||||
TagLibParser::parse(const std::filesystem::path& p, bool debug)
|
||||
{
|
||||
TagLib::FileRef f {p.string().c_str(),
|
||||
true, // read audio properties
|
||||
@@ -155,13 +155,13 @@ TagLibParser::parse(const boost::filesystem::path& p, bool debug)
|
||||
if (f.isNull())
|
||||
{
|
||||
LMS_LOG(METADATA, ERROR) << "File '" << p.string() << "': parsing failed";
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
if (!f.audioProperties())
|
||||
{
|
||||
LMS_LOG(METADATA, INFO) << "File '" << p.string() << "': no audio properties";
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
Track track;
|
||||
|
||||
@@ -19,9 +19,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "MetaData.hpp"
|
||||
|
||||
namespace MetaData
|
||||
@@ -31,7 +28,7 @@ namespace MetaData
|
||||
class TagLibParser : public Parser
|
||||
{
|
||||
public:
|
||||
boost::optional<Track> parse(const boost::filesystem::path& p, bool debug = false) override;
|
||||
std::optional<Track> parse(const std::filesystem::path& p, bool debug = false) override;
|
||||
};
|
||||
|
||||
} // namespace MetaData
|
||||
|
||||
Reference in New Issue
Block a user