7#include "exiv2lib_export.h"
18#ifndef EXV_XPATH_MEMIO
19#define EXV_XPATH_MEMIO 0
82 virtual size_t write(
const byte* data,
size_t wcount) = 0;
100 virtual int putb(
byte data) = 0;
124 virtual size_t read(
byte* buf,
size_t rcount) = 0;
135 void readOrThrow(
byte* buf,
size_t rcount,
ErrorCode err = ErrorCode::kerCorruptedMetadata);
186 virtual byte*
mmap(
bool isWriteable =
false) = 0;
203 [[nodiscard]]
virtual size_t tell()
const = 0;
209 [[nodiscard]]
virtual size_t size()
const = 0;
211 [[nodiscard]]
virtual bool isopen()
const = 0;
213 [[nodiscard]]
virtual int error()
const = 0;
215 [[nodiscard]]
virtual bool eof()
const = 0;
221 [[nodiscard]]
virtual const std::string&
path() const noexcept = 0;
230 virtual
void populateFakeData() = 0;
293 explicit FileIo(
const std::string& path);
314 int open(
const std::string& mode);
329 int close()
override;
339 size_t write(
const byte* data,
size_t wcount)
override;
349 size_t write(
BasicIo& src)
override;
357 int putb(
byte data)
override;
368 DataBuf read(
size_t rcount)
override;
381 size_t read(
byte* buf,
size_t rcount)
override;
407 void transfer(
BasicIo& src)
override;
409 int seek(int64_t offset,
Position pos)
override;
422 byte* mmap(
bool isWriteable =
false)
override;
430 int munmap()
override;
434 virtual void setPath(
const std::string& path);
443 [[nodiscard]]
size_t tell()
const override;
450 [[nodiscard]]
size_t size()
const override;
452 [[nodiscard]]
bool isopen()
const override;
454 [[nodiscard]]
int error()
const override;
456 [[nodiscard]]
bool eof()
const override;
458 [[nodiscard]]
const std::string& path()
const noexcept override;
467 void populateFakeData()
override;
479 std::unique_ptr<Impl> p_;
508 MemIo(
const byte* data,
size_t size);
526 int close()
override;
537 size_t write(
const byte* data,
size_t wcount)
override;
548 size_t write(
BasicIo& src)
override;
556 int putb(
byte data)
override;
567 DataBuf read(
size_t rcount)
override;
580 size_t read(
byte* buf,
size_t rcount)
override;
603 void transfer(
BasicIo& src)
override;
605 int seek(int64_t offset,
Position pos)
override;
615 byte* mmap(
bool =
false)
override;
616 int munmap()
override;
625 [[nodiscard]]
size_t tell()
const override;
631 [[nodiscard]]
size_t size()
const override;
633 [[nodiscard]]
bool isopen()
const override;
635 [[nodiscard]]
int error()
const override;
637 [[nodiscard]]
bool eof()
const override;
639 [[nodiscard]]
const std::string& path()
const noexcept override;
648 void populateFakeData()
override;
661 std::unique_ptr<Impl> p_;
674 XPathIo(
const std::string& path);
687 void ReadDataUri(
const std::string& path);
696 static constexpr auto TEMP_FILE_EXT =
".exiv2_temp";
701 static constexpr auto GEN_FILE_EXT =
".exiv2";
706 explicit XPathIo(
const std::string& orgPath);
721 void transfer(
BasicIo& src)
override;
733 static std::string writeDataToFile(
const std::string& orgPath);
739 std::string tempFilePath_;
776 int close()
override;
781 size_t write(
const byte* data,
size_t wcount)
override;
796 size_t write(
BasicIo& src)
override;
802 int putb(
byte data)
override;
815 DataBuf read(
size_t rcount)
override;
830 size_t read(
byte* buf,
size_t rcount)
override;
854 void transfer(
BasicIo& src)
override;
856 int seek(int64_t offset,
Position pos)
override;
862 byte* mmap(
bool =
false)
override;
867 int munmap()
override;
875 [[nodiscard]]
size_t tell()
const override;
881 [[nodiscard]]
size_t size()
const override;
883 [[nodiscard]]
bool isopen()
const override;
885 [[nodiscard]]
int error()
const override;
887 [[nodiscard]]
bool eof()
const override;
889 [[nodiscard]]
const std::string& path() const noexcept override;
898 void populateFakeData() override;
925 explicit HttpIo(
const std::string& url,
size_t blockSize = 1024);
937class EXIV2API CurlIo :
public RemoteIo {
950 explicit CurlIo(
const std::string& url,
size_t blockSize = 0);
957 size_t write(
const byte* data,
size_t wcount)
override;
963 size_t write(
BasicIo& src)
override;
979EXIV2API DataBuf readFile(
const std::string& path);
985EXIV2API
size_t writeFile(
const DataBuf& buf,
const std::string& path);
990EXIV2API
size_t curlWriter(
char* data,
size_t size,
size_t nmemb, std::string* writerData);
An interface for simple binary IO.
Definition basicio.hpp:35
virtual size_t write(const byte *data, size_t wcount)=0
Write data to the IO source. Current IO position is advanced by the number of bytes written.
virtual bool isopen() const =0
Returns true if the IO source is open, otherwise false.
virtual int open()=0
Open the IO source using the default access mode. The default mode should allow for reading and writi...
Position
Seek starting positions.
Definition basicio.hpp:41
virtual bool eof() const =0
Returns true if the IO position has reached the end, otherwise false.
virtual size_t size() const =0
Get the current size of the IO source in bytes.
virtual int getb()=0
Read one byte from the IO source. Current IO position is advanced by one byte.
virtual int close()=0
Close the IO source. After closing a BasicIo instance can not be read or written. Closing flushes any...
virtual size_t tell() const =0
Get the current IO position.
virtual ~BasicIo()=default
Destructor.
virtual int seek(int64_t offset, Position pos)=0
Move the current IO position.
virtual const std::string & path() const noexcept=0
Return the path to the IO resource. Often used to form comprehensive error messages where only a Basi...
virtual int munmap()=0
Remove a mapping established with mmap(). If the mapped area is writeable, this ensures that changes ...
virtual size_t write(BasicIo &src)=0
Write data that is read from another BasicIo instance to the IO source. Current IO position is advanc...
std::unique_ptr< BasicIo > UniquePtr
BasicIo auto_ptr type.
Definition basicio.hpp:38
virtual DataBuf read(size_t rcount)=0
Read data from the IO source. Reading starts at the current IO position and the position is advanced ...
virtual void transfer(BasicIo &src)=0
Remove all data from this object's IO source and then transfer data from the src BasicIo object into ...
virtual int putb(byte data)=0
Write one byte to the IO source. Current IO position is advanced by one byte.
virtual int error() const =0
Returns 0 if the IO source is in a valid state, otherwise nonzero.
virtual byte * mmap(bool isWriteable=false)=0
Direct access to the IO data. For files, this is done by mapping the file into the process's address ...
virtual size_t read(byte *buf, size_t rcount)=0
Read data from the IO source. Reading starts at the current IO position and the position is advanced ...
Internal Pimpl structure of class FileIo.
Definition basicio.cpp:79
Provides binary file IO by implementing the BasicIo interface.
Definition basicio.hpp:283
FileIo(const FileIo &)=delete
Copy constructor.
FileIo & operator=(const FileIo &)=delete
Assignment operator.
Internal Pimpl structure of class HttpIo.
Definition basicio.cpp:1389
Provides the http read/write access for the RemoteIo.
Definition basicio.hpp:912
Utility class that closes a BasicIo instance upon destruction. Meant to be used as a stack variable i...
Definition basicio.hpp:246
IoCloser & operator=(const IoCloser &)=delete
Assignment operator.
IoCloser(BasicIo &bio)
Constructor, takes a BasicIo reference.
Definition basicio.hpp:251
virtual ~IoCloser()
Destructor, closes the BasicIo reference.
Definition basicio.hpp:254
void close()
Close the BasicIo if it is open.
Definition basicio.hpp:262
BasicIo & bio_
The BasicIo reference.
Definition basicio.hpp:270
IoCloser(const IoCloser &)=delete
Copy constructor.
Internal Pimpl structure of class MemIo.
Definition basicio.cpp:575
Provides binary IO on blocks of memory by implementing the BasicIo interface. A copy-on-write impleme...
Definition basicio.hpp:495
MemIo & operator=(const MemIo &)=delete
Assignment operator.
MemIo(const MemIo &)=delete
Copy constructor.
Internal Pimpl abstract structure of class RemoteIo.
Definition basicio.cpp:1003
Provides remote binary file IO by implementing the BasicIo interface. This is an abstract class....
Definition basicio.hpp:748
RemoteIo()
Destructor. Releases all managed memory.
Provides binary IO for the data from stdin and data uri path.
Definition basicio.hpp:690
Error class for exceptions, log message class.
Class CrwImage to access Canon CRW images. References: The Canon RAW (CRW) File Format by Phil Harv...
Definition asfvideo.hpp:15
ErrorCode
Complete list of all Exiv2 error codes.
Definition error.hpp:162
Utility class containing a character array. All it does is to take care of memory allocation and dele...
Definition types.hpp:124