Octane v1.01.20 - The Open Compression Toolkit for C++ http://octane.sourceforge.net/
Homepage | Main | Modules | Class Hierarchy | Compound List | File List | Compound Members | Related Pages

file_bitreader Class Reference
[bitio]

#include <file_bitreader.hpp>

Inheritance diagram for file_bitreader:

bitreader List of all members.

Detailed Description

Specialization for files.

This class opens a file and reads from it. Unlike the stream_bitreader it manages the file that it operates on, and thus hides the details of file access.

It adds the member function error(), which checks if there was an error opening the file in the constructor.

Definition at line 33 of file file_bitreader.hpp.

Public Member Functions

 file_bitreader (const char *name)
 Constructor.

 file_bitreader (const char *name, size_t size_in_bits)
 Constructor with size specification.

bool error () const
 Check the state of the file.

bool supports_seek () const
 Check if seek functions are supported.


Protected Member Functions

char read_next_byte ()
 Defines the method of reading a single byte of input.

void set_position (size_t pos)
 Defines the method of setting the position for the next read.


Protected Attributes

std::ifstream s


Constructor & Destructor Documentation

file_bitreader::file_bitreader const char *  name  )  [inline]
 

Constructor.

Sets the number of bits available to the size of the file.

Parameters:
name - the name of the file to open.

Definition at line 39 of file file_bitreader.hpp.

References bitreader::length.

00040         : s(name, std::ios::binary)
00041     {
00042         if (s)
00043         {
00044             length = 8 * s.seekg(0, std::ios::end).tellg();
00045             s.seekg(0);
00046         }
00047     }

file_bitreader::file_bitreader const char *  name,
size_t  size_in_bits
[inline]
 

Constructor with size specification.

Parameters:
name - the name of the file to open.
size_in_bits - the number of bits available.

Definition at line 51 of file file_bitreader.hpp.

00052         : bitreader(size_in_bits), s(name, std::ios::binary) { ; }


Member Function Documentation

bool file_bitreader::error  )  const [inline, virtual]
 

Check the state of the file.

Returns:
true if a file error has occurred.

Reimplemented from bitreader.

Definition at line 58 of file file_bitreader.hpp.

Referenced by OctaneTester::CheckFilesAreIdentical(), OctaneTester::RunCommand_Compress(), OctaneTester::RunCommand_Decompress(), OctaneTester::RunCommand_LoadCompressor(), and OctaneTester::RunCommand_MakeState().

00058 { return !s; }

bool file_bitreader::supports_seek  )  const [inline, virtual]
 

Check if seek functions are supported.

Returns:
true if seek functions are supported.

Implements bitreader.

Definition at line 60 of file file_bitreader.hpp.

00060 { return true; }

char file_bitreader::read_next_byte  )  [inline, protected, virtual]
 

Defines the method of reading a single byte of input.

Derived classes must implement this function.

Returns:
the next byte (8 bits) from the input.

Implements bitreader.

Definition at line 63 of file file_bitreader.hpp.

00063 { char c; s.get(c); return c; }

void file_bitreader::set_position size_t  pos  )  [inline, protected, virtual]
 

Defines the method of setting the position for the next read.

Derived classes should implement this function if possible.

Parameters:
pos - the position for the next read.

Reimplemented from bitreader.

Definition at line 64 of file file_bitreader.hpp.

00064 { s.seekg((std::streamoff)pos); }


The documentation for this class was generated from the following file:  
Generated on 20 May 2004 by doxygen 1.3.3