OpenMS
Loading...
Searching...
No Matches
CompressedInputSource Class Reference

Xerces InputSource that opens a bzip2-, zip- or gzip-compressed file on demand. More...

#include <OpenMS/FORMAT/CompressedInputSource.h>

Inheritance diagram for CompressedInputSource:
[legend]
Collaboration diagram for CompressedInputSource:
[legend]

Public Member Functions

 CompressedInputSource (const std::string &file_path, const std::string &header, xercesc::MemoryManager *const manager=xercesc::XMLPlatformUtils::fgMemoryManager)
 Construct from a UTF-8 String path.
 
 CompressedInputSource (const XMLCh *const file_path, const std::string &header, xercesc::MemoryManager *const manager=xercesc::XMLPlatformUtils::fgMemoryManager)
 Construct from a wide-character (XMLCh) path.
 
 ~CompressedInputSource () override
 Destructor.
 
xercesc::BinInputStream * makeStream () const override
 Create the decompression input stream for this source.
 

Private Member Functions

 CompressedInputSource ()
 Default construction is deliberately suppressed (declared but not defined).
 
 CompressedInputSource (const CompressedInputSource &source)
 Copy construction is deliberately suppressed (declared but not defined).
 
CompressedInputSourceoperator= (const CompressedInputSource &source)
 Assignment is deliberately suppressed (declared but not defined).
 

Private Attributes

std::string head_
 Header bytes captured at construction; makeStream uses the first two characters to pick a decompressor.
 

Detailed Description

Xerces InputSource that opens a bzip2-, zip- or gzip-compressed file on demand.

Resolves the file path the same way as xercesc::LocalFileInputSource (relative paths are completed against the current working directory), but makeStream picks an OpenMS decompression stream (Bzip2InputStream, ZipInputStream or GzipInputStream) based on the first two bytes of the file as passed to the constructor.

Copy construction, copy assignment and default construction are deliberately suppressed.

Constructor & Destructor Documentation

◆ CompressedInputSource() [1/4]

CompressedInputSource ( const std::string &  file_path,
const std::string &  header,
xercesc::MemoryManager *const  manager = xercesc::XMLPlatformUtils::fgMemoryManager 
)

Construct from a UTF-8 String path.

Parameters
[in]file_pathPath to the compressed file; relative paths are completed against Xerces' current working directory.
[in]headerFirst two bytes of the file; makeStream uses them to pick the decompressor. "BZ" selects bzip2, "PK" selects zip, anything else (including a header shorter than two characters, which is silently replaced with two NUL bytes) selects gzip.
[in]managerMemory manager used for Xerces allocations. Defaults to the platform-wide manager.

◆ CompressedInputSource() [2/4]

CompressedInputSource ( const XMLCh *const  file_path,
const std::string &  header,
xercesc::MemoryManager *const  manager = xercesc::XMLPlatformUtils::fgMemoryManager 
)

Construct from a wide-character (XMLCh) path.

Parameters
[in]file_pathPath to the compressed file; relative paths are completed against Xerces' current working directory.
[in]headerSame semantics as the header argument of the String overload of this constructor.
[in]managerMemory manager used for Xerces allocations. Defaults to the platform-wide manager.

◆ ~CompressedInputSource()

~CompressedInputSource ( )
override

Destructor.

◆ CompressedInputSource() [3/4]

CompressedInputSource ( )
private

Default construction is deliberately suppressed (declared but not defined).

◆ CompressedInputSource() [4/4]

CompressedInputSource ( const CompressedInputSource source)
private

Copy construction is deliberately suppressed (declared but not defined).

Member Function Documentation

◆ makeStream()

xercesc::BinInputStream * makeStream ( ) const
override

Create the decompression input stream for this source.

Inspects the header passed to the constructor and returns a newly-allocated BinInputStream of the matching type:

Ownership of the returned stream is transferred to the caller (typically the Xerces parser).

Returns
A newly allocated decompression stream, or nullptr when the chosen stream fails to open the file.

◆ operator=()

CompressedInputSource & operator= ( const CompressedInputSource source)
private

Assignment is deliberately suppressed (declared but not defined).

Member Data Documentation

◆ head_

std::string head_
private

Header bytes captured at construction; makeStream uses the first two characters to pick a decompressor.