Belle II Software light-2406-ragdoll
FileContext Class Reference

InputContext which serves the content of a plain file. More...

#include <FileHandler.h>

Inheritance diagram for FileContext:
Collaboration diagram for FileContext:

Public Member Functions

 FileContext (const std::string &filename, bool compressed)
 Open the given filename.
 
virtual int readXmlData (char *buffer, int buffsize) override
 Return a block of the data.
 
virtual ~FileContext ()
 Close the file.
 

Protected Attributes

boost::iostreams::filtering_istream m_stream
 stream to read data from
 

Detailed Description

InputContext which serves the content of a plain file.

Definition at line 23 of file FileHandler.h.

Constructor & Destructor Documentation

◆ FileContext()

FileContext ( const std::string &  filename,
bool  compressed 
)

Open the given filename.

Parameters
filenameabsolute filename name of the file
compressedif true, decompress the file on the fly

Definition at line 28 of file FileHandler.cc.

29 {
30 B2DEBUG(100, "Opening " << filename << (compressed ? " (gzip)" : ""));
31 if (compressed) m_stream.push(io::gzip_decompressor());
32 m_stream.push(io::file_source(filename));
33 }
boost::iostreams::filtering_istream m_stream
stream to read data from
Definition: FileHandler.h:40

◆ ~FileContext()

virtual ~FileContext ( )
inlinevirtual

Close the file.

Definition at line 37 of file FileHandler.h.

37{}

Member Function Documentation

◆ readXmlData()

virtual int readXmlData ( char *  buffer,
int  buffsize 
)
inlineoverridevirtual

Return a block of the data.

Implements InputContext.

Definition at line 31 of file FileHandler.h.

32 {
33 m_stream.read(buffer, buffsize);
34 return m_stream.gcount();
35 }

Member Data Documentation

◆ m_stream

boost::iostreams::filtering_istream m_stream
protected

stream to read data from

Definition at line 40 of file FileHandler.h.


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