diff options
Diffstat (limited to 'xbmc/utils/EmbeddedArt.cpp')
-rw-r--r-- | xbmc/utils/EmbeddedArt.cpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/xbmc/utils/EmbeddedArt.cpp b/xbmc/utils/EmbeddedArt.cpp new file mode 100644 index 0000000..3af2259 --- /dev/null +++ b/xbmc/utils/EmbeddedArt.cpp @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "EmbeddedArt.h" + +#include "Archive.h" + +EmbeddedArtInfo::EmbeddedArtInfo(size_t size, + const std::string &mime, const std::string& type) +{ + Set(size, mime, type); +} + +void EmbeddedArtInfo::Set(size_t size, const std::string &mime, const std::string& type) +{ + m_size = size; + m_mime = mime; + m_type = type; +} + +void EmbeddedArtInfo::Clear() +{ + m_mime.clear(); + m_size = 0; +} + +bool EmbeddedArtInfo::Empty() const +{ + return m_size == 0; +} + +bool EmbeddedArtInfo::Matches(const EmbeddedArtInfo &right) const +{ + return (m_size == right.m_size && + m_mime == right.m_mime && + m_type == right.m_type); +} + +void EmbeddedArtInfo::Archive(CArchive &ar) +{ + if (ar.IsStoring()) + { + ar << m_size; + ar << m_mime; + ar << m_type; + } + else + { + ar >> m_size; + ar >> m_mime; + ar >> m_type; + } +} + +EmbeddedArt::EmbeddedArt(const uint8_t *data, size_t size, + const std::string &mime, const std::string& type) +{ + Set(data, size, mime, type); +} + +void EmbeddedArt::Set(const uint8_t *data, size_t size, + const std::string &mime, const std::string& type) +{ + EmbeddedArtInfo::Set(size, mime, type); + m_data.resize(size); + m_data.assign(data, data+size); +} |