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