X-Git-Url: http://git.pippins.net/embedvideo/.git/static/git-logo.png?a=blobdiff_plain;f=filedata.hpp;h=f98b520e5e8d18eef6d2bf79b3a0c58ab181e0eb;hb=4d43b38a139fcc3ef784f7fe3cab00019f679b54;hp=62546747f1f3e8d7da7f49680ee73e3d9679c29a;hpb=831e1711cdf96ccd26203aec08a46e5c09bca3bd;p=backups%2F.git diff --git a/filedata.hpp b/filedata.hpp index 6254674..f98b520 100644 --- a/filedata.hpp +++ b/filedata.hpp @@ -4,6 +4,7 @@ #include #include #include +#include class FileData { public: @@ -28,6 +29,30 @@ class FileData { void setFileName( const std::string &arg ) { filename = arg; } void setLastBackupDate( unsigned long long arg ) { last_backup_date = arg; } + struct LastBackupCmp { + bool operator()( const FileData *a, const FileData *b ) { + return a->getLastBackupDate() < b->getLastBackupDate(); + } + }; + + struct SizeCmp { + bool operator()( const FileData *a, const FileData *b ) { + return a->getFileSize() < b->getFileSize(); + } + }; + + struct NameCmp { + bool operator()( const FileData *a, const FileData *b ) { + return cmp( a->getFileName(), b->getFileName() ); + } + private: + std::less cmp; + }; + + static const LastBackupCmp lastbackupcmp; + static const SizeCmp sizecmp; + static const NameCmp namecmp; + private: FileData( const FileData & ); @@ -47,27 +72,9 @@ std::istream &operator>>( std::istream &i, FileData *d ); std::ostream &operator<<( std::ostream &o, const FileData &d ); std::istream &operator>>( std::istream &i, FileData &d ); -struct FileDataLastBackupCmp { - bool operator()( const FileData *a, const FileData *b ) { - return a->getLastBackupDate() < b->getLastBackupDate(); - } -}; - -struct FileDataSizeCmp { - bool operator()( const FileData *a, const FileData *b ) { - return a->getFileSize() < b->getFileSize(); - } -}; - -struct FileDataNameCmp { - bool operator()( const FileData *a, const FileData *b ) { - return cmp( a->getFileName(), b->getFileName() ); - } - private: - std::less cmp; -}; +bool needs_backup( const FileData *before, const FileData *after ); -typedef std::set file_set; -typedef std::vector file_vector; +typedef std::set file_set; +typedef std::vector file_vector; #endif