Class Specialization
BZ2 File Stream
Wrapper for BZFILE * streams from bzlib.

StreamConcept

Stream

BZ2 File Stream

Stream<BZ2File>
Include Headers
seqan/stream.h
Remarks
This is only available if SEQAN_HAS_ZLIB is set to 1.
Not copy constructable.
Follows the RIIA pattern when the file is opened through open (and thus the underlying BZFILE * and FILE * are owned).
Can be used as a wrapper around a BZFILE * or create such an object itself through open. Also see the constructor.
Specialization of
Stream
Implements
StreamConcept
Member Functions

Stream | Constructor

Functions

atEnd | Determines whether an iterator is at the end position. (Stream)
close | Closes a file. (Stream)
open | Opens a file, stream, or persistent string. (Stream)

Examples
It is easy to open a BZ2 file via open.
#include <seqan/stream.h>
Stream<BZ2File> bzStream;
open(bzStream, "/path/to/file.txt.bz2", "r"); // binary is implicit
// Now, work with bzStream. The object will close the file on destruction.
You can also use BZ2 File Stream as a wrapper around BZFILE *. In this case, we have to deal with the verbose code for opening FILE * and BZFILE * by hand.
#include <cstdio>
#include <bzlib.h>
#include <seqan/stream.h>
// Open normal FILE *, BZFILE * above, and Stream<BZ2File> on top.
FILE * f = fopen("/path/to/file.txt.bz2", "rb");
SEQAN_ASSERT(f != NULL);
int err = BZ_OK;
BZFILE * f2 = BZ2_bzReadOpen(&err, f, 0, 0, NULL, 0);
SEQAN_ASSERT_EQ(err, BZ_OK);
Stream<BZ2File> bzStream(f2);
// Now, you can work with the stream bzStream.
// Note that you only have to close f2 and f, not bzStream.
BZ2_bzReadClose(&err, f2);
SEQAN_ASSERT_EQ(err, BZ_OK);
fclose(f);
SeqAn - Sequence Analysis Library - www.seqan.de

Page built @2014/10/13 16:13:00