27#include "exiv2lib_export.h"
37#ifndef EXV_XPATH_MEMIO
38#define EXV_XPATH_MEMIO 0
102 virtual long write(
const byte* data,
long wcount) = 0;
120 virtual int putb(
byte data) = 0;
144 virtual long read(
byte* buf,
long rcount) = 0;
175 virtual int seek(int64_t offset,
Position pos) = 0;
189 virtual byte*
mmap(
bool isWriteable =
false) =0;
213 virtual size_t size()
const = 0;
219 virtual bool eof()
const = 0;
225 virtual std::string
path()
const =0;
226#ifdef EXV_UNICODE_PATH
231 virtual std::wstring wpath()
const =0;
270 void close() {
if (bio_.isopen()) bio_.close(); }
298 explicit FileIo(
const std::string& path);
299#ifdef EXV_UNICODE_PATH
305 FileIo(
const std::wstring& wpath);
326 int open(
const std::string& mode);
341 int close()
override;
351 long write(
const byte* data,
long wcount)
override;
361 long write(
BasicIo& src)
override;
369 int putb(
byte data)
override;
380 DataBuf read(
long rcount)
override;
393 long read(
byte* buf,
long rcount)
override;
419 void transfer(
BasicIo& src)
override;
429 int seek(int64_t offset,
Position pos)
override;
431 int seek(
long offset,
Position pos)
override;
444 byte* mmap(
bool isWriteable =
false)
override;
452 int munmap()
override;
456 virtual void setPath(
const std::string& path);
457#ifdef EXV_UNICODE_PATH
463 virtual void setPath(
const std::wstring& wpath);
473 long tell()
const override;
480 size_t size()
const override;
482 bool isopen()
const override;
484 int error()
const override;
486 bool eof()
const override;
488 std::string path()
const override;
489#ifdef EXV_UNICODE_PATH
494 virtual std::wstring wpath()
const;
504 void populateFakeData()
override;
516 std::unique_ptr<Impl> p_;
546 MemIo(
const byte* data,
long size);
564 int close()
override;
575 long write(
const byte* data,
long wcount)
override;
586 long write(
BasicIo& src)
override;
594 int putb(
byte data)
override;
605 DataBuf read(
long rcount)
override;
618 long read(
byte* buf,
long rcount)
override;
641 void transfer(
BasicIo& src)
override;
651 virtual int seek(int64_t offset,
Position pos);
653 int seek(
long offset,
Position pos)
override;
663 byte* mmap(
bool =
false)
override;
664 int munmap()
override;
673 long tell()
const override;
679 size_t size()
const override;
681 bool isopen()
const override;
683 int error()
const override;
685 bool eof()
const override;
687 std::string path()
const override;
688#ifdef EXV_UNICODE_PATH
693 virtual std::wstring wpath()
const;
703 void populateFakeData()
override;
716 std::unique_ptr<Impl> p_;
729 XPathIo(
const std::string& path);
730#ifdef EXV_UNICODE_PATH
736 XPathIo(
const std::wstring& wpath);
750 void ReadDataUri(
const std::string& path);
769 explicit XPathIo(
const std::string& orgPath);
770#ifdef EXV_UNICODE_PATH
776 XPathIo(
const std::wstring& wOrgPathpath);
788 void transfer(
BasicIo& src)
override;
800 static std::string writeDataToFile(
const std::string& orgPath);
801#ifdef EXV_UNICODE_PATH
807 static std::string writeDataToFile(
const std::wstring& wOrgPath);
814 std::string tempFilePath_;
848 int close()
override;
853 long write(
const byte* data,
long wcount)
override;
868 long write(
BasicIo& src)
override;
874 int putb(
byte data)
override;
887 DataBuf read(
long rcount)
override;
902 long read(
byte* buf,
long rcount)
override;
926 void transfer(
BasicIo& src)
override;
936 virtual int seek(int64_t offset,
Position pos);
938 int seek(
long offset,
Position pos)
override;
944 byte* mmap(
bool =
false)
override;
949 int munmap()
override;
957 long tell()
const override;
963 size_t size()
const override;
965 bool isopen()
const override;
967 int error()
const override;
969 bool eof()
const override;
971 std::string path()
const override;
972#ifdef EXV_UNICODE_PATH
977 virtual std::wstring wpath()
const;
987 void populateFakeData()
override;
1015 explicit HttpIo(
const std::string& url,
size_t blockSize = 1024);
1016#ifdef EXV_UNICODE_PATH
1022 HttpIo(
const std::wstring& wurl,
size_t blockSize = 1024);
1040 class EXIV2API CurlIo :
public RemoteIo {
1053 explicit CurlIo(
const std::string& url,
size_t blockSize = 0);
1054#ifdef EXV_UNICODE_PATH
1060 CurlIo(
const std::wstring& wurl,
size_t blockSize = 0);
1067 long write(
const byte* data,
long wcount)
override;
1073 long write(
BasicIo& src)
override;
1077 CurlIo(CurlIo& rhs) =
delete;
1079 CurlIo& operator=(
const CurlIo& rhs) =
delete;
1095 EXIV2API DataBuf
readFile(
const std::string& path);
1096#ifdef EXV_UNICODE_PATH
1101 EXIV2API DataBuf
readFile(
const std::wstring& wpath);
1108 EXIV2API
long writeFile(
const DataBuf& buf,
const std::string& path);
1109#ifdef EXV_UNICODE_PATH
1114 EXIV2API
long writeFile(
const DataBuf& buf,
const std::wstring& wpath);
1121 const std::string& replace);
1122#ifdef EXV_UNICODE_PATH
1129 const std::wstring& replace);
1135 EXIV2API
size_t curlWriter(
char* data,
size_t size,
size_t nmemb, std::string* writerData);
An interface for simple binary IO.
Definition: basicio.hpp:55
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:61
virtual bool eof() const =0
Returns true if the IO position has reached the end, otherwise false.
virtual long write(BasicIo &src)=0
Write data that is read from another BasicIo instance to the IO source. Current IO position is advanc...
virtual void populateFakeData()
Mark all the bNone blocks to bKnow. This avoids allocating memory for parts of the file that contain ...
Definition: basicio.hpp:241
virtual int seek(long offset, Position pos)=0
Move the current IO position.
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 ~BasicIo()=default
Destructor.
virtual std::string path() const =0
Return the path to the IO resource. Often used to form comprehensive error messages where only a Basi...
virtual DataBuf read(long rcount)=0
Read data from the IO source. Reading starts at the current IO position and the position is advanced ...
virtual int munmap()=0
Remove a mapping established with mmap(). If the mapped area is writeable, this ensures that changes ...
virtual long write(const byte *data, long wcount)=0
Write data to the IO source. Current IO position is advanced by the number of bytes written.
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 ...
std::unique_ptr< BasicIo > UniquePtr
BasicIo auto_ptr type.
Definition: basicio.hpp:58
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 long tell() const =0
Get the current IO position.
virtual long read(byte *buf, long rcount)=0
Read data from the IO source. Reading starts at the current IO position and the position is advanced ...
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 ...
Internal Pimpl structure of class FileIo.
Definition: basicio.cpp:81
Provides binary file IO by implementing the BasicIo interface.
Definition: basicio.hpp:288
FileIo(FileIo &rhs)=delete
Copy constructor.
FileIo & operator=(const FileIo &rhs)=delete
Assignment operator.
Internal Pimpl structure of class HttpIo.
Definition: basicio.cpp:2022
Provides the http read/write access for the RemoteIo.
Definition: basicio.hpp:1002
HttpIo(HttpIo &rhs)=delete
Copy constructor.
HttpIo & operator=(const HttpIo &rhs)=delete
Assignment operator.
Utility class that closes a BasicIo instance upon destruction. Meant to be used as a stack variable i...
Definition: basicio.hpp:257
IoCloser & operator=(const IoCloser &)=delete
Assignment operator.
IoCloser(BasicIo &bio)
Constructor, takes a BasicIo reference.
Definition: basicio.hpp:262
virtual ~IoCloser()
Destructor, closes the BasicIo reference.
Definition: basicio.hpp:264
void close()
Close the BasicIo if it is open.
Definition: basicio.hpp:270
BasicIo & bio_
The BasicIo reference.
Definition: basicio.hpp:275
IoCloser(const IoCloser &)=delete
Copy constructor.
Internal Pimpl structure of class MemIo.
Definition: basicio.cpp:1053
Provides binary IO on blocks of memory by implementing the BasicIo interface. A copy-on-write impleme...
Definition: basicio.hpp:532
MemIo(MemIo &rhs)=delete
Copy constructor.
MemIo & operator=(const MemIo &rhs)=delete
Assignment operator.
Internal Pimpl abstract structure of class RemoteIo.
Definition: basicio.cpp:1566
Provides remote binary file IO by implementing the BasicIo interface. This is an abstract class....
Definition: basicio.hpp:824
Provides binary IO for the data from stdin and data uri path.
Definition: basicio.hpp:753
static const std::string TEMP_FILE_EXT
The extension of the temporary file which is created when getting input data to read metadata....
Definition: basicio.hpp:759
static const std::string GEN_FILE_EXT
The extension of the generated file which is created when getting input data to add or modify the met...
Definition: basicio.hpp:764
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition: basicio.hpp:43
EXIV2API std::string ReplaceStringInPlace(std::string subject, const std::string &search, const std::string &replace)
replace each substring of the subject that matches the given search string with the given replacement...
Definition: basicio.cpp:2492
EXIV2API long writeFile(const DataBuf &buf, const std::string &path)
Write DataBuf buf to file path.
Definition: basicio.cpp:2472
EXIV2API DataBuf readFile(const std::string &path)
Read file path into a DataBuf, which is returned.
Definition: basicio.cpp:2434
Utility class containing a character array. All it does is to take care of memory allocation and dele...
Definition: types.hpp:162