Beatmup
Beatmup::FileInputStream Class Reference

InputStream reading from a file. More...

#include <input_stream.h>

Inheritance diagram for Beatmup::FileInputStream:
Beatmup::InputStream

Public Member Functions

 FileInputStream ()
 
 FileInputStream (const char *filename)
 
bool isOpen () const
 
void open (const char *filename)
 
void close ()
 
void clear ()
 
bool operator() (void *buffer, msize bytes)
 Reads a given number of bytes into a specific memory location. More...
 
bool seek (msize pos)
 Moves the read pointer to a given position in the stream. More...
 
bool eof () const
 Returns true, if the end of the stream is reached (i.e., all the data is read or the stream is empty). More...
 

Private Attributes

std::ifstream stream
 

Detailed Description

InputStream reading from a file.

Definition at line 54 of file input_stream.h.

Constructor & Destructor Documentation

◆ FileInputStream() [1/2]

FileInputStream::FileInputStream ( )

Definition at line 24 of file input_stream.cpp.

24 {}

◆ FileInputStream() [2/2]

Beatmup::FileInputStream::FileInputStream ( const char *  filename)
inline

Definition at line 59 of file input_stream.h.

59 { open(filename); }
void open(const char *filename)
JNIEnv jlong jstring filename

Member Function Documentation

◆ isOpen()

bool FileInputStream::isOpen ( ) const

Definition at line 27 of file input_stream.cpp.

27  {
28  return stream.is_open();
29 }

◆ open()

void FileInputStream::open ( const char *  filename)

Definition at line 31 of file input_stream.cpp.

31  {
32  stream.open(filename, std::ios::in | std::ios::binary);
33 }

◆ close()

void FileInputStream::close ( )

Definition at line 35 of file input_stream.cpp.

35  {
36  stream.close();
37 }

◆ clear()

void FileInputStream::clear ( )

Definition at line 39 of file input_stream.cpp.

39  {
40  stream.clear();
41 }

◆ operator()()

bool FileInputStream::operator() ( void *  buffer,
msize  bytes 
)
virtual

Reads a given number of bytes into a specific memory location.

Parameters
[in]bufferThe address to store the data to
[in]bytesNumber of bytes to read
Returns
true on success.

Implements Beatmup::InputStream.

Definition at line 44 of file input_stream.cpp.

44  {
45  stream.read((char*)buffer, bytes);
46  return stream.good();
47 }

◆ seek()

bool FileInputStream::seek ( msize  pos)
virtual

Moves the read pointer to a given position in the stream.

Parameters
posThe position in bytes from the beginning of the stream
Returns
true on success.

Implements Beatmup::InputStream.

Definition at line 49 of file input_stream.cpp.

49  {
50  stream.seekg(pos);
51  return stream.good();
52 }

◆ eof()

bool FileInputStream::eof ( ) const
virtual

Returns true, if the end of the stream is reached (i.e., all the data is read or the stream is empty).

Implements Beatmup::InputStream.

Definition at line 54 of file input_stream.cpp.

54  {
55  return stream.eof();
56 }

Member Data Documentation

◆ stream

std::ifstream Beatmup::FileInputStream::stream
private

Definition at line 56 of file input_stream.h.


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