mirror of
https://github.com/qpdf/qpdf.git
synced 2025-02-05 05:18:25 +00:00
Add new private API InputSource read methods
Improve support for reading into std::string objects.
This commit is contained in:
parent
2c7c121a97
commit
c502abbc98
@ -79,6 +79,8 @@ class QPDF_DLL_CLASS InputSource
|
||||
virtual void unreadCh(char ch) = 0;
|
||||
|
||||
// The following methods are for internal use by qpdf only.
|
||||
inline size_t read(std::string& str, size_t count, qpdf_offset_t at = -1);
|
||||
inline std::string read(size_t count, qpdf_offset_t at = -1);
|
||||
inline qpdf_offset_t fastTell();
|
||||
inline bool fastRead(char&);
|
||||
inline void fastUnread(bool);
|
||||
|
@ -3,6 +3,25 @@
|
||||
|
||||
#include <qpdf/InputSource.hh>
|
||||
|
||||
inline size_t
|
||||
InputSource::read(std::string& str, size_t count, qpdf_offset_t at)
|
||||
{
|
||||
if (at >= 0) {
|
||||
seek(at, SEEK_SET);
|
||||
}
|
||||
str.resize(count);
|
||||
str.resize(read(str.data(), count));
|
||||
return str.size();
|
||||
}
|
||||
|
||||
inline std::string
|
||||
InputSource::read(size_t count, qpdf_offset_t at)
|
||||
{
|
||||
std::string result(count, '\0');
|
||||
(void)read(result, count, at);
|
||||
return result;
|
||||
}
|
||||
|
||||
inline void
|
||||
InputSource::loadBuffer()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user