Exiv2
basicio.hpp
1 // ***************************************************************** -*- C++ -*-
2 /*
3  * Copyright (C) 2004-2018 Exiv2 authors
4  * This program is part of the Exiv2 distribution.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
19  */
20 /*
21  File: basicio.hpp
22  */
23 #ifndef BASICIO_HPP_
24 #define BASICIO_HPP_
25 
26 // *****************************************************************************
27 #include "exiv2lib_export.h"
28 
29 // included header files
30 #include "types.hpp"
31 
32 // + standard includes
33 #include <memory> // for std::auto_ptr
34 
35 // The way to handle data from stdin or data uri path. If EXV_XPATH_MEMIO = 1,
36 // it uses MemIo. Otherwises, it uses FileIo.
37 #ifndef EXV_XPATH_MEMIO
38 #define EXV_XPATH_MEMIO 0
39 #endif
40 
41 // *****************************************************************************
42 // namespace extensions
43 namespace Exiv2 {
44 
45 // *****************************************************************************
46 // class definitions
47 
55  class EXIV2API BasicIo {
56  public:
58  typedef std::auto_ptr<BasicIo> AutoPtr;
59 
61  enum Position { beg, cur, end };
62 
64 
65  virtual ~BasicIo();
68 
70 
71 
83  virtual int open() = 0;
84 
92  virtual int close() = 0;
102  virtual long write(const byte* data, long wcount) = 0;
112  virtual long write(BasicIo& src) = 0;
120  virtual int putb(byte data) = 0;
131  virtual DataBuf read(long rcount) = 0;
144  virtual long read(byte* buf, long rcount) = 0;
151  virtual int getb() = 0;
165  virtual void transfer(BasicIo& src) = 0;
174 #if defined(_MSC_VER)
175  virtual int seek(int64_t offset, Position pos) = 0;
176 #else
177  virtual int seek(long offset, Position pos) = 0;
178 #endif
179 
189  virtual byte* mmap(bool isWriteable =false) =0;
196  virtual int munmap() =0;
197 
199 
201 
202 
207  virtual long tell() const = 0;
213  virtual size_t size() const = 0;
215  virtual bool isopen() const = 0;
217  virtual int error() const = 0;
219  virtual bool eof() const = 0;
225  virtual std::string path() const =0;
226 #ifdef EXV_UNICODE_PATH
227 
231  virtual std::wstring wpath() const =0;
232 #endif
233 
241  virtual void populateFakeData() {}
242 
246  byte* bigBlock_;
247 
249 
250  protected:
252 
253  BasicIo() : bigBlock_(NULL) {};
256  }; // class BasicIo
257 
264  class EXIV2API IoCloser {
265  public:
267 
268  explicit IoCloser(BasicIo& bio) : bio_(bio) {}
271  virtual ~IoCloser() { close(); }
273 
275 
276  void close() { if (bio_.isopen()) bio_.close(); }
279 
280  // DATA
283 
284  private:
285  // Not implemented
287  IoCloser(const IoCloser&);
289  IoCloser& operator=(const IoCloser&);
290  }; // class IoCloser
291 
296  class EXIV2API FileIo : public BasicIo {
297  public:
299 
300 
306  explicit FileIo(const std::string& path);
307 #ifdef EXV_UNICODE_PATH
308 
313  FileIo(const std::wstring& wpath);
314 #endif
315  virtual ~FileIo();
318 
320 
321 
334  int open(const std::string& mode);
342  virtual int open();
349  virtual int close();
359  virtual long write(const byte* data, long wcount);
369  virtual long write(BasicIo& src);
377  virtual int putb(byte data);
388  virtual DataBuf read(long rcount);
401  virtual long read(byte* buf, long rcount);
408  virtual int getb();
427  virtual void transfer(BasicIo& src);
436 #if defined(_MSC_VER)
437  virtual int seek(int64_t offset, Position pos);
438 #else
439  virtual int seek(long offset, Position pos);
440 #endif
441 
452  virtual byte* mmap(bool isWriteable =false);
460  virtual int munmap();
464  virtual void setPath(const std::string& path);
465 #ifdef EXV_UNICODE_PATH
466 
471  virtual void setPath(const std::wstring& wpath);
472 #endif
473 
474 
476 
481  virtual long tell() const;
488  virtual size_t size() const;
490  virtual bool isopen() const;
492  virtual int error() const;
494  virtual bool eof() const;
496  virtual std::string path() const;
497 #ifdef EXV_UNICODE_PATH
498  /*
499  @brief Like path() but returns the unicode path of the file in an std::wstring.
500  @note This function is only available on Windows.
501  */
502  virtual std::wstring wpath() const;
503 #endif
504 
512  virtual void populateFakeData();
514 
515  private:
516  // NOT IMPLEMENTED
518  FileIo(FileIo& rhs);
520  FileIo& operator=(const FileIo& rhs);
521 
522  // Pimpl idiom
523  class Impl;
524  std::auto_ptr<Impl> p_;
525 
526  }; // class FileIo
527 
540  class EXIV2API MemIo : public BasicIo {
541  public:
543 
544  MemIo();
554  MemIo(const byte* data, long size);
556  virtual ~MemIo();
558 
560 
561 
567  virtual int open();
572  virtual int close();
583  virtual long write(const byte* data, long wcount);
594  virtual long write(BasicIo& src);
602  virtual int putb(byte data);
613  virtual DataBuf read(long rcount);
626  virtual long read(byte* buf, long rcount);
633  virtual int getb();
649  virtual void transfer(BasicIo& src);
658 #if defined(_MSC_VER)
659  virtual int seek(int64_t offset, Position pos);
660 #else
661  virtual int seek(long offset, Position pos);
662 #endif
663 
671  virtual byte* mmap(bool /*isWriteable*/ =false);
672  virtual int munmap();
674 
676 
677 
681  virtual long tell() const;
687  virtual size_t size() const;
689  virtual bool isopen() const;
691  virtual int error() const;
693  virtual bool eof() const;
695  virtual std::string path() const;
696 #ifdef EXV_UNICODE_PATH
697  /*
698  @brief Like path() but returns a unicode dummy path in an std::wstring.
699  @note This function is only available on Windows.
700  */
701  virtual std::wstring wpath() const;
702 #endif
703 
711  virtual void populateFakeData();
712 
714 
715  private:
716  // NOT IMPLEMENTED
718  MemIo(MemIo& rhs);
720  MemIo& operator=(const MemIo& rhs);
721 
722  // Pimpl idiom
723  class Impl;
724  std::auto_ptr<Impl> p_;
725 
726  }; // class MemIo
727 
731 #if EXV_XPATH_MEMIO
732  class EXIV2API XPathIo : public MemIo {
733  public:
735 
736  XPathIo(const std::string& path);
738 #ifdef EXV_UNICODE_PATH
739 
744  XPathIo(const std::wstring& wpath);
745 #endif
746 
747  private:
752  void ReadStdin();
758  void ReadDataUri(const std::string& path);
759  }; // class XPathIo
760 #else
761  class EXIV2API XPathIo : public FileIo {
762  public:
772  static const std::string GEN_FILE_EXT;
773 
775 
776  explicit XPathIo(const std::string& orgPath);
778 #ifdef EXV_UNICODE_PATH
779 
784  XPathIo(const std::wstring& wOrgPathpath);
785 #endif
786  virtual ~XPathIo();
789 
791 
792 
796  virtual void transfer(BasicIo& src);
797 
799 
801 
802 
808  static std::string writeDataToFile(const std::string& orgPath);
809 #ifdef EXV_UNICODE_PATH
810 
815  static std::string writeDataToFile(const std::wstring& wOrgPath);
816 #endif
817 
818 
819  private:
820  // True if the file is a temporary file and it should be deleted in destructor.
821  bool isTemp_;
822  std::string tempFilePath_;
823  }; // class XPathIo
824 #endif
825 
826 
832  class EXIV2API RemoteIo : public BasicIo {
833  public:
835  virtual ~RemoteIo();
837 
839 
840 
849  virtual int open();
850 
856  virtual int close();
861  virtual long write(const byte* data, long wcount);
876  virtual long write(BasicIo& src);
877 
882  virtual int putb(byte data);
895  virtual DataBuf read(long rcount);
910  virtual long read(byte* buf, long rcount);
919  virtual int getb();
934  virtual void transfer(BasicIo& src);
943 #if defined(_MSC_VER)
944  virtual int seek(int64_t offset, Position pos);
945 #else
946  virtual int seek(long offset, Position pos);
947 #endif
948 
952  virtual byte* mmap(bool /*isWriteable*/ =false);
957  virtual int munmap();
959 
961 
965  virtual long tell() const;
971  virtual size_t size() const;
973  virtual bool isopen() const;
975  virtual int error() const;
977  virtual bool eof() const;
979  virtual std::string path() const;
980 #ifdef EXV_UNICODE_PATH
981  /*
982  @brief Like path() but returns a unicode URL path in an std::wstring.
983  @note This function is only available on Windows.
984  */
985  virtual std::wstring wpath() const;
986 #endif
987 
995  virtual void populateFakeData();
996 
998 
999  protected:
1001 
1002  RemoteIo() {p_=NULL;}
1005 
1006  // Pimpl idiom
1007  class Impl;
1009  Impl* p_;
1010  }; // class RemoteIo
1011 
1015  class EXIV2API HttpIo : public RemoteIo {
1016  public:
1018 
1019 
1028  HttpIo(const std::string& url, size_t blockSize = 1024);
1029 #ifdef EXV_UNICODE_PATH
1030 
1035  HttpIo(const std::wstring& wurl, size_t blockSize = 1024);
1036 #endif
1037 
1038  protected:
1039  // NOT IMPLEMENTED
1041  HttpIo(HttpIo& rhs);
1043  HttpIo& operator=(const HttpIo& rhs);
1044  // Pimpl idiom
1045  class HttpImpl;
1046 
1048 
1049  virtual ~HttpIo(){}
1052  };
1053 
1054 #ifdef EXV_USE_CURL
1055 
1059  class EXIV2API CurlIo : public RemoteIo {
1060  public:
1062 
1063 
1072  CurlIo(const std::string& url, size_t blockSize = 0);
1073 #ifdef EXV_UNICODE_PATH
1074 
1079  CurlIo(const std::wstring& wurl, size_t blockSize = 0);
1080 #endif
1081 
1086  long write(const byte* data, long wcount);
1092  long write(BasicIo& src);
1093  protected:
1094  // NOT IMPLEMENTED
1096  CurlIo(CurlIo& rhs);
1098  CurlIo& operator=(const CurlIo& rhs);
1099  // Pimpl idiom
1100  class CurlImpl;
1101 
1103 
1104  virtual ~CurlIo(){}
1107  };
1108 #endif
1109 
1110 #ifdef EXV_USE_SSH
1111 
1115  class EXIV2LIB_DEPRECATED_EXPORT SshIo : public RemoteIo {
1116  public:
1118 
1119 
1128  SshIo(const std::string& url, size_t blockSize = 1024);
1129 #ifdef EXV_UNICODE_PATH
1130 
1135  SshIo(const std::wstring& wurl, size_t blockSize = 1024);
1136 #endif
1137 
1138  protected:
1139  // NOT IMPLEMENTED
1141  SshIo(SshIo& rhs);
1143  SshIo& operator=(const SshIo& rhs);
1144  // Pimpl idiom
1145  class SshImpl;
1146 
1148 
1149  virtual ~SshIo(){}
1152  };
1153 #endif
1154 
1155 // *****************************************************************************
1156 // template, inline and free functions
1157 
1163  EXIV2API DataBuf readFile(const std::string& path);
1164 #ifdef EXV_UNICODE_PATH
1165 
1169  EXIV2API DataBuf readFile(const std::wstring& wpath);
1170 #endif
1171 
1176  EXIV2API long writeFile(const DataBuf& buf, const std::string& path);
1177 #ifdef EXV_UNICODE_PATH
1178 
1182  EXIV2API long writeFile(const DataBuf& buf, const std::wstring& wpath);
1183 #endif
1184 
1188  EXIV2API std::string ReplaceStringInPlace(std::string subject, const std::string& search,
1189  const std::string& replace);
1190 #ifdef EXV_UNICODE_PATH
1191 
1196  EXIV2API std::wstring ReplaceStringInPlace(std::wstring subject, const std::wstring& search,
1197  const std::wstring& replace);
1198 #endif
1199 #ifdef EXV_USE_CURL
1200 
1203  EXIV2API size_t curlWriter(char* data, size_t size, size_t nmemb, std::string* writerData);
1204 #endif
1205 } // namespace Exiv2
1206 #endif // #ifndef BASICIO_HPP_
Exiv2::MemIo::Impl
Internal Pimpl structure of class MemIo.
Definition: basicio.cpp:1055
Exiv2::MemIo::Impl::isMalloced_
bool isMalloced_
Was the buffer allocated?
Definition: basicio.cpp:1065
Exiv2::BasicIo::open
virtual int open()=0
Open the IO source using the default access mode. The default mode should allow for reading and writi...
Exiv2::MemIo
Provides binary IO on blocks of memory by implementing the BasicIo interface. A copy-on-write impleme...
Definition: basicio.hpp:540
Exiv2::Uri::Port
std::string Port
URL port.
Definition: futils.hpp:197
Exiv2::BasicIo::isopen
virtual bool isopen() const =0
Returns true if the IO source is open, otherwise false.
Exiv2::MemIo::getb
virtual int getb()
Read one byte from the memory block. The IO position is advanced by one byte.
Definition: basicio.cpp:1394
Exiv2::FileIo::Impl::openMode_
std::string openMode_
File open mode.
Definition: basicio.cpp:110
Exiv2::RemoteIo::close
virtual int close()
Reset the IO position to the start. It does not release the data.
Definition: basicio.cpp:1742
Exiv2::BasicIo::error
virtual int error() const =0
Returns 0 if the IO source is in a valid state, otherwise nonzero.
Exiv2::DataBuf::pData_
byte * pData_
Pointer to the buffer, 0 if none has been allocated.
Definition: types.hpp:269
Exiv2::BlockMap::populate
void populate(byte *source, size_t num)
Populate the block.
Definition: basicio.cpp:1125
Exiv2::FileIo::Impl::pMappedArea_
byte * pMappedArea_
Pointer to the memory-mapped area.
Definition: basicio.cpp:118
Exiv2::RemoteIo::error
virtual int error() const
Always returns 0.
Definition: basicio.cpp:1996
Exiv2::XPathIo::GEN_FILE_EXT
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:772
Exiv2::FileIo::mmap
virtual byte * mmap(bool isWriteable=false)
Map the file into the process's address space. The file must be open before mmap() is called....
Definition: basicio.cpp:412
Exiv2::FileIo
Provides binary file IO by implementing the BasicIo interface.
Definition: basicio.hpp:296
Exiv2::http
EXIV2API int http(Exiv2::Dictionary &request, Exiv2::Dictionary &response, std::string &errors)
execute an HTTP request
Definition: http.cpp:200
Exiv2::RemoteIo::open
virtual int open()
Connect to the remote server, get the size of the remote file and allocate the array of blocksMap.
Definition: basicio.cpp:1708
Exiv2::RemoteIo::seek
virtual int seek(long offset, Position pos)
Move the current IO position.
Definition: basicio.cpp:1934
Exiv2::IoCloser
Utility class that closes a BasicIo instance upon destruction. Meant to be used as a stack variable i...
Definition: basicio.hpp:264
Exiv2::BasicIo::Position
Position
Seek starting positions.
Definition: basicio.hpp:61
Exiv2::FileIo::read
virtual DataBuf read(long rcount)
Read data from the file. Reading starts at the current file position and the position is advanced by ...
Definition: basicio.cpp:992
Exiv2::RemoteIo::size
virtual size_t size() const
Get the current memory buffer size in bytes.
Definition: basicio.cpp:1986
Exiv2::MemIo::Impl::size_
long size_
Size of the memory area.
Definition: basicio.cpp:1063
Exiv2::FileIo::tell
virtual long tell() const
Get the current file position.
Definition: basicio.cpp:928
Exiv2::RemoteIo::Impl::getFileLength
virtual long getFileLength()=0
Get the length (in bytes) of the remote file.
Exiv2::RemoteIo::mmap
virtual byte * mmap(bool=false)
Not support.
Definition: basicio.cpp:1954
EXV_DEBUG
#define EXV_DEBUG
Shorthand to create a temp debug log message object and return its ostringstream.
Definition: error.hpp:144
Exiv2::RemoteIo::Impl::protocol_
Protocol protocol_
the protocol of url
Definition: basicio.cpp:1608
Exiv2::RemoteIo::Impl::getDataByRange
virtual void getDataByRange(long lowBlock, long highBlock, std::string &response)=0
Get the data by range.
Exiv2::fileExists
EXIV2API bool fileExists(const std::string &path, bool ct=false)
Test if a file exists.
Definition: futils.cpp:307
Exiv2::RemoteIo::Impl::eof_
bool eof_
EOF indicator.
Definition: basicio.cpp:1607
Exiv2::FileIo::Impl::isWriteable_
bool isWriteable_
Can the mapped area be written to?
Definition: basicio.cpp:121
types.hpp
Type definitions for Exiv2 and related functionality.
Exiv2::FileIo::Impl::OpMode
OpMode
Mode of operation.
Definition: basicio.cpp:99
Exiv2::FileIo::munmap
virtual int munmap()
Remove a mapping established with mmap(). If the mapped area is writeable, this ensures that changes ...
Definition: basicio.cpp:378
Exiv2::BlockMap
Utility class provides the block mapping to the part of data. This avoids allocating a single contigu...
Definition: basicio.cpp:1102
Exiv2::BlockMap::~BlockMap
~BlockMap()
Destructor. Releases all managed memory.
Definition: basicio.cpp:1114
Exiv2::RemoteIo::populateFakeData
virtual void populateFakeData()
Mark all the bNone blocks to bKnow. This avoids allocating memory for parts of the file that contain ...
Definition: basicio.cpp:2018
Exiv2::RemoteIo::getb
virtual int getb()
Read one byte from the memory blocks. The IO position is advanced by one byte. If the memory block is...
Definition: basicio.cpp:1891
Exiv2::Dictionary_i
Dictionary::const_iterator Dictionary_i
typedef for Dictionary iterator
Definition: datasets.hpp:372
Exiv2::DataBuf::release
EXV_WARN_UNUSED_RESULT std::pair< byte *, long > release()
Release ownership of the buffer to the caller. Returns the buffer as a data pointer and size pair,...
Definition: types.cpp:172
Exiv2::FileIo::~FileIo
virtual ~FileIo()
Destructor. Flushes and closes an open file.
Definition: basicio.cpp:373
Exiv2::MemIo::transfer
virtual void transfer(BasicIo &src)
Clear the memory block and then transfer data from the src BasicIo object into a new block of memory.
Definition: basicio.cpp:1238
Exiv2::Uri::Path
std::string Path
URL file path.
Definition: futils.hpp:194
Exiv2::HttpIo::HttpImpl::getFileLength
long getFileLength()
Get the length (in bytes) of the remote file.
Definition: basicio.cpp:2093
Exiv2::MemIo::Impl::idx_
long idx_
Index into the memory area.
Definition: basicio.cpp:1062
Exiv2::FileIo::Impl::StructStat::st_nlink
nlink_t st_nlink
Number of hard links (broken on Windows, see winNumberOfLinks())
Definition: basicio.cpp:128
Exiv2::MemIo::error
virtual int error() const
Always returns 0.
Definition: basicio.cpp:1403
Exiv2::MemIo::seek
virtual int seek(long offset, Position pos)
Move the current IO position.
Definition: basicio.cpp:1315
Exiv2::FileIo::Impl::path_
std::string path_
(Standard) path
Definition: basicio.cpp:105
Exiv2::HttpIo::HttpImpl::getDataByRange
void getDataByRange(long lowBlock, long highBlock, std::string &response)
Get the data by range.
Definition: basicio.cpp:2111
Exiv2::MemIo::isopen
virtual bool isopen() const
Always returns true.
Definition: basicio.cpp:1366
Exiv2::writeFile
EXIV2API long writeFile(const DataBuf &buf, const std::string &path)
Write DataBuf buf to file path.
Definition: basicio.cpp:2702
Exiv2::BlockMap::markKnown
void markKnown(size_t num)
Change the status to bKnow. bKnow blocks do not contain the data, but they keep the size of data....
Definition: basicio.cpp:1139
Exiv2::strError
EXIV2API std::string strError()
Return a system error message and the error code (errno). See strerror(3).
Definition: futils.cpp:352
Exiv2::RemoteIo::p_
Impl * p_
Pointer to implementation.
Definition: basicio.hpp:1007
Exiv2::HttpIo
Provides the http read/write access for the RemoteIo.
Definition: basicio.hpp:1015
Exiv2::FileIo::getb
virtual int getb()
Read one byte from the file. The file position is advanced by one byte.
Definition: basicio.cpp:1011
Exiv2::RemoteIo::tell
virtual long tell() const
Get the current IO position.
Definition: basicio.cpp:1981
Exiv2::RemoteIo::Impl::path_
std::string path_
(Standard) path
Definition: basicio.cpp:1598
Exiv2::RemoteIo::Impl::writeRemote
virtual void writeRemote(const byte *data, size_t size, long from, long to)=0
Submit the data to the remote machine. The data replace a part of the remote file....
Exiv2::MemIo::MemIo
MemIo()
Default constructor that results in an empty object.
Definition: basicio.cpp:1210
Exiv2::RemoteIo::putb
virtual int putb(byte data)
Not support.
Definition: basicio.cpp:1840
Exiv2::ReplaceStringInPlace
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:2722
Exiv2::MemIo::Impl::Impl
Impl()
Default constructor.
Definition: basicio.cpp:1078
EXV_MAX
#define EXV_MAX(a, b)
Simple common max macro.
Definition: types.hpp:83
Exiv2::RemoteIo::Impl::size_
size_t size_
The file size.
Definition: basicio.cpp:1604
Exiv2::RemoteIo::Impl::idx_
long idx_
Index into the memory area.
Definition: basicio.cpp:1605
Exiv2::FileIo::putb
virtual int putb(byte data)
Write one byte to the file. The file position is advanced by one byte.
Definition: basicio.cpp:883
Exiv2::readFile
EXIV2API DataBuf readFile(const std::string &path)
Read file path into a DataBuf, which is returned.
Definition: basicio.cpp:2664
Exiv2::XPathIo::writeDataToFile
static std::string writeDataToFile(const std::string &orgPath)
Read the data from stdin/data uri path and write them to the file.
Definition: basicio.cpp:1521
Exiv2::BasicIo::bigBlock_
byte * bigBlock_
this is allocated and populated by mmap()
Definition: basicio.hpp:246
Exiv2::XPathIo::XPathIo
XPathIo(const std::string &orgPath)
Default constructor that reads data from stdin/data uri path and writes them to the temp file.
Definition: basicio.cpp:1486
Exiv2::FileIo::Impl::stat
int stat(StructStat &buf) const
stat wrapper for internal use
Definition: basicio.cpp:237
Exiv2::FileIo::Impl
Internal Pimpl structure of class FileIo.
Definition: basicio.cpp:89
Exiv2::RemoteIo::eof
virtual bool eof() const
Returns true if the IO position has reached the end, otherwise false.
Definition: basicio.cpp:2001
Exiv2::RemoteIo::Impl::blockSize_
size_t blockSize_
Size of the block memory.
Definition: basicio.cpp:1602
Exiv2::RemoteIo::transfer
virtual void transfer(BasicIo &src)
Remove the contents of the file and then transfer data from the src BasicIo object into the empty fil...
Definition: basicio.cpp:1907
Exiv2::HttpIo::HttpImpl::writeRemote
void writeRemote(const byte *data, size_t size, long from, long to)
Submit the data to the remote machine. The data replace a part of the remote file....
Definition: basicio.cpp:2133
Exiv2::getEnv
EXIV2API std::string getEnv(int env_var)
Return the value of environmental variable.
Definition: futils.cpp:70
Exiv2::BasicIo::close
virtual int close()=0
Close the IO source. After closing a BasicIo instance can not be read or written. Closing flushes any...
Exiv2::MemIo::~MemIo
virtual ~MemIo()
Destructor. Releases all managed memory.
Definition: basicio.cpp:1220
Exiv2::FileIo::size
virtual size_t size() const
Flush any buffered writes and get the current file size in bytes.
Definition: basicio.cpp:934
Exiv2::FileIo::open
virtual int open()
Open the file using using the default access mode of "rb". This method can also be used to "reopen" a...
Definition: basicio.cpp:952
Exiv2::RemoteIo::~RemoteIo
virtual ~RemoteIo()
Destructor. Releases all managed memory.
Definition: basicio.cpp:1700
Exiv2::FileIo::Impl::switchMode
int switchMode(OpMode opMode)
Switch to a new access mode, reopening the file if needed. Optimized to only reopen the file when it ...
Definition: basicio.cpp:181
Exiv2::byte
uint8_t byte
1 byte unsigned integer type.
Definition: types.hpp:105
Exiv2::FileIo::setPath
virtual void setPath(const std::string &path)
close the file source and set a new path.
Definition: basicio.cpp:552
Exiv2::FileIo::error
virtual int error() const
Returns 0 if the file is in a valid state, otherwise nonzero.
Definition: basicio.cpp:1018
Exiv2::RemoteIo
Provides remote binary file IO by implementing the BasicIo interface. This is an abstract class....
Definition: basicio.hpp:832
Exiv2::MemIo::Impl::reserve
void reserve(long wcount)
Reserve memory.
Definition: basicio.cpp:1172
Exiv2::HttpIo::HttpIo
HttpIo(const std::string &url, size_t blockSize=1024)
Constructor that accepts the http URL on which IO will be performed. The constructor does not open th...
Definition: basicio.cpp:2183
Exiv2::BasicIo::~BasicIo
virtual ~BasicIo()
Destructor.
Definition: basicio.cpp:84
Exiv2::MemIo::Impl::data_
byte * data_
Pointer to the start of the memory area.
Definition: basicio.cpp:1061
Exiv2::RemoteIo::Impl::~Impl
virtual ~Impl()
Destructor. Releases all managed memory.
Definition: basicio.cpp:1696
Exiv2::fileProtocol
EXIV2API Protocol fileProtocol(const std::string &path)
Return the protocol of the path.
Definition: futils.cpp:257
Exiv2::IoCloser::bio_
BasicIo & bio_
The BasicIo reference.
Definition: basicio.hpp:282
Exiv2::RemoteIo::Impl
Internal Pimpl abstract structure of class RemoteIo.
Definition: basicio.cpp:1586
Exiv2::DataBuf
Utility class containing a character array. All it does is to take care of memory allocation and dele...
Definition: types.hpp:204
Exiv2::XPathIo::TEMP_FILE_EXT
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:767
Exiv2::DataBuf::alloc
void alloc(long size)
Allocate a data buffer of at least the given size. Note that if the requested size is less than the c...
Definition: types.cpp:161
Exiv2::XPathIo::transfer
virtual void transfer(BasicIo &src)
Change the name of the temp file and make it untemporary before calling the method of superclass File...
Definition: basicio.cpp:1505
Exiv2::RemoteIo::read
virtual DataBuf read(long rcount)
Read data from the memory blocks. Reading starts at the current IO position and the position is advan...
Definition: basicio.cpp:1845
Exiv2::DataBuf::size_
long size_
The current size of the buffer.
Definition: types.hpp:271
Exiv2::Uri::Parse
static Uri EXIV2API Parse(const std::string &uri)
Parse the input URL to the protocol, host, path, username, password.
Definition: futils.cpp:391
Exiv2::BasicIo::eof
virtual bool eof() const =0
Returns true if the IO position has reached the end, otherwise false.
Exiv2::RemoteIo::isopen
virtual bool isopen() const
Returns true if the memory area is allocated.
Definition: basicio.cpp:1991
Exiv2::MemIo::populateFakeData
virtual void populateFakeData()
Mark all the bNone blocks to bKnow. This avoids allocating memory for parts of the file that contain ...
Definition: basicio.cpp:1425
Exiv2::FileIo::Impl::StructStat::st_mode
mode_t st_mode
Permissions.
Definition: basicio.cpp:126
Exiv2::BasicIo::read
virtual DataBuf read(long rcount)=0
Read data from the IO source. Reading starts at the current IO position and the position is advanced ...
Exiv2::Protocol
Protocol
the collection of protocols.
Definition: futils.hpp:46
Exiv2::FileIo::Impl::copyXattrFrom
void copyXattrFrom(const FileIo &src)
copy extended attributes (xattr) from another file
Definition: basicio.cpp:277
Exiv2::RemoteIo::Impl::blocksMap_
BlockMap * blocksMap_
An array contains all blocksMap.
Definition: basicio.cpp:1603
properties.hpp
XMP property and type information. References: XMP Specification from Adobe (Property descriptions c...
Exiv2
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition: asfvideo.hpp:36
Exiv2::FileIo::Impl::StructStat
Simple struct stat wrapper for internal use.
Definition: basicio.cpp:124
Exiv2::RemoteIo::write
virtual long write(const byte *data, long wcount)
Not support this method.
Definition: basicio.cpp:1758
Exiv2::base64decode
EXIV2API long base64decode(const char *in, char *out, size_t out_size)
Decode base64 data and put the resulting string in out.
Definition: futils.cpp:212
Exiv2::FileIo::FileIo
FileIo(const std::string &path)
Constructor that accepts the file path on which IO will be performed. The constructor does not open t...
Definition: basicio.cpp:361
Exiv2::BasicIo::path
virtual std::string path() const =0
Return the path to the IO resource. Often used to form comprehensive error messages where only a Basi...
Exiv2::HttpIo::HttpImpl::hostInfo_
Exiv2::Uri hostInfo_
the host information extracted from the path
Definition: basicio.cpp:2038
Exiv2::XPathIo::~XPathIo
virtual ~XPathIo()
Destructor. Releases all managed memory and removes the temp file.
Definition: basicio.cpp:1498
Exiv2::FileIo::seek
virtual int seek(long offset, Position pos)
Move the current file position.
Definition: basicio.cpp:910
EXV_MIN
#define EXV_MIN(a, b)
Simple common min macro.
Definition: types.hpp:81
Exiv2::RemoteIo::Impl::Impl
Impl(const std::string &path, size_t blockSize)
Constructor.
Definition: basicio.cpp:1650
Exiv2::HttpIo::operator=
HttpIo & operator=(const HttpIo &rhs)
Assignment operator.
Exiv2::FileIo::Impl::opMode_
OpMode opMode_
File open mode.
Definition: basicio.cpp:112
Exiv2::MemIo::close
virtual int close()
Does nothing on MemIo objects.
Definition: basicio.cpp:1371
Exiv2::FileIo::Impl::Impl
Impl(const std::string &path)
Constructor.
Definition: basicio.cpp:155
EXV_WARNING
#define EXV_WARNING
Shorthand for a temp warning log message object and return its ostringstream.
Definition: error.hpp:148
Exiv2::BasicIo::populateFakeData
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
Exiv2::MemIo::putb
virtual int putb(byte data)
Write one byte to the memory block. The IO position is advanced by one byte.
Definition: basicio.cpp:1283
Exiv2::BasicIo::size
virtual size_t size() const =0
Get the current size of the IO source in bytes.
Exiv2::time
@ time
IPTC time type.
Definition: types.hpp:149
Exiv2::base64encode
EXIV2API int base64encode(const void *data_buf, size_t dataLength, char *result, size_t resultSize)
Encode in base64 the data in data_buf and put the resulting string in result.
Definition: futils.cpp:138
Exiv2::BlockMap::blockType_e
blockType_e
the status of the block.
Definition: basicio.cpp:1105
Exiv2::RemoteIo::Impl::populateBlocks
virtual size_t populateBlocks(size_t lowBlock, size_t highBlock)
Get the data from the remote machine and write them to the memory blocks.
Definition: basicio.cpp:1663
Exiv2::MemIo::path
virtual std::string path() const
Returns a dummy path, indicating that memory access is used.
Definition: basicio.cpp:1413
Exiv2::RemoteIo::path
virtual std::string path() const
Returns the URL of the file.
Definition: basicio.cpp:2006
Exiv2::MemIo::tell
virtual long tell() const
Get the current IO position.
Definition: basicio.cpp:1349
Exiv2::IoCloser::~IoCloser
virtual ~IoCloser()
Destructor, closes the BasicIo reference.
Definition: basicio.hpp:271
Exiv2::HttpIo::HttpImpl::HttpImpl
HttpImpl(const std::string &path, size_t blockSize)
Constructor.
Definition: basicio.cpp:2076
Exiv2::BasicIo::AutoPtr
std::auto_ptr< BasicIo > AutoPtr
BasicIo auto_ptr type.
Definition: basicio.hpp:58
Exiv2::XPathIo
Provides binary IO for the data from stdin and data uri path.
Definition: basicio.hpp:761
Exiv2::Uri::Host
std::string Host
URL host.
Definition: futils.hpp:196
Exiv2::Error
BasicError< char > Error
Error class used for exceptions (std::string based)
Definition: error.hpp:323
Exiv2::FileIo::isopen
virtual bool isopen() const
Returns true if the file is open, otherwise false.
Definition: basicio.cpp:976
Exiv2::MemIo::mmap
virtual byte * mmap(bool=false)
Allow direct access to the underlying data buffer. The buffer is not protected against write access i...
Definition: basicio.cpp:1339
Exiv2::RemoteIo::Impl::totalRead_
uint32_t totalRead_
bytes requested from host
Definition: basicio.cpp:1609
Exiv2::FileIo::path
virtual std::string path() const
Returns the path of the file.
Definition: basicio.cpp:1029
Exiv2::FileIo::Impl::isMalloced_
bool isMalloced_
Is the mapped area allocated?
Definition: basicio.cpp:120
Exiv2::MemIo::write
virtual long write(const byte *data, long wcount)
Write data to the memory block. If needed, the size of the internal memory block is expanded....
Definition: basicio.cpp:1227
Exiv2::RemoteIo::Impl::isMalloced_
bool isMalloced_
Was the blocksMap_ allocated?
Definition: basicio.cpp:1606
Exiv2::MemIo::munmap
virtual int munmap()
Remove a mapping established with mmap(). If the mapped area is writeable, this ensures that changes ...
Definition: basicio.cpp:1344
Exiv2::Uri::Decode
static void EXIV2API Decode(Uri &uri)
Decode the url components.
Definition: futils.cpp:382
Exiv2::string
@ string
IPTC string type.
Definition: types.hpp:147
Exiv2::Dictionary
std::map< std::string, std::string > Dictionary
typedef for string:string map
Definition: datasets.hpp:364
Exiv2::FileIo::populateFakeData
virtual void populateFakeData()
Mark all the bNone blocks to bKnow. This avoids allocating memory for parts of the file that contain ...
Definition: basicio.cpp:1050
Exiv2::FileIo::Impl::StructStat::st_size
off_t st_size
Size.
Definition: basicio.cpp:127
Exiv2::FileIo::Impl::fp_
FILE * fp_
File stream pointer.
Definition: basicio.cpp:111
Exiv2::MemIo::Impl::sizeAlloced_
long sizeAlloced_
Size of the allocated buffer.
Definition: basicio.cpp:1064
Exiv2::MemIo::size
virtual size_t size() const
Get the current memory buffer size in bytes.
Definition: basicio.cpp:1354
Exiv2::BasicIo::seek
virtual int seek(long offset, Position pos)=0
Move the current IO position.
Exiv2::HttpIo::HttpImpl
Internal Pimpl structure of class HttpIo.
Definition: basicio.cpp:2030
datasets.hpp
IPTC dataset and type information.
Exiv2::BasicIo
An interface for simple binary IO.
Definition: basicio.hpp:55
Exiv2::FileIo::close
virtual int close()
Flush and unwritten data and close the file . It is safe to call close on an already closed instance.
Definition: basicio.cpp:981
Exiv2::FileIo::Impl::mappedLength_
size_t mappedLength_
Size of the memory-mapped area.
Definition: basicio.cpp:119
Exiv2::FileIo::open
int open(const std::string &mode)
Open the file using using the specified mode.
Definition: basicio.cpp:958
Exiv2::FileIo::write
virtual long write(const byte *data, long wcount)
Write data to the file. The file position is advanced by the number of bytes written.
Definition: basicio.cpp:579
Exiv2::MemIo::eof
virtual bool eof() const
Returns true if the IO position has reached the end, otherwise false.
Definition: basicio.cpp:1408
Exiv2::FileIo::transfer
virtual void transfer(BasicIo &src)
Remove the contents of the file and then transfer data from the src BasicIo object into the empty fil...
Definition: basicio.cpp:609
Exiv2::FileIo::eof
virtual bool eof() const
Returns true if the file position has reached the end, otherwise false.
Definition: basicio.cpp:1023
futils.hpp
Basic file utility functions required by Exiv2.
Exiv2::RemoteIo::munmap
virtual int munmap()
Not support.
Definition: basicio.cpp:1976
Exiv2::MemIo::read
virtual DataBuf read(long rcount)
Read data from the memory block. Reading starts at the current IO position and the position is advanc...
Definition: basicio.cpp:1376
Exiv2::Uri::Protocol
std::string Protocol
URL protocol.
Definition: futils.hpp:195
error.hpp
Error class for exceptions, log message class.
Exiv2::MemIo::open
virtual int open()
Memory IO is always open for reading and writing. This method therefore only resets the IO position t...
Definition: basicio.cpp:1359
Exiv2::MemIo::Impl::eof_
bool eof_
EOF indicator.
Definition: basicio.cpp:1066
Exiv2::Uri
A container for URL components. It also provides the method to parse a URL to get the protocol,...
Definition: futils.hpp:189
Exiv2::urlencode
EXIV2API std::string urlencode(const char *str)
Encode the input url.
Definition: futils.cpp:90