#include <string>
#include <set>
#include <vector>
+#include <cassert>
class FileData {
public:
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<std::string> cmp;
+ };
+
+ static const LastBackupCmp lastbackupcmp;
+ static const SizeCmp sizecmp;
+ static const NameCmp namecmp;
+
private:
FileData( const FileData & );
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<std::string> cmp;
-};
+bool needs_backup( const FileData *before, const FileData *after );
-typedef std::set<FileData*,FileDataNameCmp> file_set;
-typedef std::vector<FileData*> file_vector;
+typedef std::set<FileData*,FileData::NameCmp> file_set;
+typedef std::vector<FileData*> file_vector;
#endif