diff options
author | Jay Berkenbilt <ejb@ql.org> | 2020-01-12 15:48:22 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2020-01-13 15:19:53 +0100 |
commit | 9a398504ca869e00de15c713108264e0beead504 (patch) | |
tree | 23b10049734b6d2097444f7117856058cf110fdf /include | |
parent | 752416554086d5d34323bc14164d5084db83cfbd (diff) | |
download | qpdf-9a398504ca869e00de15c713108264e0beead504.tar.zst |
Refactor QUtil::read_lines_from_file
This commit adds the preserve_eol flags but doesn't implement EOL
preservation yet.
Diffstat (limited to 'include')
-rw-r--r-- | include/qpdf/QUtil.hh | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/include/qpdf/QUtil.hh b/include/qpdf/QUtil.hh index 9994fcc6..da136342 100644 --- a/include/qpdf/QUtil.hh +++ b/include/qpdf/QUtil.hh @@ -29,6 +29,7 @@ #include <list> #include <vector> #include <stdexcept> +#include <functional> #include <stdio.h> #include <time.h> @@ -90,8 +91,9 @@ namespace QUtil QPDF_DLL int os_wrapper(std::string const& description, int status); - // If the open fails, throws std::runtime_error. Otherwise, the - // FILE* is returned. + // If the open fails, throws std::runtime_error. Otherwise, the + // FILE* is returned. The filename should be UTF-8 encoded, even + // on Windows. It will be converted as needed on Windows. QPDF_DLL FILE* safe_fopen(char const* filename, char const* mode); @@ -308,10 +310,29 @@ namespace QUtil QPDF_DLL RandomDataProvider* getRandomDataProvider(); + // Filename is UTF-8 encoded, even on Windows, as described in the + // comments for safe_fopen. QPDF_DLL std::list<std::string> read_lines_from_file(char const* filename); + // ABI: make preserve_eol an optional arg and remove single-arg version + QPDF_DLL + std::list<std::string> read_lines_from_file( + char const* filename, bool preserve_eol); QPDF_DLL std::list<std::string> read_lines_from_file(std::istream&); + // ABI: make preserve_eol an optional arg and remove single-arg version + QPDF_DLL + std::list<std::string> read_lines_from_file( + std::istream&, bool preserve_eol); + QPDF_DLL + std::list<std::string> read_lines_from_file( + FILE*, bool preserve_eol = false); + QPDF_DLL + void read_lines_from_file( + std::function<bool(char&)> next_char, + std::list<std::string>& lines, + bool preserve_eol = false); + QPDF_DLL void read_file_into_memory( char const* filename, PointerHolder<char>& file_buf, size_t& size); |