libopenraw  0.3.7
streamclone.hpp
1 /* -*- Mode: C++ -*- */
2 /*
3  * libopenraw - streamclone.hpp
4  *
5  * Copyright (C) 2006-2020 Hubert Figuière
6  *
7  * This library is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation, either version 3 of
10  * the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library. If not, see
19  * <http://www.gnu.org/licenses/>.
20  */
21 
22 
23 #ifndef OR_INTERNALS_IO_STREAMCLONE_H_
24 #define OR_INTERNALS_IO_STREAMCLONE_H_
25 
26 #include <stddef.h>
27 #include <sys/types.h>
28 
29 #include "stream.hpp"
30 
31 namespace OpenRaw {
32 namespace IO {
33 
40  : public Stream
41 {
42 public:
47  StreamClone(const Stream::Ptr &clone, off_t offset);
48  virtual ~StreamClone();
49 
50  StreamClone(const StreamClone& f) = delete;
51  StreamClone & operator=(const StreamClone&) = delete;
52 
54  virtual Error open() override;
56  virtual int close() override;
58  virtual int seek(off_t offset, int whence) override;
60  virtual int read(void *buf, size_t count) override;
62  virtual off_t filesize() override;
63 
64 private:
65 
66  Stream::Ptr m_cloned;
67  off_t m_offset;
68 };
69 
71 }
72 }
73 
74 #endif
cloned stream. Allow reading from a different offset
Definition: streamclone.hpp:41
virtual Error open() override
open the file
Definition: streamclone.cpp:48
virtual int read(void *buf, size_t count) override
read in the file. Semantics are similar to POSIX read()
Definition: streamclone.cpp:83
virtual int close() override
close the file
Definition: streamclone.cpp:61
virtual int seek(off_t offset, int whence) override
seek in the file. Semantics are similar to POSIX lseek()
Definition: streamclone.cpp:68
StreamClone(const Stream::Ptr &clone, off_t offset)
Definition: streamclone.cpp:35
virtual off_t filesize() override
Return the filesize.
Definition: streamclone.cpp:93
base virtual class for IO
Definition: stream.hpp:44
std::shared_ptr< Stream > Ptr
Definition: stream.hpp:47
or_error
Error codes returned by libopenraw.
Definition: consts.h:42
Global namespace for libopenraw.
Definition: arwfile.cpp:29