libxcks  0.1.0.1
xckswriter.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_XCKSWRITER_HPP_0FFE21B6_E2AF_4985_9134_279C8EE17E5D
26 #define INC_XCKSWRITER_HPP_0FFE21B6_E2AF_4985_9134_279C8EE17E5D
27 
28 //---------------------------------------------------------------------------
29 #include <ostream>
30 // #include <filesystem> // Included in "libxcks/types.hpp"
31 // #include <string> // Included in "libxcks/types.hpp"
32 
33 // #include "libxcks/types.hpp" // Included in #include "libxcks/handlers.hpp"
34 // #include "libxcks/defs.hpp" // Included in #include "libxcks/handlers.hpp"
35 // #include "libxcks/export.hpp" // Included in #include "libxcks/handlers.hpp"
36 #include "libxcks/handlers.hpp"
37 #include "libxcks/ckformatter.hpp"
38 //---------------------------------------------------------------------------
39 
40 
41 namespace libxcks
42 {
46 class LIBXCKS_SO_EXPORT XCKSWriter
47 {
48  protected:
52  const Version version;
55 
56  public:
58  XCKSWriter() = delete;
59 
61  XCKSWriter(const XCKSWriter&) = delete;
62 
64  XCKSWriter& operator=(const XCKSWriter&) = delete;
65 
79  XCKSWriter(XCKSWriterHandler& xcksWriterHandler,
80  XCKSWriterChecksumProvider& checksumProvider,
81  const XCKSWriterOptions& options,
82  const Version version,
83  const ArrayChecksumAlgoId& algoIds,
84  const ChecksumFormatter::ConfigurationProvider& ckftConfProvider);
85 
87  virtual ~XCKSWriter();
88 
107  bool write(std::ostream& os, const std::filesystem::path& basePath,
108  const ArrayPath& relativePaths);
109 
127  bool write(const std::filesystem::path& fileFullPath,
128  const ArrayPath& relativePaths);
129 
130 
151  bool write(const std::filesystem::path& filePath,
152  const std::filesystem::path& basePath,
153  const ArrayPath& relativePaths);
154 
155  // Since we need some more complicated handlers than the reader, convenience
156  // methods are a nonsense.
157 
158  protected:
179  virtual bool doWrite(std::ostream& os, const std::filesystem::path& basePath,
180  const ArrayPath& relativePaths);
181 
182  private:
194  bool checkBaseDirAndPathList(const std::filesystem::path& basePath,
195  const ArrayPath& relativePaths) const;
196 };
197 //---------------------------------------------------------------------------
198 
199 
200 
204 class LIBXCKS_SO_EXPORT ZXCKSWriter : public XCKSWriter
205 {
206  public:
208  ZXCKSWriter() = delete;
209 
211  ZXCKSWriter(const ZXCKSWriter&) = delete;
212 
214  ZXCKSWriter& operator=(const ZXCKSWriter&) = delete;
215 
229  ZXCKSWriter(XCKSWriterHandler& xcksWriterHandler,
230  XCKSWriterChecksumProvider& checksumProvider,
231  const ZXCKSWriterOptions& options,
232  const Version version,
233  const ArrayChecksumAlgoId& algoIds,
234  const ChecksumFormatter::ConfigurationProvider& ckftConfProvider);
235 
237  virtual ~ZXCKSWriter();
238 
239  // Since we need some more complicated handlers than the reader, convenience
240  // methods are a nonsense.
241 
242  protected:
263  bool doWrite(std::ostream& os, const std::filesystem::path& basePath,
264  const ArrayPath& relativePaths) override;
265 };
266 //---------------------------------------------------------------------------
267 
268 } // namespace libxcks
269 //---------------------------------------------------------------------------
270 
271 #endif // INC_XCKSWRITER_HPP_0FFE21B6_E2AF_4985_9134_279C8EE17E5D
Format checksum and hash values.
Configuration provider for ChecksumFormatter.
Definition: ckformatter.hpp:69
Provides checksums values from an array of wanted algorithms of checksums for the XCKS writer.
Definition: handlers.hpp:375
Handler for writing XCKS files.
Definition: handlers.hpp:423
Provides options for the XCKS writer.
Definition: handlers.hpp:818
XCKS file writer.
Definition: xckswriter.hpp:47
XCKSWriter & operator=(const XCKSWriter &)=delete
Deleted copy assignment operator.
const ArrayChecksumAlgoId sumsAlgos
Type of algorithms' checksums to write for each file.
Definition: xckswriter.hpp:53
const Version version
Version of the (Z)XCKS file to write.
Definition: xckswriter.hpp:52
XCKSWriter(const XCKSWriter &)=delete
Deleted copy constructor.
XCKSWriter()=delete
Deleted default constructor.
XCKSWriterChecksumProvider & ckProvider
The provider of checksums values.
Definition: xckswriter.hpp:50
XCKSWriterHandler & writerHandler
The XCKS file writer handler.
Definition: xckswriter.hpp:49
const ChecksumFormatter::ConfigurationProvider & ckfConfProvider
Configuration provider for ChecksumFormatter.
Definition: xckswriter.hpp:54
const XCKSWriterOptions & writerOptions
The writer options.
Definition: xckswriter.hpp:51
Provides options for the XCKS writer.
Definition: handlers.hpp:1071
ZXCKS file writer.
Definition: xckswriter.hpp:205
ZXCKSWriter()=delete
Deleted default constructor.
ZXCKSWriter(const ZXCKSWriter &)=delete
Deleted copy constructor.
ZXCKSWriter & operator=(const ZXCKSWriter &)=delete
Deleted copy assignment operator.
Handlers for reading and writing XCKS files.
std::vector< ChecksumAlgoId > ArrayChecksumAlgoId
Array of ids of algorithms of checksums.
Definition: types.hpp:92
std::vector< std::filesystem::path > ArrayPath
Array of paths.
Definition: types.hpp:49
Version
Known versions of XCKS file.
Definition: types.hpp:55