From e9c99e0518d6646ba8843c16828e234bb05a2e52 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 8 Feb 2017 10:38:25 +0100 Subject: [PATCH] DetachedSong: add LightSong cast operator --- src/DetachedSong.cxx | 13 +++++++++++++ src/DetachedSong.hxx | 3 +++ 2 files changed, 16 insertions(+) diff --git a/src/DetachedSong.cxx b/src/DetachedSong.cxx index da5d0f629..6ed08cd14 100644 --- a/src/DetachedSong.cxx +++ b/src/DetachedSong.cxx @@ -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 { diff --git a/src/DetachedSong.hxx b/src/DetachedSong.hxx index 2197d0d43..fc8d7c4e6 100644 --- a/src/DetachedSong.hxx +++ b/src/DetachedSong.hxx @@ -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();