MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Attributes | List of all members
Mezzanine::Resource::FileStream Class Reference

This represents a stream to a file on disk using the C++ file stream API. More...

#include <filestream.h>

+ Inheritance diagram for Mezzanine::Resource::FileStream:
+ Collaboration diagram for Mezzanine::Resource::FileStream:

Public Member Functions

 FileStream (std::fstream *Stream, const UInt16 Flags=DataStream::SF_Read)
 Class constructor. More...
 
 FileStream (const String &FileName, const String &Path, const UInt16 Flags=DataStream::SF_Read)
 Self loading constructor. More...
 
virtual ~FileStream ()
 Class destructor.
 
virtual void Advance (const StreamOff Count)
 Advances the position in the stream. More...
 
virtual void Close ()
 Closes the stream to the resource. More...
 
virtual bool EoF () const
 Gets whether or not the current position is at the end of the file/stream. More...
 
virtual StreamPos GetStreamPosition (bool Read=true)
 Gets the current position in this stream. (bool Read = true) More...
 
virtual size_t Read (void *Buffer, const size_t &Count)
 Reads data from the stream, copying to a buffer. More...
 
virtual void SetStreamPosition (StreamPos Position)
 Sets the position of the read and write cursors explicitly. More...
 
virtual void SetStreamPosition (StreamOff Offset, SeekOrigin Origin)
 Sets the position of the read and write cursors. More...
 
virtual size_t Write (const void *Buffer, const size_t &Count)
 Writes data from the stream, copying from the provided buffer. More...
 
- Public Member Functions inherited from Mezzanine::Resource::DataStream
 DataStream (const UInt16 Flags=SF_Read)
 Class constructor. More...
 
virtual ~DataStream ()
 Class destructor.
 
virtual String GetAsString ()
 Gets the contents of the stream as a string. More...
 
virtual String GetLine (bool Trim=true)
 Gets the contents of the current line in the stream. More...
 
virtual StreamSize GetSize () const
 Gets the size of the stream. More...
 
virtual bool IsReadable () const
 Gets whether this stream can be read. More...
 
virtual bool IsWriteable () const
 Gets whether this stream can be written to. More...
 
virtual size_t ReadLine (Char8 *Buffer, size_t MaxCount, const String &Delim="\n")
 Reads a single line from a string. More...
 
virtual size_t SkipLine (const String &Delim="\n")
 Moves the current position to the start of the next line. More...
 

Protected Attributes

std::fstream * StandardStream
 
- Protected Attributes inherited from Mezzanine::Resource::DataStream
UInt16 SFlags
 The type of access this stream has to the resource.
 
StreamSize Size
 The size of the stream.
 

Additional Inherited Members

- Public Types inherited from Mezzanine::Resource::DataStream
enum  SeekOrigin { SO_Beginning = std::ios_base::beg, SO_Current = std::ios_base::cur, SO_End = std::ios_base::end }
 An enum describing which position should be considered the origin for changing the current position in a stream. More...
 
enum  StreamFlags {
  SF_None = 0, SF_Read = 1, SF_Write = 2, SF_Append = 4,
  SF_AtEnd = 8, SF_Binary = 16, SF_Truncate = 32
}
 This enum describes the flags that control certain behaviors of a stream. More...
 

Detailed Description

This represents a stream to a file on disk using the C++ file stream API.

Definition at line 70 of file filestream.h.

Constructor & Destructor Documentation

Mezzanine::Resource::FileStream::FileStream ( std::fstream *  Stream,
const UInt16  Flags = DataStream::SF_Read 
)

Class constructor.

Parameters
StreamThe stream to the file being streamed to/from.
ModeThe flags to use when initializing the stream.

Definition at line 57 of file filestream.cpp.

Mezzanine::Resource::FileStream::FileStream ( const String FileName,
const String Path,
const UInt16  Flags = DataStream::SF_Read 
)

Self loading constructor.

Parameters
FileNameThe name of the file to be loaded. This will also become the name of the stream.
PathThe path to the file being loaded.
ModeThe flags to use when initializing the stream.

Definition at line 67 of file filestream.cpp.

Member Function Documentation

void Mezzanine::Resource::FileStream::Advance ( const StreamOff  Count)
virtual

Advances the position in the stream.

Parameters
CountThe number of bytes to skip/advance in the stream from the current position.

Implements Mezzanine::Resource::DataStream.

Definition at line 138 of file filestream.cpp.

void Mezzanine::Resource::FileStream::Close ( )
virtual

Closes the stream to the resource.

Implements Mezzanine::Resource::DataStream.

Definition at line 169 of file filestream.cpp.

bool Mezzanine::Resource::FileStream::EoF ( ) const
virtual

Gets whether or not the current position is at the end of the file/stream.

Returns
Returns true if the current position has reached the end of the stream, false otherwise.

Implements Mezzanine::Resource::DataStream.

Definition at line 164 of file filestream.cpp.

StreamPos Mezzanine::Resource::FileStream::GetStreamPosition ( bool  Read = true)
virtual

Gets the current position in this stream. (bool Read = true)

Parameters
ReadWhether or not to get the Read position. If false this will get the write position instead.
Returns
Returns a StreamPos representing the current position specified from the beginning of the stream.

(bool Read = true)

Implements Mezzanine::Resource::DataStream.

Definition at line 158 of file filestream.cpp.

size_t Mezzanine::Resource::FileStream::Read ( void *  Buffer,
const size_t &  Count 
)
virtual

Reads data from the stream, copying to a buffer.

Parameters
BufferThe buffer to place data from the stream.
CountThe number of bytes to read from the stream.
Returns
Returns the number of bytes read.

Implements Mezzanine::Resource::DataStream.

Definition at line 114 of file filestream.cpp.

void Mezzanine::Resource::FileStream::SetStreamPosition ( StreamPos  Position)
virtual

Sets the position of the read and write cursors explicitly.

Parameters
PositionThe position to be set.

Implements Mezzanine::Resource::DataStream.

Definition at line 144 of file filestream.cpp.

void Mezzanine::Resource::FileStream::SetStreamPosition ( StreamOff  Offset,
SeekOrigin  Origin 
)
virtual

Sets the position of the read and write cursors.

Parameters
OffsetThe number of bytes to move the cursors back(if negative) or forward(if positive).
OriginThe starting point to be considered for the offset.

Implements Mezzanine::Resource::DataStream.

Definition at line 151 of file filestream.cpp.

size_t Mezzanine::Resource::FileStream::Write ( const void *  Buffer,
const size_t &  Count 
)
virtual

Writes data from the stream, copying from the provided buffer.

Parameters
BufferThe buffer of data to be written.
CountThe number of bytes to write from the buffer to the stream.
Returns
Returns the number of bytes written.

Implements Mezzanine::Resource::DataStream.

Definition at line 126 of file filestream.cpp.


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