27 #include <boost/iostreams/filtering_streambuf.hpp>
28 #include <boost/iostreams/filter/gzip.hpp>
29 #include <boost/locale.hpp>
42 using namespace boost::locale;
55 XCKSReader::XCKSReader(
XCKSReaderHandler& xcksReaderHandler) : readerHandler(xcksReaderHandler)
75 if (!basePath.is_absolute())
93 if (!fileFullPath.is_absolute())
100 ifstream is(fileFullPath, ios_base::in | ios_base::binary);
108 return parse(is, fileFullPath.parent_path());
117 const std::filesystem::path& basePath)
119 if (!basePath.is_absolute())
126 ifstream is(filePath, ios_base::in | ios_base::binary);
134 return parse(is, basePath);
143 const std::filesystem::path& basePath)
146 return reader.
parse(is, basePath);
155 const std::filesystem::path& fileFullPath)
158 return reader.
parse(fileFullPath);
167 const std::filesystem::path& filePath,
168 const std::filesystem::path& basePath)
171 return reader.
parse(filePath, basePath);
206 boost::iostreams::filtering_streambuf<boost::iostreams::input> inbuf;
207 inbuf.push(boost::iostreams::gzip_decompressor());
209 istream instream(&inbuf);
217 res = instream.good();
219 catch (
const boost::iostreams::gzip_error& e)
224 catch (
const exception& e)
239 std::istream& is,
const std::filesystem::path& basePath)
242 return reader.
parse(is, basePath);
251 const std::filesystem::path& fileFullPath)
254 return reader.
parse(fileFullPath);
263 const std::filesystem::path& filePath,
264 const std::filesystem::path& basePath)
267 return reader.
parse(filePath, basePath);
Handler for reading XCKS files.
virtual void onFatalError(const std::string &errorMessage, int line, int column)=0
Called on a non-recoverable error.
virtual bool parse(std::istream &is, const std::filesystem::path &basePath)
Parses an XCKS file from an input stream.
static bool parseXCKS(XCKSReaderHandler &xcksReaderHandler, std::istream &is, const std::filesystem::path &basePath)
Convenience method for parsing an XCKS file from an input stream.
XCKSReaderHandler & readerHandler
The XCKS file reader handler.
virtual ~XCKSReader()
Destructor.
bool parse(const std::string &filename)
Parses the given file.
virtual bool parse(std::istream &is, const std::filesystem::path &basePath)
Parses an XCKS file from an input stream.
bool parse(std::istream &is, const std::filesystem::path &basePath) override
Parses an ZXCKS file from an input stream.
ZXCKSReader()=delete
Deleted default constructor.
static bool parseZXCKS(XCKSReaderHandler &xcksReaderHandler, std::istream &is, const std::filesystem::path &basePath)
Convenience method for parsing an ZXCKS file from an input stream.
virtual ~ZXCKSReader()
Destructor.
constexpr const char * libxcks_domain
Domain for translations (i18n).
std::filesystem::path ensureEndsWithPathSeparator(const std::filesystem::path &p)
Ensures the path ends with a path separator.
std::string from_u8string(const std::string &s)
Returns an UTF-8 encoded string in an object of type std::string (C++17).
Classes that read a XCKS file.