crawlserv++  [under development]
Application for crawling and analyzing textual content of websites.
crawlservpp::Wrapper::ZipSource Class Reference

RAII wrapper for sources used by libzip. More...

#include <ZipSource.hpp>

Construction and Destruction

 ZipSource ()
 Constructor creating an empty source. More...
 
 ZipSource (const void *data, zip_uint64_t size)
 Constructor creating a source from the given data. More...
 
virtual ~ZipSource ()
 Destructor clearing the source if necessary. More...
 

Getters

zip_source_t * get () noexcept
 Gets a pointer to the underlying source. More...
 
const zip_source_t * getc () const noexcept
 Gets a const pointer to the underlying source. More...
 
bool valid () const noexcept
 Checks whether the underlying source is valid. More...
 
zip_error_t getError () const
 Get the last occurred error. More...
 

Cleanup

void clear () noexcept
 Clears the underlying source if necessary. More...
 

Copy and Move

The class is not copyable, only moveable.

 ZipSource (ZipSource &)=delete
 Deleted copy constructor. More...
 
ZipSourceoperator= (ZipSource &)=delete
 Deleted copy assignment operator. More...
 
 ZipSource (ZipSource &&other) noexcept
 Move constructor. More...
 
ZipSourceoperator= (ZipSource &&other) noexcept
 Move assignment operator. More...
 

Detailed Description

RAII wrapper for sources used by libzip.

Creates the source on construction and clears it on destruction, avoiding memory leaks.

This class is used exclusively by functions in the Data::Compression::Zip namespace.

For more information about the libzip library used, visit its website.

Note
The class does not own the underlying pointer, but takes care of its deletion via API call.

Constructor & Destructor Documentation

◆ ZipSource() [1/4]

crawlservpp::Wrapper::ZipSource::ZipSource ( )
inline

Constructor creating an empty source.

◆ ZipSource() [2/4]

crawlservpp::Wrapper::ZipSource::ZipSource ( const void *  data,
zip_uint64_t  size 
)
inline

Constructor creating a source from the given data.

Parameters
dataPointer to the data from which to create the source.
sizeSize of the data in bytes.
Warning
The data must remain valid for the lifetime of the created source!

◆ ~ZipSource()

crawlservpp::Wrapper::ZipSource::~ZipSource ( )
inlinevirtual

Destructor clearing the source if necessary.

References clear().

◆ ZipSource() [3/4]

crawlservpp::Wrapper::ZipSource::ZipSource ( ZipSource )
delete

Deleted copy constructor.

◆ ZipSource() [4/4]

crawlservpp::Wrapper::ZipSource::ZipSource ( ZipSource &&  other)
inlinenoexcept

Move constructor.

Moves the source from the specified location into this instance of the class.

Note
The other source will be invalidated by this move.
Parameters
otherThe source to move from.
See also
valid

Member Function Documentation

◆ clear()

void crawlservpp::Wrapper::ZipSource::clear ( )
inlinenoexcept

Clears the underlying source if necessary.

The source will be invalid and valid() will return false afterwards.

Note
Does nothing if the underlying source is not valid.
See also
valid

Referenced by operator=(), and ~ZipSource().

◆ get()

zip_source_t * crawlservpp::Wrapper::ZipSource::get ( )
inlinenoexcept

Gets a pointer to the underlying source.

Returns
A pointer to the underlying source or nullptr if none is set.

Referenced by crawlservpp::Wrapper::ZipArchive::close(), and crawlservpp::Wrapper::ZipArchive::ZipArchive().

◆ getc()

const zip_source_t * crawlservpp::Wrapper::ZipSource::getc ( ) const
inlinenoexcept

Gets a const pointer to the underlying source.

Returns
A constant pointer to the underlying source or nullptr if none is set.

◆ getError()

zip_error_t crawlservpp::Wrapper::ZipSource::getError ( ) const
inline

Get the last occurred error.

Returns
A copy of the structure containing the last error that occurred while calling the libzip API.

Referenced by crawlservpp::Wrapper::ZipArchive::ZipArchive().

◆ operator=() [1/2]

ZipSource& crawlservpp::Wrapper::ZipSource::operator= ( ZipSource )
delete

Deleted copy assignment operator.

◆ operator=() [2/2]

ZipSource & crawlservpp::Wrapper::ZipSource::operator= ( ZipSource &&  other)
inlinenoexcept

Move assignment operator.

Moves the source from the specified location into this instance of the class.

Note
The other source will be invalidated by this move.
Nothing will be done if used on itself.
Parameters
otherThe source to move from.
Returns
A reference to the instance containing the source after moving (i.e. *this).
See also
valid

References clear().

◆ valid()

bool crawlservpp::Wrapper::ZipSource::valid ( ) const
inlinenoexcept

Checks whether the underlying source is valid.

Returns
True, if the source is valid, i.e. a pointer has been set. False otherwise.
See also
clear

Referenced by crawlservpp::Wrapper::ZipArchive::close(), and crawlservpp::Wrapper::ZipArchive::ZipArchive().


The documentation for this class was generated from the following file: