zipios++
2.0.2
Zipios++ – a small C++ library that provides easy access to .zip files.
|
A virtual class used to see in a file embedded in another. More...
#include <virtualseeker.hpp>
Public Member Functions | |
VirtualSeeker (offset_t start_offset=0, offset_t end_offset=0) | |
Create a virtual seeker. More... | |
offset_t | endOffset () const |
Return the end offset. More... | |
void | getOffsets (offset_t &start_offset, offset_t &end_offset) const |
Retrieve the current offsets. More... | |
void | setOffsets (offset_t start_offset, offset_t end_offset) |
Set the offsets of the virtual seeker. More... | |
offset_t | startOffset () const |
Return the start offset. More... | |
void | vseekg (std::istream &is, offset_t offset, std::ios::seekdir sd) const |
Seek within the embedded file. More... | |
std::streampos | vtellg (std::istream &is) const |
Current position within the sub-file. More... | |
Private Attributes | |
offset_t | m_end_offset = 0 |
offset_t | m_start_offset = 0 |
The virtual seeker class is a simple definition of an object that keeps track of a set of specified (virtual) file pointers that mark start and end of a file inside another.
An example of its use (and its reason for existence) is to keep track of the file endings of a Zip file embedded in another file (see the appendzip tool and the ZipFile::openEmbeddedZipFile() function).
Definition at line 46 of file virtualseeker.hpp.
This constructor defines a virtual seeker start and end offsets on initialization. By default it is initialized to a transparent seeker since the start and end are set to zero.
InvalidException | The two offsets must be positive. |
[in] | start_offset | The start offset of the embedded file. |
[in] | end_offset | The end offset of the embedded file. |
Definition at line 92 of file virtualseeker.cpp.
References m_end_offset, and m_start_offset.
offset_t zipios::VirtualSeeker::endOffset | ( | ) | const |
This function returns a copy of the end offset.
Definition at line 161 of file virtualseeker.cpp.
References m_end_offset.
This function retrieves the start and end offsets from the virtual seeker object.
[out] | start_offset | Returns the start offset. |
[out] | end_offset | Returns the end offset. |
Definition at line 136 of file virtualseeker.cpp.
References m_end_offset, and m_start_offset.
This function can be used to change the virtual seeker offsets.
InvalidException | The start offset must be before or equal to the end offset or this exception is raised. |
[in] | start_offset | The new start offset. |
[in] | end_offset | The new end offset. |
Definition at line 115 of file virtualseeker.cpp.
References m_end_offset, and m_start_offset.
offset_t zipios::VirtualSeeker::startOffset | ( | ) | const |
This function returns a copy of the start offset.
Definition at line 149 of file virtualseeker.cpp.
References m_start_offset.
Referenced by zipios::ZipFile::getInputStream().
void zipios::VirtualSeeker::vseekg | ( | std::istream & | is, |
offset_t | offset, | ||
std::ios::seekdir | sd | ||
) | const |
This function changes the file pointer in is
to the position specified in offset.
The direction can be indicated by sd
.
[in,out] | is | The stream which pointer is to be changed. |
[in] | offset | Relative position to set the input pointer to. |
[in] | sd | The stream direction to use to apply offset. |
Definition at line 178 of file virtualseeker.cpp.
References m_end_offset, and m_start_offset.
Referenced by zipios::BackBuffer::BackBuffer(), zipios::BackBuffer::readChunk(), and zipios::ZipFile::ZipFile().
std::streampos zipios::VirtualSeeker::vtellg | ( | std::istream & | is | ) | const |
This function calculates the position (file current pointer) within the embedded file in the specified stream.
If the position in the existing file is too large or too small, then the function returns -1.
[in] | is | The stream to get the position from. |
Definition at line 218 of file virtualseeker.cpp.
References m_start_offset.
Referenced by zipios::BackBuffer::BackBuffer(), and zipios::ZipFile::ZipFile().
|
private |
Definition at line 60 of file virtualseeker.hpp.
Referenced by endOffset(), getOffsets(), setOffsets(), VirtualSeeker(), and vseekg().
|
private |
Definition at line 59 of file virtualseeker.hpp.
Referenced by getOffsets(), setOffsets(), startOffset(), VirtualSeeker(), vseekg(), and vtellg().