diff options
author | Max Kellermann <max@duempel.org> | 2014-01-18 18:20:54 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-01-21 21:06:56 +0100 |
commit | 5d4b450c52b3af92a03a8380a40dc703f0df4233 (patch) | |
tree | 9f861173b3861c544670dfb3f38b436902f67b63 /src/DetachedSong.hxx | |
parent | 483b1f51c96303f2b587870cce6803cc6f699158 (diff) | |
download | mpd-5d4b450c52b3af92a03a8380a40dc703f0df4233.tar.gz mpd-5d4b450c52b3af92a03a8380a40dc703f0df4233.tar.xz mpd-5d4b450c52b3af92a03a8380a40dc703f0df4233.zip |
DetachedSong: add attribute "real_uri"
Prepare for UPnP songs that retain there database identity.
Diffstat (limited to '')
-rw-r--r-- | src/DetachedSong.hxx | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/src/DetachedSong.hxx b/src/DetachedSong.hxx index 3b14d5a07..b2f5196ff 100644 --- a/src/DetachedSong.hxx +++ b/src/DetachedSong.hxx @@ -47,6 +47,16 @@ class DetachedSong { */ std::string uri; + /** + * The "real" URI, the one to be used for opening the + * resource. If this attribute is empty, then #uri shall be + * used. + * + * This attribute is used for songs from the database which + * have a relative URI. + */ + std::string real_uri; + Tag tag; time_t mtime; @@ -98,6 +108,29 @@ public: } /** + * Does this object have a "real" URI different from the + * displayed URI? + */ + gcc_pure + bool HasRealURI() const { + return !real_uri.empty(); + } + + /** + * Returns "real" URI (#real_uri) and falls back to just + * GetURI(). + */ + gcc_pure + const char *GetRealURI() const { + return (HasRealURI() ? real_uri : uri).c_str(); + } + + template<typename T> + void SetRealURI(T &&_uri) { + real_uri = std::forward<T>(_uri); + } + + /** * Returns true if both objects refer to the same physical * song. */ @@ -123,9 +156,7 @@ public: bool IsAbsoluteFile() const; gcc_pure - bool IsInDatabase() const { - return IsFile() && !IsAbsoluteFile(); - } + bool IsInDatabase() const; const Tag &GetTag() const { return tag; |