|
27 | 27 | #include "exiv2lib_export.h" |
28 | 28 |
|
29 | 29 | // included header files |
| 30 | +#include "error.hpp" |
30 | 31 | #include "types.hpp" |
31 | 32 |
|
32 | 33 | // + standard includes |
@@ -142,6 +143,17 @@ namespace Exiv2 { |
142 | 143 | 0 if failure; |
143 | 144 | */ |
144 | 145 | virtual long read(byte* buf, long rcount) = 0; |
| 146 | + /*! |
| 147 | + @brief Safe version of `read()` that checks for errors and throws |
| 148 | + an exception if the read was unsuccessful. |
| 149 | + @param buf Pointer to a block of memory into which the read data |
| 150 | + is stored. The memory block must be at least \em rcount bytes |
| 151 | + long. |
| 152 | + @param rcount Maximum number of bytes to read. Fewer bytes may be |
| 153 | + read if \em rcount bytes are not available. |
| 154 | + @param err Error code to use if an exception is thrown. |
| 155 | + */ |
| 156 | + void readOrThrow(byte* buf, long rcount, ErrorCode err); |
145 | 157 | /*! |
146 | 158 | @brief Read one byte from the IO source. Current IO position is |
147 | 159 | advanced by one byte. |
@@ -176,6 +188,19 @@ namespace Exiv2 { |
176 | 188 | #else |
177 | 189 | virtual int seek(long offset, Position pos) = 0; |
178 | 190 | #endif |
| 191 | + /*! |
| 192 | + @brief Safe version of `seek()` that checks for errors and throws |
| 193 | + an exception if the seek was unsuccessful. |
| 194 | + @param offset Number of bytes to move the position relative |
| 195 | + to the starting position specified by \em pos |
| 196 | + @param pos Position from which the seek should start |
| 197 | + @param err Error code to use if an exception is thrown. |
| 198 | + */ |
| 199 | +#if defined(_MSC_VER) |
| 200 | + void seekOrThrow(int64_t offset, Position pos, ErrorCode err); |
| 201 | +#else |
| 202 | + void seekOrThrow(long offset, Position pos, ErrorCode err); |
| 203 | +#endif |
179 | 204 |
|
180 | 205 | /*! |
181 | 206 | @brief Direct access to the IO data. For files, this is done by |
|
0 commit comments