Regular commit
[backups/.git] / filedata.hpp
1 #ifndef FILEDATA_H
2 #define FILEDATA_H
3
4 #include <string>
5 #include <set>
6 #include <vector>
7
8 class FileData {
9   public:
10     // Construct a FileData object with default values
11     FileData( char,
12               std::string,
13               std::string,
14               std::string,
15               unsigned long long,
16               unsigned long long,
17               std::string,
18               unsigned long long = 0
19               );
20
21     char               getFileType()       const { return filetype; }
22     const std::string &getPermissions()    const { return permissions; }
23     const std::string &getUserName()       const { return username; }
24     const std::string &getGroupName()      const { return groupname; }
25     unsigned long long getFileSize()       const { return filesize; }
26     unsigned long long getModifiedDate()   const { return modified_date; }
27     const std::string &getFileName()       const { return filename; }
28     unsigned long long getLastBackupDate() const { return last_backup_date; }
29
30     void setFileType(       char               arg ) { filetype         = arg; }
31     void setPermissions(    const std::string &arg ) { permissions      = arg; }
32     void setUserName(       const std::string &arg ) { username         = arg; }
33     void setGroupName(      const std::string &arg ) { groupname        = arg; }
34     void setFileSize(       unsigned long long arg ) { filesize         = arg; }
35     void setModifiedDate(   unsigned long long arg ) { modified_date    = arg; }
36     void setFileName(       const std::string &arg ) { filename         = arg; }
37     void setLastBackupDate( unsigned long long arg ) { last_backup_date = arg; }
38
39   private:
40     FileData();
41     FileData( const FileData & );
42
43     char               filetype;
44     std::string        permissions;
45     std::string        username;
46     std::string        groupname;
47     unsigned long long filesize;
48     unsigned long long modified_date;
49     std::string        filename;
50
51     unsigned long long last_backup_date;
52 };
53
54 struct FileDataLastBackupCmp {
55   bool operator()( const FileData *a, const FileData *b ) {
56     return a->getLastBackupDate() < b->getLastBackupDate();
57   }
58 };
59
60 struct FileDataSizeCmp {
61   bool operator()( const FileData *a, const FileData *b ) {
62     return a->getFileSize() < b->getFileSize();
63   }
64 };
65
66 struct FileDataNameCmp {
67   bool operator()( const FileData *a, const FileData *b ) {
68     return cmp( a->getFileName(), b->getFileName() );
69   }
70   private:
71     std::less<std::string> cmp;
72 };
73
74 typedef std::set<FileData*,FileDataNameCmp> file_set;
75 typedef std::vector<FileData*> file_vector;
76
77 #endif