DetachedSong: add LightSong cast operator

This commit is contained in:
Max Kellermann 2017-02-08 10:38:25 +01:00
parent 332baa4f67
commit e9c99e0518
2 changed files with 16 additions and 0 deletions

View File

@ -31,6 +31,19 @@ DetachedSong::DetachedSong(const LightSong &other)
start_time(other.start_time),
end_time(other.end_time) {}
DetachedSong::operator LightSong() const
{
LightSong result;
result.directory = nullptr;
result.uri = uri.c_str();
result.real_uri = real_uri.empty() ? nullptr : real_uri.c_str();
result.tag = &tag;
result.mtime = mtime;
result.start_time = start_time;
result.end_time = end_time;
return result;
}
bool
DetachedSong::IsRemote() const
{

View File

@ -107,6 +107,9 @@ public:
DetachedSong(DetachedSong &&) = default;
DetachedSong &operator=(DetachedSong &&) = default;
gcc_pure
explicit operator LightSong() const;
gcc_pure
const char *GetURI() const {
return uri.c_str();