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>
9#include <c++utilities/misc/flagenumclass.h>
43 explicit PasswordFile(
const std::string &path,
const std::string &password);
47 CppUtilities::NativeFileStream &fileStream();
50 void generateRootEntry();
59 void exportToTextfile(
const std::string &targetPath)
const;
61 bool hasRootEntry()
const;
64 const std::string &path()
const;
65 const std::string &password()
const;
66 void setPath(
const std::string &value);
68 void setPassword(
const std::string &password);
69 void setPassword(
const char *password,
const std::size_t passwordSize);
71 bool isEncryptionUsed();
73 std::string &extendedHeader();
74 const std::string &extendedHeader()
const;
75 std::string &encryptedExtendedHeader();
76 const std::string &encryptedExtendedHeader()
const;
78 std::uint32_t version()
const;
85 std::string m_password;
86 std::unique_ptr<NodeEntry> m_rootEntry;
87 std::string m_extendedHeader;
88 std::string m_encryptedExtendedHeader;
89 CppUtilities::NativeFileStream m_file;
90 CppUtilities::BinaryReader m_freader;
91 CppUtilities::BinaryWriter m_fwriter;
92 std::uint32_t m_version;
143 m_password.assign(
password, passwordSize);
159 return m_file.is_open();
167 return m_extendedHeader;
175 return m_extendedHeader;
183 return m_encryptedExtendedHeader;
191 return m_encryptedExtendedHeader;
208 return m_openOptions;
216 return m_saveOptions;
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...
PasswordFileOpenFlags openOptions() const
Returns the options used to open the file.
bool isOpen() const
Returns an indication whether the file is open.
void close()
Closes the file if currently opened.
std::uint32_t version() const
Returns the file version used the last time when saving the file (the version of the file as it is on...
CppUtilities::NativeFileStream & fileStream()
Returns the underlying file stream.
void clearPassword()
Clears the current password.
const std::string & password() const
Returns the current password.
void setPassword(const std::string &password)
Sets the current password.
const std::string & path() const
Returns the current file path.
void setPassword(const char *password, const std::size_t passwordSize)
std::string & encryptedExtendedHeader()
Returns the encrypted extended header.
std::string & extendedHeader()
Returns the extended header.
void clearPath()
Clears the current path.
PasswordFileSaveFlags saveOptions() const
Returns the save options used the last time when saving the file.
#define PASSWORD_FILE_EXPORT
Marks the symbol to be exported by the passwordfile library.
Contains all IO related classes.
PASSWORD_FILE_EXPORT std::string flagsToString(PasswordFileOpenFlags flags)
Returns a comma-separated string for the specified flags.
CPP_UTILITIES_MARK_FLAG_ENUM_CLASS(Io, Io::PasswordFileOpenFlags)