1 #ifndef PASSWORD_FILE_IO_PASSWORD_FILE_H 2 #define PASSWORD_FILE_IO_PASSWORD_FILE_H 6 #include <c++utilities/io/binaryreader.h> 7 #include <c++utilities/io/binarywriter.h> 8 #include <c++utilities/io/nativefilestream.h> 30 static_cast<std::underlying_type<PasswordFileOpenFlags>::type
>(lhs) |
static_cast<std::underlying_type<PasswordFileOpenFlags>::type
>(rhs));
35 return lhs =
static_cast<PasswordFileOpenFlags>(
static_cast<std::underlying_type<PasswordFileOpenFlags>::type
>(lhs)
36 |
static_cast<std::underlying_type<PasswordFileOpenFlags>::type
>(rhs));
41 return static_cast<bool>(
42 static_cast<std::underlying_type<PasswordFileOpenFlags>::type
>(lhs) &
static_cast<std::underlying_type<PasswordFileOpenFlags>::type
>(rhs));
58 static_cast<std::underlying_type<PasswordFileSaveFlags>::type
>(lhs) |
static_cast<std::underlying_type<PasswordFileSaveFlags>::type
>(rhs));
63 return lhs =
static_cast<PasswordFileSaveFlags>(
static_cast<std::underlying_type<PasswordFileSaveFlags>::type
>(lhs)
64 |
static_cast<std::underlying_type<PasswordFileSaveFlags>::type
>(rhs));
69 return static_cast<bool>(
70 static_cast<std::underlying_type<PasswordFileSaveFlags>::type
>(lhs) &
static_cast<std::underlying_type<PasswordFileSaveFlags>::type
>(rhs));
76 explicit PasswordFile(
const std::string &path,
const std::string &password);
80 IoUtilities::NativeFileStream &fileStream();
83 void generateRootEntry();
92 void exportToTextfile(
const std::string &targetPath)
const;
94 bool hasRootEntry()
const;
97 const std::string &path()
const;
98 const std::string &password()
const;
99 void setPath(
const std::string &value);
101 void setPassword(
const std::string &password);
102 void setPassword(
const char *password,
const std::size_t passwordSize);
103 void clearPassword();
104 bool isEncryptionUsed();
106 std::string &extendedHeader();
107 const std::string &extendedHeader()
const;
108 std::string &encryptedExtendedHeader();
109 const std::string &encryptedExtendedHeader()
const;
111 uint32 version()
const;
118 std::string m_password;
119 std::unique_ptr<NodeEntry> m_rootEntry;
120 std::string m_extendedHeader;
121 std::string m_encryptedExtendedHeader;
122 IoUtilities::NativeFileStream m_file;
123 IoUtilities::BinaryReader m_freader;
124 IoUtilities::BinaryWriter m_fwriter;
176 m_password.assign(
password, passwordSize);
192 return m_file.is_open();
200 return m_extendedHeader;
208 return m_extendedHeader;
216 return m_encryptedExtendedHeader;
224 return m_encryptedExtendedHeader;
241 return m_openOptions;
249 return m_saveOptions;
254 #endif // PASSWORD_FILE_IO_PASSWORD_FILE_H The NodeEntry class acts as parent for other entries.
The PasswordFile class holds account information in the form of Entry and Field instances and provide...
std::string & encryptedExtendedHeader()
Returns the encrypted extended header.
std::string PASSWORD_FILE_EXPORT flagsToString(PasswordFileOpenFlags flags)
Returns a comma-separated string for the specified flags.
void close()
Closes the file if currently opened.
Contains all IO related classes.
PasswordFileOpenFlags openOptions() const
Returns the options used to open the file.
bool isOpen() const
Returns an indication whether the file is open.
void clearPath()
Clears the current path.
const std::string & path() const
Returns the current file path.
void setPassword(const std::string &password)
Sets the current password.
#define PASSWORD_FILE_EXPORT
Marks the symbol to be exported by the passwordfile library.
std::string & extendedHeader()
Returns the extended header.
const std::string & password() const
Returns the current password.
constexpr bool operator &(PasswordFileOpenFlags lhs, PasswordFileOpenFlags rhs)
uint32 version() const
Returns the file version used the last time when saving the file (the version of the file as it is on...
void clearPassword()
Clears the current password.
constexpr PasswordFileOpenFlags operator|(PasswordFileOpenFlags lhs, PasswordFileOpenFlags rhs)
constexpr PasswordFileOpenFlags & operator|=(PasswordFileOpenFlags &lhs, PasswordFileOpenFlags rhs)
IoUtilities::NativeFileStream & fileStream()
Returns the underlying file stream.
PasswordFileSaveFlags saveOptions() const
Returns the save options used the last time when saving the file.