libxcks  0.1.0.1
xcksfilereader.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 
24 #ifndef INC_XCKSFILEREADER_HPP_21738D0B_5681_443B_87CE_B151AC285AB7
25 #define INC_XCKSFILEREADER_HPP_21738D0B_5681_443B_87CE_B151AC285AB7
26 
27 //---------------------------------------------------------------------------
28 #include <memory>
29 // #include <string> // included in "xmlparser.hpp"
30 
31 #include "libxcks/handlers.hpp"
32 #include "xmlparser.hpp"
33 //---------------------------------------------------------------------------
34 
35 
36 namespace libxcks
37 {
41 class XCKSFileReader final : public XMLParser
42 {
43  protected:
45  const std::filesystem::path baseDirectory;
46  std::shared_ptr<XMLParserDefaultHandler> versionHandler;
47 
48  public:
52  XCKSFileReader() = delete;
53 
54  // Constructor.
55  XCKSFileReader(XCKSReaderHandler& handler, const std::filesystem::path& baseDir);
56 
57  // Receives notification of the beginning of an element.
58  void startElement(const std::string& name, const XMLParserAttributes& atts) noexcept(false) override;
59 
60  // Receives notification of the end of an element.
61  void endElement(const std::string& name) noexcept(false) override;
62 
63  // Receives notification of character data.
64  void characters(const std::string& chars) noexcept(false) override;
65 
66  // Receive notification of a non-recoverable error.
67  void fatalError(XML_Error errorCode, const std::string& errorMessage, int line, int column) noexcept override;
68 
69  protected:
70  // Gets the handler to parse the sums' file.
72 
73  // Sets the handler to parse the sums' file.
75 };
76 //---------------------------------------------------------------------------
77 } // namespace libxcks
78 //---------------------------------------------------------------------------
79 
80 #endif // INC_XCKSFILEREADER_HPP_21738D0B_5681_443B_87CE_B151AC285AB7
void characters(const std::string &chars) noexcept(false) override
Receives notification of character data.
void endElement(const std::string &name) noexcept(false) override
Receives notification of the end of an element.
void setVersionHandler(XMLParserDefaultHandler *handler)
Sets the handler to parse the sums' file.
XCKSReaderHandler & readerHandler
The XCKS file reader handler.
XMLParserDefaultHandler * getVersionHandler() const
Gets the handler to parse the sums' file.
void startElement(const std::string &name, const XMLParserAttributes &atts) noexcept(false) override
Receives notification of the beginning of an element.
const std::filesystem::path baseDirectory
The base directory of the checksums' file.
void fatalError(XML_Error errorCode, const std::string &errorMessage, int line, int column) noexcept override
Receive notification of a non-recoverable error.
XCKSFileReader()=delete
Deleted default constructor.
std::shared_ptr< XMLParserDefaultHandler > versionHandler
The handler for the version of the file.
Handler for reading XCKS files.
Definition: handlers.hpp:50
Manages elements' attributes.
Definition: xmlparser.hpp:84
Default XML parser handler.
Definition: xmlparser.hpp:198
A very simple XML parser.
Definition: xmlparser.hpp:138
Handlers for reading and writing XCKS files.
A very simple XML Parser.