libxcks  0.1.0.1
handlers.hpp
Go to the documentation of this file.
1 /*
2  * libxcks
3  * Copyright (C) 2022 Julien Couot
4  *
5  * This program is free software: you can redistribute it and/or modify it
6  * under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or (at your
8  * option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
13  * License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this program. If not, see <https://www.gnu.org/licenses/>.
17  */
18 
25 #ifndef INC_HANDLERS_HPP_48EADBB6_2C70_45A8_B132_289939A427CC
26 #define INC_HANDLERS_HPP_48EADBB6_2C70_45A8_B132_289939A427CC
27 
28 //---------------------------------------------------------------------------
29 // #include <string> // Included in "libxcks/types.hpp"
30 // #include <filesystem> // Included in "libxcks/types.hpp"
31 #include <ctime>
32 
33 #include "libxcks/export.hpp"
34 // #include "libxcks/types.hpp" // Included in "libxcks/ckvalue.hpp"
35 #include "libxcks/defs.hpp"
36 #include "libxcks/ckvalue.hpp"
37 //---------------------------------------------------------------------------
38 
39 
40 namespace libxcks
41 {
42 //###########################################################################
43 // XCKS reader handlers.
44 //###########################################################################
45 
49 class LIBXCKS_SO_EXPORT XCKSReaderHandler
50 {
51  public:
53  virtual ~XCKSReaderHandler() = default;
54 
60  virtual void onChecksumsFile(const std::string& version) = 0;
61 
69  virtual void onGenerated(const std::string& by, const std::string& version,
70  const std::time_t on) = 0;
71 
77  virtual void onAlgorithm(const ChecksumAlgoId type) = 0;
78 
82  virtual void onAlgorithmsStart() = 0;
83 
87  virtual void onAlgorithmsEnd() = 0;
88 
94  virtual void onAlgorithms(const ArrayChecksumAlgoId& types) = 0;
95 
99  virtual void onLocalFilesStart() = 0;
100 
104  virtual void onLocalFilesEnd() = 0;
105 
109  virtual void onParentDirectoryStart() = 0;
110 
116  virtual void onParentDirectoryStart(const std::filesystem::path& path) = 0;
117 
121  virtual void onParentDirectoryEnd() = 0;
122 
128  virtual void onDirectoryStart(const std::string name) = 0;
129 
135  virtual void onDirectoryStart(const std::filesystem::path& path) = 0;
136 
140  virtual void onDirectoryEnd() = 0;
141 
147  virtual void onFileStart(const std::string name) = 0;
148 
154  virtual void onFileStart(const std::filesystem::path& path) = 0;
155 
159  virtual void onFileEnd() = 0;
160 
167  virtual void onFileInformation(const uintmax_t size = Invalid_File_Size,
168  const time_t date = Invalid_DateTime) = 0;
169 
175  virtual void onFileChecksum(const ChecksumValue& value) = 0;
176 
185  virtual void onFile(const std::filesystem::path& path,
186  const ArrayChecksumValue& checksums,
187  const uintmax_t size = Invalid_File_Size,
188  const time_t date = Invalid_DateTime) = 0;
189 
200  virtual void onFatalError(const std::string& errorMessage, int line, int column) = 0;
201 };
202 //---------------------------------------------------------------------------
203 
204 
208 class LIBXCKS_SO_EXPORT XCKSReaderDefaultHandler : public XCKSReaderHandler
209 {
210  public:
212  virtual ~XCKSReaderDefaultHandler() = default;
213 
219  void onChecksumsFile(const std::string& version) override {}
220 
228  void onGenerated(const std::string& by, const std::string& version,
229  const std::time_t on) override {}
230 
236  void onAlgorithm(const ChecksumAlgoId type) override {}
237 
241  void onAlgorithmsStart() override {}
242 
246  void onAlgorithmsEnd() override {}
247 
253  void onAlgorithms(const ArrayChecksumAlgoId& types) override {}
254 
258  void onLocalFilesStart() override {}
259 
263  void onLocalFilesEnd() override {}
264 
268  void onParentDirectoryStart() override {}
269 
275  void onParentDirectoryStart(const std::filesystem::path& path) override {}
276 
280  void onParentDirectoryEnd() override {}
281 
287  void onDirectoryStart(const std::string name) override {}
288 
294  void onDirectoryStart(const std::filesystem::path& path) override {}
295 
299  void onDirectoryEnd() override {}
300 
306  void onFileStart(const std::string name) override {}
307 
313  void onFileStart(const std::filesystem::path& path) override {}
314 
318  void onFileEnd() override {}
319 
326  void onFileInformation(const uintmax_t size = Invalid_File_Size,
327  const time_t date = Invalid_DateTime) override {}
328 
334  void onFileChecksum(const ChecksumValue& value) override {}
335 
344  void onFile(const std::filesystem::path& path,
345  const ArrayChecksumValue& checksums,
346  const uintmax_t size = Invalid_File_Size,
347  const time_t date = Invalid_DateTime) override {}
348 
359  void onFatalError(const std::string& errorMessage, int line, int column) override {}
360 };
361 //---------------------------------------------------------------------------
362 
363 
364 
365 
366 //###########################################################################
367 // XCKS writer handlers.
368 //###########################################################################
369 
374 class LIBXCKS_SO_EXPORT XCKSWriterChecksumProvider
375 {
376  public:
378  enum class Status : int
379  {
380  Ok,
381  FileNotFound,
382  ReadError,
383  BadChecksumValue,
384  BadDuplicateValue,
385  MissingAlgorithm,
386  };
387 
390 
392  virtual ~XCKSWriterChecksumProvider() = default;
393 
411  uintmax_t& filesize,
412  time_t& filedatetime,
413  const ArrayChecksumAlgoId& ids,
414  const std::filesystem::path& filepath) = 0;
415 };
416 //---------------------------------------------------------------------------
417 
418 
422 class LIBXCKS_SO_EXPORT XCKSWriterHandler
423 {
424  public:
426  virtual ~XCKSWriterHandler() = default;
427 
433  virtual void onChecksumsFileStart(const std::string& version) = 0;
434 
440  virtual void onChecksumsFileEnd() = 0;
441 
449  virtual void onGenerated(const std::string& by, const std::string& version,
450  const std::time_t on) = 0;
451 
457  virtual void onAlgorithm(const ChecksumAlgoId type) = 0;
458 
462  virtual void onAlgorithmsStart() = 0;
463 
467  virtual void onAlgorithmsEnd() = 0;
468 
474  virtual void onAlgorithms(const ArrayChecksumAlgoId& types) = 0;
475 
479  virtual void onLocalFilesStart() = 0;
480 
484  virtual void onLocalFilesEnd() = 0;
485 
489  virtual void onParentDirectoryStart() = 0;
490 
496  virtual void onParentDirectoryStart(const std::filesystem::path& path) = 0;
497 
501  virtual void onParentDirectoryEnd() = 0;
502 
508  virtual void onDirectoryStart(const std::string name) = 0;
509 
515  virtual void onDirectoryStart(const std::filesystem::path& path) = 0;
516 
520  virtual void onDirectoryEnd() = 0;
521 
527  virtual void onFileStart(const std::string name) = 0;
528 
534  virtual void onFileStart(const std::filesystem::path& path) = 0;
535 
539  virtual void onFileEnd() = 0;
540 
547  virtual void onFileInformation(const uintmax_t size = Invalid_File_Size,
548  const time_t date = Invalid_DateTime) = 0;
549 
555  virtual void onFileChecksum(const ChecksumValue& value) = 0;
556 
565  virtual void onFile(const std::filesystem::path& path,
566  const ArrayChecksumValue& checksums,
567  const uintmax_t size = Invalid_File_Size,
568  const time_t date = Invalid_DateTime) = 0;
569 
584  virtual void onFileGetChecksumsError(const std::filesystem::path& relativePath,
585  const std::filesystem::path& absolutePath,
587  bool& stopWriting,
588  const ChecksumAlgoId algoId = ChecksumAlgoId::Invalid) = 0;
589 
601  virtual void onFileGetChecksumError(const std::filesystem::path& relativePath,
602  const std::filesystem::path& absolutePath,
604  const ChecksumValue& ckValue) = 0;
605 
611  virtual void onFatalError(const std::string& errorMessage) = 0;
612 };
613 //---------------------------------------------------------------------------
614 
615 
619 class LIBXCKS_SO_EXPORT XCKSWriterDefaultHandler : public XCKSWriterHandler
620 {
621  public:
623  virtual ~XCKSWriterDefaultHandler() = default;
624 
630  void onChecksumsFileStart(const std::string& version) override {}
631 
637  void onChecksumsFileEnd() override {}
638 
646  void onGenerated(const std::string& by, const std::string& version,
647  const std::time_t on) override {}
648 
654  void onAlgorithm(const ChecksumAlgoId type) override {}
655 
659  void onAlgorithmsStart() override {}
660 
664  void onAlgorithmsEnd() override {}
665 
671  void onAlgorithms(const ArrayChecksumAlgoId& types) override {}
672 
676  void onLocalFilesStart() override {}
677 
681  void onLocalFilesEnd() override {}
682 
686  void onParentDirectoryStart() override {}
687 
693  void onParentDirectoryStart(const std::filesystem::path& path) override {}
694 
698  void onParentDirectoryEnd() override {}
699 
705  void onDirectoryStart(const std::string name) override {}
706 
712  void onDirectoryStart(const std::filesystem::path& path) override {}
713 
717  void onDirectoryEnd() override {}
718 
724  void onFileStart(const std::string name) override {}
725 
731  void onFileStart(const std::filesystem::path& path) override {}
732 
736  void onFileEnd() override {}
737 
744  void onFileInformation(const uintmax_t size = Invalid_File_Size,
745  const time_t date = Invalid_DateTime) override {}
746 
752  void onFileChecksum(const ChecksumValue& value) override {}
753 
762  void onFile(const std::filesystem::path& path,
763  const ArrayChecksumValue& checksums,
764  const uintmax_t size = Invalid_File_Size,
765  const time_t date = Invalid_DateTime) override {}
766 
781  void onFileGetChecksumsError(const std::filesystem::path& relativePath,
782  const std::filesystem::path& absolutePath,
784  bool& stopWriting,
785  const ChecksumAlgoId algoId = ChecksumAlgoId::Invalid) override {}
786 
798  void onFileGetChecksumError(const std::filesystem::path& relativePath,
799  const std::filesystem::path& absolutePath,
801  const ChecksumValue& ckValue) override {}
802 
808  void onFatalError(const std::string& errorMessage) override {}
809 };
810 //---------------------------------------------------------------------------
811 
812 
813 
817 class LIBXCKS_SO_EXPORT XCKSWriterOptions
818 {
819  private:
820  bool writeGenerated;
821  bool writeSizeOfFile;
822  bool writeDateTimeOfFile;
823 
824  bool compactXML;
825  bool tabsforIndent;
826  unsigned int indentSpaces;
827 
828  bool checkReturnedCks;
829  std::string appWriter;
830  std::string appWriterVersion;
831  bool writeLibXCKSVer;
832 
833  static constexpr unsigned int max_indent_spaces = 16u;
834  protected:
835  static constexpr unsigned int default_indent_spaces = 2u;
836 
837  public:
870  XCKSWriterOptions(const bool writeGeneratedElement = true,
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);
880 
882  virtual ~XCKSWriterOptions() = default;
883 
890  virtual bool writeGeneratedElement() const final { return writeGenerated; }
891 
898  virtual void setWriteGeneratedElement(const bool writeGeneratedElement) final { writeGenerated = writeGeneratedElement; }
899 
906  virtual bool writeFileSize() const final { return writeSizeOfFile; }
907 
914  virtual void setWriteFileSize(const bool writeFileSize) final { writeSizeOfFile = writeFileSize; }
915 
922  virtual bool writeFileDateTime() const final { return writeDateTimeOfFile; }
923 
930  virtual void setWriteFileDateTime(const bool writeFileDateTime) final { writeDateTimeOfFile = writeFileDateTime; }
931 
938  virtual bool useCompactXML() const final { return compactXML; }
939 
946  virtual void setUseCompactXML(const bool useCompactXML) final { compactXML = useCompactXML; }
947 
954  virtual bool useTabsforIndentation() const final { return tabsforIndent; }
955 
962  virtual void setUseTabsforIndentation(const bool useTabsforIndentation) final { tabsforIndent = useTabsforIndentation; }
963 
970  virtual unsigned int getIndentSpaces() const final { return indentSpaces; }
971 
979  virtual void setIndentSpaces(const unsigned int nbIndentSpaces) final;
980 
988  virtual bool checkReturnedChecksums() const final { return checkReturnedCks; }
989 
999  virtual void setCheckReturnedChecksums(const bool checkReturnedChecksums) final { checkReturnedCks = checkReturnedChecksums; }
1000 
1007  virtual std::string getApplicationWriter() const final { return appWriter; }
1008 
1017  virtual void setApplicationWriter(const std::string& applicationWriter) final { appWriter = applicationWriter; }
1018 
1026  virtual std::string getApplicationWriterVersion() const final { return appWriterVersion; }
1027 
1035  virtual void setApplicationWriterVersion(const std::string& applicationVersion) final { appWriterVersion = applicationVersion; }
1036 
1047  virtual bool writeLibXCKSVersion() const final { return writeLibXCKSVer; }
1048 
1062  virtual void setWriteLibXCKSVersion(const bool writeLibXCKSVersion) final { writeLibXCKSVer = writeLibXCKSVersion; }
1063 };
1064 //---------------------------------------------------------------------------
1065 
1066 
1070 class LIBXCKS_SO_EXPORT ZXCKSWriterOptions : public XCKSWriterOptions
1071 {
1072  private:
1073  int compressionLevel;
1074 
1075  public:
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;
1079 
1114  ZXCKSWriterOptions(const bool writeGeneratedElement = true,
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);
1125 
1127  virtual ~ZXCKSWriterOptions() = default;
1128 
1134  virtual int getCompressionLevel() const final { return compressionLevel; }
1135 
1142  virtual void setCompressionLevel(const int level) final;
1143 };
1144 //---------------------------------------------------------------------------
1145 
1146 
1147 } // namespace libxcks
1148 //---------------------------------------------------------------------------
1149 
1150 #endif // INC_HANDLERS_HPP_48EADBB6_2C70_45A8_B132_289939A427CC
Stores the value of a checksum.
std::vector< ChecksumValue > ArrayChecksumValue
Array of values of checksum.
Definition: ckvalue.hpp:113
Stores the value of a checksum.
Definition: ckvalue.hpp:45
Default handler for reading XCKS files.
Definition: handlers.hpp:209
void onFatalError(const std::string &errorMessage, int line, int column) override
Called on a non-recoverable error.
Definition: handlers.hpp:359
void onFileStart(const std::filesystem::path &path) override
Called on read file start tag.
Definition: handlers.hpp:313
void onLocalFilesEnd() override
Called on read localFiles end tag.
Definition: handlers.hpp:263
void onAlgorithmsStart() override
Called on read algorithms start tag.
Definition: handlers.hpp:241
void onAlgorithms(const ArrayChecksumAlgoId &types) override
Called on read algorithms element.
Definition: handlers.hpp:253
void onParentDirectoryStart() override
Called on read parentDirectory start tag.
Definition: handlers.hpp:268
void onLocalFilesStart() override
Called on read localFiles start tag.
Definition: handlers.hpp:258
void onFileInformation(const uintmax_t size=Invalid_File_Size, const time_t date=Invalid_DateTime) override
Called on read information tag (for file).
Definition: handlers.hpp:326
void onAlgorithm(const ChecksumAlgoId type) override
Called on read algorithm element.
Definition: handlers.hpp:236
void onDirectoryEnd() override
Called on read directory end tag.
Definition: handlers.hpp:299
void onFileEnd() override
Called on read file end tag.
Definition: handlers.hpp:318
void onDirectoryStart(const std::filesystem::path &path) override
Called on read directory start tag.
Definition: handlers.hpp:294
void onParentDirectoryStart(const std::filesystem::path &path) override
Called on read parentDirectory start tag.
Definition: handlers.hpp:275
void onDirectoryStart(const std::string name) override
Called on read directory start tag.
Definition: handlers.hpp:287
void onGenerated(const std::string &by, const std::string &version, const std::time_t on) override
Called on read generated element.
Definition: handlers.hpp:228
void onChecksumsFile(const std::string &version) override
Called on read checksumsFile element.
Definition: handlers.hpp:219
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.
Definition: handlers.hpp:344
void onFileStart(const std::string name) override
Called on read file start tag.
Definition: handlers.hpp:306
void onAlgorithmsEnd() override
Called on read algorithms end tag.
Definition: handlers.hpp:246
void onFileChecksum(const ChecksumValue &value) override
Called on read checksum element (for file).
Definition: handlers.hpp:334
void onParentDirectoryEnd() override
Called on read parentDirectory end tag.
Definition: handlers.hpp:280
Handler for reading XCKS files.
Definition: handlers.hpp:50
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.
Definition: handlers.hpp:375
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().
Definition: handlers.hpp:379
Default handler for writing XCKS files.
Definition: handlers.hpp:620
void onParentDirectoryEnd() override
Called on write parentDirectory end tag.
Definition: handlers.hpp:698
void onParentDirectoryStart() override
Called on write parentDirectory start tag.
Definition: handlers.hpp:686
void onChecksumsFileEnd() override
Called on write checksumsFile end tag.
Definition: handlers.hpp:637
void onFatalError(const std::string &errorMessage) override
Called on a non-recoverable error.
Definition: handlers.hpp:808
void onDirectoryStart(const std::string name) override
Called on write directory start tag.
Definition: handlers.hpp:705
void onLocalFilesStart() override
Called on write localFiles start tag.
Definition: handlers.hpp:676
void onFileStart(const std::string name) override
Called on write file start tag.
Definition: handlers.hpp:724
void onAlgorithm(const ChecksumAlgoId type) override
Called on write algorithm element.
Definition: handlers.hpp:654
void onGenerated(const std::string &by, const std::string &version, const std::time_t on) override
Called on write generated element.
Definition: handlers.hpp:646
void onDirectoryStart(const std::filesystem::path &path) override
Called on write directory start tag.
Definition: handlers.hpp:712
void onLocalFilesEnd() override
Called on write localFiles end tag.
Definition: handlers.hpp:681
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.
Definition: handlers.hpp:781
void onParentDirectoryStart(const std::filesystem::path &path) override
Called on write parentDirectory start tag.
Definition: handlers.hpp:693
virtual ~XCKSWriterDefaultHandler()=default
Destructor.
void onDirectoryEnd() override
Called on write directory end tag.
Definition: handlers.hpp:717
void onChecksumsFileStart(const std::string &version) override
Called on write checksumsFile start tag.
Definition: handlers.hpp:630
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.
Definition: handlers.hpp:762
void onAlgorithmsEnd() override
Called on write algorithms end tag.
Definition: handlers.hpp:664
void onFileInformation(const uintmax_t size=Invalid_File_Size, const time_t date=Invalid_DateTime) override
Called on write information tag (for file).
Definition: handlers.hpp:744
void onAlgorithmsStart() override
Called on write algorithms start tag.
Definition: handlers.hpp:659
void onFileStart(const std::filesystem::path &path) override
Called on write file start tag.
Definition: handlers.hpp:731
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.
Definition: handlers.hpp:798
void onAlgorithms(const ArrayChecksumAlgoId &types) override
Called on write algorithms element.
Definition: handlers.hpp:671
void onFileChecksum(const ChecksumValue &value) override
Called on write checksum element (for file).
Definition: handlers.hpp:752
void onFileEnd() override
Called on write file end tag.
Definition: handlers.hpp:736
Handler for writing XCKS files.
Definition: handlers.hpp:423
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.
Definition: handlers.hpp:818
virtual bool writeGeneratedElement() const final
Indicates whether the generated element must be written in the XCKS file.
Definition: handlers.hpp:890
virtual ~XCKSWriterOptions()=default
Destructor.
virtual bool useCompactXML() const final
Indicates whether the XCKS file must be written in its compact form or not.
Definition: handlers.hpp:938
virtual void setUseTabsforIndentation(const bool useTabsforIndentation) final
Sets which type of indentation should be used when writing the XCKS file.
Definition: handlers.hpp:962
virtual bool writeFileDateTime() const final
Indicates whether the files' date/time must be written in the XCKS file.
Definition: handlers.hpp:922
virtual unsigned int getIndentSpaces() const final
Returns the number of spaces to use for indention (meaningful only if useTabsforIndentation() returns...
Definition: handlers.hpp:970
virtual bool writeLibXCKSVersion() const final
Indicates whether the name and version of the libxcks must be written with the application name and v...
Definition: handlers.hpp:1047
virtual void setWriteFileSize(const bool writeFileSize) final
Sets if the files' size must be written in the XCKS file.
Definition: handlers.hpp:914
virtual void setApplicationWriterVersion(const std::string &applicationVersion) final
Sets the version of the application using libxcks to write the XCKS file.
Definition: handlers.hpp:1035
virtual void setCheckReturnedChecksums(const bool checkReturnedChecksums) final
Sets if all checksums values returned by an XCKSWriterChecksumProvider instance must be verified.
Definition: handlers.hpp:999
virtual void setUseCompactXML(const bool useCompactXML) final
Sets if the XCKS file must be written in its compact form or not.
Definition: handlers.hpp:946
virtual void setApplicationWriter(const std::string &applicationWriter) final
Sets the name of the application using libxcks to write the XCKS file.
Definition: handlers.hpp:1017
virtual bool checkReturnedChecksums() const final
Indicates whether all checksums values returned by an XCKSWriterChecksumProvider instance must be ver...
Definition: handlers.hpp:988
virtual std::string getApplicationWriter() const final
Gets the name of the application using libxcks to write the XCKS file.
Definition: handlers.hpp:1007
virtual std::string getApplicationWriterVersion() const final
Gets the version of the application using libxcks to write the XCKS file.
Definition: handlers.hpp:1026
virtual void setWriteFileDateTime(const bool writeFileDateTime) final
Sets if the files' date/time must be written in the XCKS file.
Definition: handlers.hpp:930
virtual void setWriteGeneratedElement(const bool writeGeneratedElement) final
Sets if the generated element must be written in the XCKS file.
Definition: handlers.hpp:898
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.
Definition: handlers.hpp:1062
virtual bool useTabsforIndentation() const final
Indicates which type of indentation should be used when writing the XCKS file.
Definition: handlers.hpp:954
virtual bool writeFileSize() const final
Indicates whether the files' size must be written in the XCKS file.
Definition: handlers.hpp:906
Provides options for the XCKS writer.
Definition: handlers.hpp:1071
virtual int getCompressionLevel() const final
Returns the compression level to use.
Definition: handlers.hpp:1134
virtual ~ZXCKSWriterOptions()=default
Destructor.
Common definitions for libxcks.
OS dependent exports defines.
std::vector< ChecksumAlgoId > ArrayChecksumAlgoId
Array of ids of algorithms of checksums.
Definition: types.hpp:92
ChecksumAlgoId
Ids of algorithms of checksums.
Definition: types.hpp:65