QSFML
|
sf::InputStream reading QResource files More...
#include <qresourcestream.hpp>
Public Member Functions | |
QResourceStream () | |
Default constructor. More... | |
~QResourceStream () | |
Destructor. More... | |
bool | open (const char *path) |
Opens file. More... | |
virtual sf::Int64 | read (void *data, sf::Int64 size) |
Reads parts of resource. More... | |
virtual sf::Int64 | seek (sf::Int64 position) |
Sets new cursor's position. More... | |
virtual sf::Int64 | tell () |
Returns cursor's position. More... | |
virtual sf::Int64 | getSize () |
Returns file size. More... | |
QResourceStream & | operator() (const char *path) |
Open a file using operator() More... | |
Friends | |
std::ostream & | operator<< (std::ostream &out, QResourceStream &resource) |
Prints whole file (std::ostream) More... | |
QDebug | operator<< (QDebug out, const QResourceStream &resource) |
Prints whole file (QDebug) More... | |
sf::InputStream reading QResource files
This class inherits sf::InputStream, so it can by used by any SFML method that takes reference to such object. Therafore you can store your textures, sounds etc. in an execatulable/binary file using Qt resources and then read them thanks to this class.
qsf::QResourceStream::QResourceStream | ( | ) |
Default constructor.
Does nothing expect of setting private variables to proper values.
qsf::QResourceStream::~QResourceStream | ( | ) |
Destructor.
Frees resources (memory).
|
virtual |
Returns file size.
bool qsf::QResourceStream::open | ( | const char * | path | ) |
Opens file.
[in] | path | – Path to file |
Opens given file, loads its contents to memory and then closes it.
QResourceStream & qsf::QResourceStream::operator() | ( | const char * | path | ) |
Open a file using operator()
[in] | path | – Path to file |
Opens a file and then returns reference, discards informations about file being opened properly. Such a structure allows writing code like that:
So you don't need to declare many instances of QResourceStream.
|
virtual |
Reads parts of resource.
[in] | size | – Amount of thata to be read |
[out] | data | – Pointer to place, where data should be copied |
|
virtual |
Sets new cursor's position.
[in] | position | – New position |
|
virtual |
Returns cursor's position.
|
friend |
Prints whole file (std::ostream)
Allows printing file to std::ostream.
Sample usage:
|
friend |
Prints whole file (QDebug)
Allows printing file to QDebug.
Sample usage: