25 #ifndef INC_HANDLERS_HPP_48EADBB6_2C70_45A8_B132_289939A427CC
26 #define INC_HANDLERS_HPP_48EADBB6_2C70_45A8_B132_289939A427CC
69 virtual void onGenerated(
const std::string& by,
const std::string& version,
70 const std::time_t on) = 0;
168 const time_t date = Invalid_DateTime) = 0;
185 virtual void onFile(
const std::filesystem::path& path,
187 const uintmax_t size = Invalid_File_Size,
188 const time_t date = Invalid_DateTime) = 0;
200 virtual void onFatalError(
const std::string& errorMessage,
int line,
int column) = 0;
228 void onGenerated(
const std::string& by,
const std::string& version,
229 const std::time_t on)
override {}
327 const time_t date = Invalid_DateTime)
override {}
344 void onFile(
const std::filesystem::path& path,
346 const uintmax_t size = Invalid_File_Size,
347 const time_t date = Invalid_DateTime)
override {}
359 void onFatalError(
const std::string& errorMessage,
int line,
int column)
override {}
412 time_t& filedatetime,
414 const std::filesystem::path& filepath) = 0;
449 virtual void onGenerated(
const std::string& by,
const std::string& version,
450 const std::time_t on) = 0;
548 const time_t date = Invalid_DateTime) = 0;
565 virtual void onFile(
const std::filesystem::path& path,
567 const uintmax_t size = Invalid_File_Size,
568 const time_t date = Invalid_DateTime) = 0;
585 const std::filesystem::path& absolutePath,
602 const std::filesystem::path& absolutePath,
646 void onGenerated(
const std::string& by,
const std::string& version,
647 const std::time_t on)
override {}
745 const time_t date = Invalid_DateTime)
override {}
762 void onFile(
const std::filesystem::path& path,
764 const uintmax_t size = Invalid_File_Size,
765 const time_t date = Invalid_DateTime)
override {}
782 const std::filesystem::path& absolutePath,
785 const ChecksumAlgoId algoId = ChecksumAlgoId::Invalid)
override {}
799 const std::filesystem::path& absolutePath,
821 bool writeSizeOfFile;
822 bool writeDateTimeOfFile;
826 unsigned int indentSpaces;
828 bool checkReturnedCks;
829 std::string appWriter;
830 std::string appWriterVersion;
831 bool writeLibXCKSVer;
833 static constexpr
unsigned int max_indent_spaces = 16u;
835 static constexpr
unsigned int default_indent_spaces = 2u;
871 const bool writeFileSize =
true,
872 const bool writeFileDateTime =
true,
873 const bool useCompactXML =
false,
874 const bool useTabsforIndentation =
false,
875 const unsigned int nbIndentSpaces = default_indent_spaces,
876 const bool checkReturnedChecksums =
true,
877 const std::string applicationWriter = std::string(),
878 const std::string applicationVersion = std::string(),
879 const bool writeLibXCKSVersion =
false);
914 virtual void setWriteFileSize(
const bool writeFileSize)
final { writeSizeOfFile = writeFileSize; }
930 virtual void setWriteFileDateTime(
const bool writeFileDateTime)
final { writeDateTimeOfFile = writeFileDateTime; }
946 virtual void setUseCompactXML(
const bool useCompactXML)
final { compactXML = useCompactXML; }
979 virtual void setIndentSpaces(
const unsigned int nbIndentSpaces)
final;
1073 int compressionLevel;
1076 static constexpr
int min_compression_level = 1;
1077 static constexpr
int max_compression_level = 9;
1078 static constexpr
int default_compression_level = max_compression_level;
1115 const bool writeFileSize =
true,
1116 const bool writeFileDateTime =
true,
1117 const bool useCompactXML =
true,
1118 const bool useTabsforIndentation =
false,
1119 const unsigned int nbIndentSpaces = default_indent_spaces,
1120 const bool checkReturnedChecksums =
true,
1121 const std::string applicationWriter = std::string(),
1122 const std::string applicationVersion = std::string(),
1123 const bool writeLibXCKSVersion =
false,
1124 const int compressionLevel = default_compression_level);
1142 virtual void setCompressionLevel(
const int level)
final;
Stores the value of a checksum.
std::vector< ChecksumValue > ArrayChecksumValue
Array of values of checksum.
Stores the value of a checksum.
Default handler for reading XCKS files.
void onFatalError(const std::string &errorMessage, int line, int column) override
Called on a non-recoverable error.
void onFileStart(const std::filesystem::path &path) override
Called on read file start tag.
void onLocalFilesEnd() override
Called on read localFiles end tag.
void onAlgorithmsStart() override
Called on read algorithms start tag.
void onAlgorithms(const ArrayChecksumAlgoId &types) override
Called on read algorithms element.
void onParentDirectoryStart() override
Called on read parentDirectory start tag.
void onLocalFilesStart() override
Called on read localFiles start tag.
void onFileInformation(const uintmax_t size=Invalid_File_Size, const time_t date=Invalid_DateTime) override
Called on read information tag (for file).
void onAlgorithm(const ChecksumAlgoId type) override
Called on read algorithm element.
void onDirectoryEnd() override
Called on read directory end tag.
void onFileEnd() override
Called on read file end tag.
void onDirectoryStart(const std::filesystem::path &path) override
Called on read directory start tag.
void onParentDirectoryStart(const std::filesystem::path &path) override
Called on read parentDirectory start tag.
void onDirectoryStart(const std::string name) override
Called on read directory start tag.
void onGenerated(const std::string &by, const std::string &version, const std::time_t on) override
Called on read generated element.
void onChecksumsFile(const std::string &version) override
Called on read checksumsFile element.
virtual ~XCKSReaderDefaultHandler()=default
Destructor.
void onFile(const std::filesystem::path &path, const ArrayChecksumValue &checksums, const uintmax_t size=Invalid_File_Size, const time_t date=Invalid_DateTime) override
Called on read file element.
void onFileStart(const std::string name) override
Called on read file start tag.
void onAlgorithmsEnd() override
Called on read algorithms end tag.
void onFileChecksum(const ChecksumValue &value) override
Called on read checksum element (for file).
void onParentDirectoryEnd() override
Called on read parentDirectory end tag.
Handler for reading XCKS files.
virtual void onParentDirectoryStart(const std::filesystem::path &path)=0
Called on read parentDirectory start tag.
virtual void onFileInformation(const uintmax_t size=Invalid_File_Size, const time_t date=Invalid_DateTime)=0
Called on read information tag (for file).
virtual void onFileChecksum(const ChecksumValue &value)=0
Called on read checksum element (for file).
virtual void onParentDirectoryStart()=0
Called on read parentDirectory start tag.
virtual void onChecksumsFile(const std::string &version)=0
Called on read checksumsFile element.
virtual void onDirectoryStart(const std::string name)=0
Called on read directory start tag.
virtual void onAlgorithmsStart()=0
Called on read algorithms start tag.
virtual void onFile(const std::filesystem::path &path, const ArrayChecksumValue &checksums, const uintmax_t size=Invalid_File_Size, const time_t date=Invalid_DateTime)=0
Called on read file element.
virtual void onFileEnd()=0
Called on read file end tag.
virtual void onFatalError(const std::string &errorMessage, int line, int column)=0
Called on a non-recoverable error.
virtual void onAlgorithms(const ArrayChecksumAlgoId &types)=0
Called on read algorithms element.
virtual void onAlgorithm(const ChecksumAlgoId type)=0
Called on read algorithm element.
virtual void onDirectoryStart(const std::filesystem::path &path)=0
Called on read directory start tag.
virtual ~XCKSReaderHandler()=default
Destructor.
virtual void onLocalFilesStart()=0
Called on read localFiles start tag.
virtual void onFileStart(const std::string name)=0
Called on read file start tag.
virtual void onDirectoryEnd()=0
Called on read directory end tag.
virtual void onFileStart(const std::filesystem::path &path)=0
Called on read file start tag.
virtual void onGenerated(const std::string &by, const std::string &version, const std::time_t on)=0
Called on read generated element.
virtual void onAlgorithmsEnd()=0
Called on read algorithms end tag.
virtual void onParentDirectoryEnd()=0
Called on read parentDirectory end tag.
virtual void onLocalFilesEnd()=0
Called on read localFiles end tag.
Provides checksums values from an array of wanted algorithms of checksums for the XCKS writer.
virtual Status getChecksumValues(ArrayChecksumValue &sumValues, uintmax_t &filesize, time_t &filedatetime, const ArrayChecksumAlgoId &ids, const std::filesystem::path &filepath)=0
Provides checksums values from an array of wanted algorithms of checksums.
XCKSWriterChecksumProvider()=default
Default constructor.
virtual ~XCKSWriterChecksumProvider()=default
Destructor.
Status
Return status of getChecksumValues().
Default handler for writing XCKS files.
void onParentDirectoryEnd() override
Called on write parentDirectory end tag.
void onParentDirectoryStart() override
Called on write parentDirectory start tag.
void onChecksumsFileEnd() override
Called on write checksumsFile end tag.
void onFatalError(const std::string &errorMessage) override
Called on a non-recoverable error.
void onDirectoryStart(const std::string name) override
Called on write directory start tag.
void onLocalFilesStart() override
Called on write localFiles start tag.
void onFileStart(const std::string name) override
Called on write file start tag.
void onAlgorithm(const ChecksumAlgoId type) override
Called on write algorithm element.
void onGenerated(const std::string &by, const std::string &version, const std::time_t on) override
Called on write generated element.
void onDirectoryStart(const std::filesystem::path &path) override
Called on write directory start tag.
void onLocalFilesEnd() override
Called on write localFiles end tag.
void onFileGetChecksumsError(const std::filesystem::path &relativePath, const std::filesystem::path &absolutePath, const XCKSWriterChecksumProvider::Status status, bool &stopWriting, const ChecksumAlgoId algoId=ChecksumAlgoId::Invalid) override
Called on a failure on getting the checksums values for a file.
void onParentDirectoryStart(const std::filesystem::path &path) override
Called on write parentDirectory start tag.
virtual ~XCKSWriterDefaultHandler()=default
Destructor.
void onDirectoryEnd() override
Called on write directory end tag.
void onChecksumsFileStart(const std::string &version) override
Called on write checksumsFile start tag.
void onFile(const std::filesystem::path &path, const ArrayChecksumValue &checksums, const uintmax_t size=Invalid_File_Size, const time_t date=Invalid_DateTime) override
Called on write file element.
void onAlgorithmsEnd() override
Called on write algorithms end tag.
void onFileInformation(const uintmax_t size=Invalid_File_Size, const time_t date=Invalid_DateTime) override
Called on write information tag (for file).
void onAlgorithmsStart() override
Called on write algorithms start tag.
void onFileStart(const std::filesystem::path &path) override
Called on write file start tag.
void onFileGetChecksumError(const std::filesystem::path &relativePath, const std::filesystem::path &absolutePath, const XCKSWriterChecksumProvider::Status status, const ChecksumValue &ckValue) override
Called on a failure on verifying a checksums value for a file.
void onAlgorithms(const ArrayChecksumAlgoId &types) override
Called on write algorithms element.
void onFileChecksum(const ChecksumValue &value) override
Called on write checksum element (for file).
void onFileEnd() override
Called on write file end tag.
Handler for writing XCKS files.
virtual void onFatalError(const std::string &errorMessage)=0
Called on a non-recoverable error.
virtual void onChecksumsFileEnd()=0
Called on write checksumsFile end tag.
virtual void onParentDirectoryStart()=0
Called on write parentDirectory start tag.
virtual ~XCKSWriterHandler()=default
Destructor.
virtual void onFileChecksum(const ChecksumValue &value)=0
Called on write checksum element (for file).
virtual void onFile(const std::filesystem::path &path, const ArrayChecksumValue &checksums, const uintmax_t size=Invalid_File_Size, const time_t date=Invalid_DateTime)=0
Called on write file element.
virtual void onDirectoryEnd()=0
Called on write directory end tag.
virtual void onAlgorithms(const ArrayChecksumAlgoId &types)=0
Called on write algorithms element.
virtual void onParentDirectoryEnd()=0
Called on write parentDirectory end tag.
virtual void onChecksumsFileStart(const std::string &version)=0
Called on write checksumsFile start tag.
virtual void onDirectoryStart(const std::filesystem::path &path)=0
Called on write directory start tag.
virtual void onFileGetChecksumsError(const std::filesystem::path &relativePath, const std::filesystem::path &absolutePath, const XCKSWriterChecksumProvider::Status status, bool &stopWriting, const ChecksumAlgoId algoId=ChecksumAlgoId::Invalid)=0
Called on a failure on getting the checksums values for a file.
virtual void onLocalFilesStart()=0
Called on write localFiles start tag.
virtual void onAlgorithmsEnd()=0
Called on write algorithms end tag.
virtual void onGenerated(const std::string &by, const std::string &version, const std::time_t on)=0
Called on write generated element.
virtual void onFileGetChecksumError(const std::filesystem::path &relativePath, const std::filesystem::path &absolutePath, const XCKSWriterChecksumProvider::Status status, const ChecksumValue &ckValue)=0
Called on a failure on verifying a checksums value for a file.
virtual void onFileStart(const std::filesystem::path &path)=0
Called on write file start tag.
virtual void onAlgorithm(const ChecksumAlgoId type)=0
Called on write algorithm element.
virtual void onFileInformation(const uintmax_t size=Invalid_File_Size, const time_t date=Invalid_DateTime)=0
Called on write information tag (for file).
virtual void onDirectoryStart(const std::string name)=0
Called on write directory start tag.
virtual void onLocalFilesEnd()=0
Called on write localFiles end tag.
virtual void onParentDirectoryStart(const std::filesystem::path &path)=0
Called on write parentDirectory start tag.
virtual void onAlgorithmsStart()=0
Called on write algorithms start tag.
virtual void onFileStart(const std::string name)=0
Called on write file start tag.
virtual void onFileEnd()=0
Called on write file end tag.
Provides options for the XCKS writer.
virtual bool writeGeneratedElement() const final
Indicates whether the generated element must be written in the XCKS file.
virtual ~XCKSWriterOptions()=default
Destructor.
virtual bool useCompactXML() const final
Indicates whether the XCKS file must be written in its compact form or not.
virtual void setUseTabsforIndentation(const bool useTabsforIndentation) final
Sets which type of indentation should be used when writing the XCKS file.
virtual bool writeFileDateTime() const final
Indicates whether the files' date/time must be written in the XCKS file.
virtual unsigned int getIndentSpaces() const final
Returns the number of spaces to use for indention (meaningful only if useTabsforIndentation() returns...
virtual bool writeLibXCKSVersion() const final
Indicates whether the name and version of the libxcks must be written with the application name and v...
virtual void setWriteFileSize(const bool writeFileSize) final
Sets if the files' size must be written in the XCKS file.
virtual void setApplicationWriterVersion(const std::string &applicationVersion) final
Sets the version of the application using libxcks to write the XCKS file.
virtual void setCheckReturnedChecksums(const bool checkReturnedChecksums) final
Sets if all checksums values returned by an XCKSWriterChecksumProvider instance must be verified.
virtual void setUseCompactXML(const bool useCompactXML) final
Sets if the XCKS file must be written in its compact form or not.
virtual void setApplicationWriter(const std::string &applicationWriter) final
Sets the name of the application using libxcks to write the XCKS file.
virtual bool checkReturnedChecksums() const final
Indicates whether all checksums values returned by an XCKSWriterChecksumProvider instance must be ver...
virtual std::string getApplicationWriter() const final
Gets the name of the application using libxcks to write the XCKS file.
virtual std::string getApplicationWriterVersion() const final
Gets the version of the application using libxcks to write the XCKS file.
virtual void setWriteFileDateTime(const bool writeFileDateTime) final
Sets if the files' date/time must be written in the XCKS file.
virtual void setWriteGeneratedElement(const bool writeGeneratedElement) final
Sets if the generated element must be written in the XCKS file.
virtual void setWriteLibXCKSVersion(const bool writeLibXCKSVersion) final
Sets if the name and version of the libxcks must be written with the application name and version.
virtual bool useTabsforIndentation() const final
Indicates which type of indentation should be used when writing the XCKS file.
virtual bool writeFileSize() const final
Indicates whether the files' size must be written in the XCKS file.
Provides options for the XCKS writer.
virtual int getCompressionLevel() const final
Returns the compression level to use.
virtual ~ZXCKSWriterOptions()=default
Destructor.
Common definitions for libxcks.
OS dependent exports defines.
std::vector< ChecksumAlgoId > ArrayChecksumAlgoId
Array of ids of algorithms of checksums.
ChecksumAlgoId
Ids of algorithms of checksums.