Permalink
Browse files

added: ISerializable interface, in order to serialize object into a C…

…Variant container.

To prevent conflicts, existing ISerializable interface was renamed to IArchivable.

git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@35123 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
  • Loading branch information...
1 parent 799869a commit 5d0f6cf2d15a6ddb9d245ae7492c5933a8660bb2 blinkseb committed Nov 2, 2010
View
@@ -23,6 +23,7 @@
#include "GUIListItemLayout.h"
#include "utils/Archive.h"
#include "utils/CharsetConverter.h"
+#include "utils/Variant.h"
CGUIListItem::CGUIListItem(const CGUIListItem& item)
{
@@ -207,7 +208,7 @@ const CGUIListItem& CGUIListItem::operator =(const CGUIListItem& item)
return *this;
}
-void CGUIListItem::Serialize(CArchive &ar)
+void CGUIListItem::Archive(CArchive &ar)
{
if (ar.IsStoring())
{
@@ -251,6 +252,21 @@ void CGUIListItem::Serialize(CArchive &ar)
}
}
}
+void CGUIListItem::Serialize(CVariant &value)
+{
+ value["isFolder"] = m_bIsFolder;
+ value["strLabel"] = m_strLabel;
+ value["strLabel2"] = m_strLabel2;
+ value["sortLabel"] = CStdString(m_sortLabel);
+ value["strThumbnailImage"] = m_strThumbnailImage;
+ value["strIcon"] = m_strIcon;
+ value["selected"] = m_bSelected;
+
+ for (std::map<CStdString, CStdString, icompare>::const_iterator it = m_mapProperties.begin(); it != m_mapProperties.end(); it++)
+ {
+ value["properties"][it->first] = it->second;
+ }
+}
void CGUIListItem::FreeIcons()
{
View
@@ -37,6 +37,7 @@
// Forward
class CGUIListItemLayout;
class CArchive;
+class CVariant;
/*!
\ingroup controls
@@ -112,7 +113,8 @@ class CGUIListItem
void ClearProperties();
- void Serialize(CArchive& ar);
+ void Archive(CArchive& ar);
+ void Serialize(CVariant& value);
bool HasProperty(const CStdString &strKey) const;
bool HasProperties() const { return m_mapProperties.size() > 0; };
View
@@ -593,7 +593,7 @@ CDateTime::operator FILETIME() const
return m_time;
}
-void CDateTime::Serialize(CArchive& ar)
+void CDateTime::Archive(CArchive& ar)
{
if (ar.IsStoring())
{
View
@@ -81,7 +81,7 @@ class CDateTimeSpan
};
/// \brief DateTime class, which uses FILETIME as it's base.
-class CDateTime : public ISerializable
+class CDateTime : public IArchivable
{
public:
CDateTime();
@@ -148,7 +148,7 @@ class CDateTime : public ISerializable
operator FILETIME() const;
- virtual void Serialize(CArchive& ar);
+ virtual void Archive(CArchive& ar);
void Reset();
View
@@ -53,6 +53,7 @@
#include "Settings.h"
#include "utils/RegExp.h"
#include "utils/log.h"
+#include "utils/Variant.h"
#include "karaoke/karaokelyricsfactory.h"
using namespace std;
@@ -331,9 +332,9 @@ void CFileItem::Reset()
SetInvalid();
}
-void CFileItem::Serialize(CArchive& ar)
+void CFileItem::Archive(CArchive& ar)
{
- CGUIListItem::Serialize(ar);
+ CGUIListItem::Archive(ar);
if (ar.IsStoring())
{
@@ -422,6 +423,27 @@ void CFileItem::Serialize(CArchive& ar)
SetInvalid();
}
}
+void CFileItem::Serialize(CVariant& value)
+{
+ //CGUIListItem::Serialize(value["CGUIListItem"]);
+
+ value["strPath"] = m_strPath;
+ value["dateTime"] = (m_dateTime.IsValid()) ? m_dateTime.GetAsRFC1123DateTime() : "";
+ value["size"] = (int) m_dwSize / 1000;
+ value["DVDLabel"] = m_strDVDLabel;
+ value["title"] = m_strTitle;
+ value["mimetype"] = m_mimetype;
+ value["extrainfo"] = m_extrainfo;
+
+ if (m_musicInfoTag)
+ (*m_musicInfoTag).Serialize(value["musicInfoTag"]);
+
+ if (m_videoInfoTag)
+ (*m_videoInfoTag).Serialize(value["videoInfoTag"]);
+
+ if (m_pictureInfoTag)
+ (*m_pictureInfoTag).Serialize(value["pictureInfoTag"]);
+}
bool CFileItem::Exists(bool bUseCache /* = true */) const
{
if (m_strPath.IsEmpty()
@@ -1561,12 +1583,12 @@ void CFileItemList::Randomize()
random_shuffle(m_items.begin(), m_items.end());
}
-void CFileItemList::Serialize(CArchive& ar)
+void CFileItemList::Archive(CArchive& ar)
{
CSingleLock lock(m_lock);
if (ar.IsStoring())
{
- CFileItem::Serialize(ar);
+ CFileItem::Archive(ar);
int i = 0;
if (m_items.size() > 0 && m_items[0]->IsParentFolder())
@@ -1614,7 +1636,7 @@ void CFileItemList::Serialize(CArchive& ar)
Clear();
- CFileItem::Serialize(ar);
+ CFileItem::Archive(ar);
int iSize = 0;
ar >> iSize;
View
@@ -60,7 +60,7 @@ class CMediaSource;
\sa CFileItemList
*/
class CFileItem :
- public CGUIListItem, public ISerializable
+ public CGUIListItem, public IArchivable, public ISerializable
{
public:
CFileItem(void);
@@ -79,7 +79,8 @@ class CFileItem :
void Reset();
const CFileItem& operator=(const CFileItem& item);
- virtual void Serialize(CArchive& ar);
+ virtual void Archive(CArchive& ar);
+ virtual void Serialize(CVariant& value);
virtual bool IsFileItem() const { return true; };
bool Exists(bool bUseCache = true) const;
@@ -339,7 +340,7 @@ class CFileItemList : public CFileItem
CFileItemList();
CFileItemList(const CStdString& strPath);
virtual ~CFileItemList();
- virtual void Serialize(CArchive& ar);
+ virtual void Archive(CArchive& ar);
CFileItemPtr operator[] (int iItem);
const CFileItemPtr operator[] (int iItem) const;
CFileItemPtr operator[] (const CStdString& strPath);
View
@@ -23,6 +23,7 @@
#include "Album.h"
#include "StringUtils.h"
#include "AdvancedSettings.h"
+#include "utils/Variant.h"
using namespace MUSIC_INFO;
@@ -344,7 +345,27 @@ void CMusicInfoTag::SetSong(const CSong& song)
m_bLoaded = true;
}
-void CMusicInfoTag::Serialize(CArchive& ar)
+void CMusicInfoTag::Serialize(CVariant& value)
+{
+ value["url"] = m_strURL;
+ value["title"] = m_strTitle;
+ value["artist"] = m_strArtist;
+ value["album"] = m_strAlbum;
+ value["albumartist"] = m_strAlbumArtist;
+ value["genre"] = m_strGenre;
+ value["duration"] = m_iDuration;
+ value["track"] = m_iTrack;
+ value["loaded"] = m_bLoaded;
+ value["year"] = m_dwReleaseDate.wYear;
+ value["musicbrainztrackid"] = m_strMusicBrainzTrackID;
+ value["musicbrainzartistid"] = m_strMusicBrainzArtistID;
+ value["musicbrainzalbumid"] = m_strMusicBrainzAlbumID;
+ value["musicbrainzalbumartistid"] = m_strMusicBrainzAlbumArtistID;
+ value["musicbrainztrmid"] = m_strMusicBrainzTRMID;
+ value["comment"] = m_strComment;
+ value["rating"] = m_rating;
+}
+void CMusicInfoTag::Archive(CArchive& ar)
{
if (ar.IsStoring())
{
View
@@ -29,7 +29,7 @@ class CAlbum;
namespace MUSIC_INFO
{
-class CMusicInfoTag : public ISerializable
+class CMusicInfoTag : public IArchivable, public ISerializable
{
public:
CMusicInfoTag(void);
@@ -105,7 +105,8 @@ class CMusicInfoTag : public ISerializable
*/
void AppendGenre(const CStdString &genre);
- virtual void Serialize(CArchive& ar);
+ virtual void Archive(CArchive& ar);
+ virtual void Serialize(CVariant& ar);
void Clear();
protected:
View
@@ -22,6 +22,7 @@
#include "PictureInfoTag.h"
#include "DateTime.h"
#include "Util.h"
+#include "utils/Variant.h"
using namespace std;
@@ -55,7 +56,7 @@ bool CPictureInfoTag::Load(const CStdString &path)
return m_isLoaded;
}
-void CPictureInfoTag::Serialize(CArchive& ar)
+void CPictureInfoTag::Archive(CArchive& ar)
{
if (ar.IsStoring())
{
@@ -183,6 +184,68 @@ void CPictureInfoTag::Serialize(CArchive& ar)
}
}
+void CPictureInfoTag::Serialize(CVariant& value)
+{
+ value["aperturefnumber"] = m_exifInfo.ApertureFNumber;
+ value["cameramake"] = CStdString(m_exifInfo.CameraMake);
+ value["cameramodel"] = CStdString(m_exifInfo.CameraModel);
+ value["ccdwidth"] = m_exifInfo.CCDWidth;
+ value["comments"] = CStdString(m_exifInfo.Comments);
+ value["datetime"] = CStdString(m_exifInfo.DateTime);
+ for (int i = 0; i < 10; i++)
+ value["datetimeoffsets"][i] = m_exifInfo.DateTimeOffsets[i];
+ value["digitalzoomratio"] = m_exifInfo.DigitalZoomRatio;
+ value["distance"] = m_exifInfo.Distance;
+ value["exposurebias"] = m_exifInfo.ExposureBias;
+ value["exposuremode"] = m_exifInfo.ExposureMode;
+ value["exposureprogram"] = m_exifInfo.ExposureProgram;
+ value["exposuretime"] = m_exifInfo.ExposureTime;
+ value["flashused"] = m_exifInfo.FlashUsed;
+ value["focallength"] = m_exifInfo.FocalLength;
+ value["focallength35mmequiv"] = m_exifInfo.FocalLength35mmEquiv;
+ value["gpsinfopresent"] = m_exifInfo.GpsInfoPresent;
+ value["gpsinfo"]["alt"] = CStdString(m_exifInfo.GpsAlt);
+ value["gpsinfo"]["lat"] = CStdString(m_exifInfo.GpsLat);
+ value["gpsinfo"]["long"] = CStdString(m_exifInfo.GpsLong);
+ value["height"] = m_exifInfo.Height;
+ value["iscolor"] = m_exifInfo.IsColor;
+ value["isoequivalent"] = m_exifInfo.ISOequivalent;
+ value["largestexifoffset"] = m_exifInfo.LargestExifOffset;
+ value["lightsource"] = m_exifInfo.LightSource;
+ value["meteringmode"] = m_exifInfo.MeteringMode;
+ value["numdatetimetags"] = m_exifInfo.numDateTimeTags;
+ value["orientation"] = m_exifInfo.Orientation;
+ value["process"] = m_exifInfo.Process;
+ value["thumbnailatend"] = m_exifInfo.ThumbnailAtEnd;
+ value["thumbnailoffset"] = m_exifInfo.ThumbnailOffset;
+ value["thumbnailsize"] = m_exifInfo.ThumbnailSize;
+ value["thumbnailsizeoffset"] = m_exifInfo.ThumbnailSizeOffset;
+ value["whitebalance"] = m_exifInfo.Whitebalance;
+ value["width"] = m_exifInfo.Width;
+
+ value["author"] = CStdString(m_iptcInfo.Author);
+ value["byline"] = CStdString(m_iptcInfo.Byline);
+ value["bylinetitle"] = CStdString(m_iptcInfo.BylineTitle);
+ value["caption"] = CStdString(m_iptcInfo.Caption);
+ value["category"] = CStdString(m_iptcInfo.Category);
+ value["city"] = CStdString(m_iptcInfo.City);
+ value["copyright"] = CStdString(m_iptcInfo.Copyright);
+ value["copyrightnotice"] = CStdString(m_iptcInfo.CopyrightNotice);
+ value["country"] = CStdString(m_iptcInfo.Country);
+ value["countrycode"] = CStdString(m_iptcInfo.CountryCode);
+ value["credit"] = CStdString(m_iptcInfo.Credit);
+ value["date"] = CStdString(m_iptcInfo.Date);
+ value["headline"] = CStdString(m_iptcInfo.Headline);
+ value["keywords"] = CStdString(m_iptcInfo.Keywords);
+ value["objectname"] = CStdString(m_iptcInfo.ObjectName);
+ value["referenceservice"] = CStdString(m_iptcInfo.ReferenceService);
+ value["source"] = CStdString(m_iptcInfo.Source);
+ value["specialinstructions"] = CStdString(m_iptcInfo.SpecialInstructions);
+ value["state"] = CStdString(m_iptcInfo.State);
+ value["supplementalcategories"] = CStdString(m_iptcInfo.SupplementalCategories);
+ value["transmissionreference"] = CStdString(m_iptcInfo.TransmissionReference);
+}
+
void CPictureInfoTag::GetStringFromArchive(CArchive &ar, char *string, size_t length)
{
CStdString temp;
View
@@ -80,12 +80,13 @@
#define SLIDE_IPTC_COUNTRY_CODE 979
#define SLIDE_IPTC_REF_SERVICE 980
-class CPictureInfoTag : public ISerializable
+class CPictureInfoTag : public IArchivable, public ISerializable
{
public:
CPictureInfoTag() { Reset(); };
void Reset();
- virtual void Serialize(CArchive& ar);
+ virtual void Archive(CArchive& ar);
+ virtual void Serialize(CVariant& value);
const CPictureInfoTag& operator=(const CPictureInfoTag& item);
const CStdString GetInfo(int info) const;
View
@@ -378,7 +378,7 @@ CTemperature CTemperature::CreateFromCelsius(double value)
return CTemperature(value*1.8f+32.0f);
}
-void CTemperature::Serialize(CArchive& ar)
+void CTemperature::Archive(CArchive& ar)
{
if (ar.IsStoring())
{
View
@@ -22,7 +22,7 @@
#include "utils/Archive.h"
-class CTemperature : public ISerializable
+class CTemperature : public IArchivable
{
public:
CTemperature();
@@ -75,7 +75,7 @@ class CTemperature : public ISerializable
CTemperature operator ++(int);
CTemperature operator --(int);
- virtual void Serialize(CArchive& ar);
+ virtual void Archive(CArchive& ar);
typedef enum _STATE
{
Oops, something went wrong.

0 comments on commit 5d0f6cf

Please sign in to comment.