/* * Copyright (C) 2007-2019 Xagasoft, All rights reserved. * * This file is part of the libbu++ library and is released under the * terms of the license contained in the file LICENSE. */ #ifndef BU_ARCHIVE_BASE_H #define BU_ARCHIVE_BASE_H #include #include #include "bu/variant.h" #include "bu/blob.h" namespace Bu { class Archive { public: Archive(); virtual ~Archive(); enum { load = true, save = false }; virtual void close()=0; virtual void write( const void *pData, size_t iLength )=0; virtual void read( void *pData, size_t iLength )=0; virtual bool isLoading()=0; virtual void setProperty( const Bu::Blob &rKey, const Bu::Variant &rValue )=0; virtual Bu::Variant getProperty( const Bu::Blob &rKey ) const=0; }; template Archive &operator&&( Archive &ar, T &dat ) { if( ar.isLoading() ) { return ar >> dat; } else { return ar << dat; } } Archive &operator<<( Archive &ar, bool p ); Archive &operator<<( Archive &ar, char p ); Archive &operator<<( Archive &ar, signed char p ); Archive &operator<<( Archive &ar, unsigned char p ); Archive &operator<<( Archive &ar, signed short p ); Archive &operator<<( Archive &ar, unsigned short p ); Archive &operator<<( Archive &ar, signed int p ); Archive &operator<<( Archive &ar, unsigned int p ); Archive &operator<<( Archive &ar, signed long p ); Archive &operator<<( Archive &ar, unsigned long p ); Archive &operator<<( Archive &ar, signed long long p ); Archive &operator<<( Archive &ar, unsigned long long p ); Archive &operator<<( Archive &ar, float p ); Archive &operator<<( Archive &ar, double p ); Archive &operator<<( Archive &ar, long double p ); Archive &operator>>( Archive &ar, bool &p ); Archive &operator>>( Archive &ar, char &p ); Archive &operator>>( Archive &ar, signed char &p ); Archive &operator>>( Archive &ar, unsigned char &p ); Archive &operator>>( Archive &ar, signed short &p ); Archive &operator>>( Archive &ar, unsigned short &p ); Archive &operator>>( Archive &ar, signed int &p ); Archive &operator>>( Archive &ar, unsigned int &p ); Archive &operator>>( Archive &ar, signed long &p ); Archive &operator>>( Archive &ar, unsigned long &p ); Archive &operator>>( Archive &ar, signed long long &p ); Archive &operator>>( Archive &ar, unsigned long long &p ); Archive &operator>>( Archive &ar, float &p ); Archive &operator>>( Archive &ar, double &p ); Archive &operator>>( Archive &ar, long double &p ); }; #endif