Passwordfile library  3.1.4
C++ library to read/write passwords from/to encrypted files
passwordfile.h
Go to the documentation of this file.
1 #ifndef PASSWORDFILE_H
2 #define PASSWORDFILE_H
3 
4 #include "../global.h"
5 
6 #include <c++utilities/io/binaryreader.h>
7 #include <c++utilities/io/binarywriter.h>
8 
9 #include <fstream>
10 #include <iostream>
11 #include <memory>
12 #include <string>
13 
14 namespace Io {
15 
16 class NodeEntry;
17 
19 public:
20  explicit PasswordFile();
21  explicit PasswordFile(const std::string &path, const std::string &password);
22  PasswordFile(const PasswordFile &other);
23  ~PasswordFile();
24  void open(bool readOnly = false);
25  void generateRootEntry();
26  void create();
27  void close();
28  void load();
29  void save(bool useEncryption = true, bool useCompression = true);
30  void clearEntries();
31  void clear();
32  void exportToTextfile(const std::string &targetPath) const;
33  void doBackup();
34  bool hasRootEntry() const;
35  const NodeEntry *rootEntry() const;
36  NodeEntry *rootEntry();
37  const std::string &path() const;
38  const char *password() const;
39  void setPath(const std::string &value);
40  void clearPath();
41  void setPassword(const std::string &value);
42  void clearPassword();
43  bool isEncryptionUsed();
44  bool isOpen() const;
45  size_t size();
46 
47 private:
48  std::string m_path;
49  char m_password[32];
50  std::unique_ptr<NodeEntry> m_rootEntry;
51  std::string m_extendedHeader;
52  std::string m_encryptedExtendedHeader;
53  std::fstream m_file;
54  IoUtilities::BinaryReader m_freader;
55  IoUtilities::BinaryWriter m_fwriter;
56 };
57 }
58 
59 #endif // PASSWORDFILE_H
The NodeEntry class acts as parent for other entries.
Definition: entry.h:95
The PasswordFile class holds account information in the form of Entry and Field instances and provide...
Definition: passwordfile.h:18
Contains all IO related classes.
#define PASSWORD_FILE_EXPORT
Marks the symbol to be exported by the passwordfile library.