#include <binarystream.h>
Public Types | |
| enum | StreamMode { InputStream, OutputStream } |
| enum | Endianness { NativeEndian, LittleEndian, BigEndian } |
| enum | SeekOrigin { SeekFromBeginning, SeekFromCurrent, SeekFromEnd } |
Public Member Functions | |
| BinaryStream () | |
| BinaryStream (const std::string &filename, StreamMode mode, Endianness endianness=NativeEndian) | |
| ~BinaryStream () | |
| void | Open (const std::string &filename, StreamMode mode, Endianness endianness=NativeEndian) |
| void | Close () throw (WriteException) |
| bool | IsOpen () const |
| void | SetBufferSize (int size) |
| void | SetEndianness (Endianness endianness) |
| void | Seek (long offset, SeekOrigin origin) throw (SeekException) |
| long | Tell () const throw (SeekException) |
| void | Write (const void *data, size_t size) throw (WriteException) |
| void | Read (void *data, size_t size) throw (ReadException) |
| template<typename T> void | Write (T t) throw (WriteException) |
| template<typename T> void | Read (T *t) throw (ReadException) |
Private Member Functions | |
| Endianness | get_host_endianness () const |
| void | initialize () |
| void | flush_output_buffer () throw (WriteException) |
| size_t | fill_input_buffer () throw (ReadException) |
| void | invalidate_input_buffer () |
| template<typename T> void | swap_bytes (T *t) const |
| Byte swapping function. | |
Private Attributes | |
| FILE * | m_file |
| The file to which is binded the stream. | |
| StreamMode | m_mode |
| Stream mode (input or output). | |
| bool | m_swap |
| True if bytes must be swapped (if host and target endianness differ). | |
| char * | m_buffer_base |
| Base address of the buffer. | |
| char * | m_buffer_end |
| In InputStream mode: one byte past the end of the data. In OutputStream mode: one byte past the end of the buffer. | |
| char * | m_buffer_ptr |
| Current location in the buffer (points to the next byte to read/write). | |
| int | m_buffer_size |
| Total size of the buffer. | |
|
|
Definition at line 48 of file binarystream.h. |
|
|
Definition at line 81 of file binarystream.h. |
|
|
Definition at line 43 of file binarystream.h. |
|
|
Definition at line 33 of file binarystream.cpp. References initialize(). |
|
||||||||||||||||
|
Definition at line 37 of file binarystream.cpp. References initialize(), and Open(). |
|
|
Definition at line 45 of file binarystream.cpp. References Close(). |
|
|
Definition at line 65 of file binarystream.cpp. Referenced by sheep::TRILoader::close_geometry_file(), and ~BinaryStream(). |
|
|
Definition at line 245 of file binarystream.cpp. |
|
|
Definition at line 228 of file binarystream.cpp. |
|
|
Definition at line 212 of file binarystream.cpp. References BigEndian, and LittleEndian. Referenced by SetEndianness(). |
|
|
Definition at line 219 of file binarystream.cpp. References InputStream, m_buffer_base, m_buffer_end, m_buffer_ptr, m_buffer_size, m_mode, and m_swap. Referenced by BinaryStream(). |
|
|
Definition at line 262 of file binarystream.cpp. References m_buffer_base, and m_buffer_end. |
|
|
Definition at line 78 of file binarystream.cpp. Referenced by toxic::PhotonMap::CreateFromFile(), sheep::TRILoader::open_geometry_file(), and toxic::PhotonMap::WriteToFile(). |
|
||||||||||||||||
|
Definition at line 49 of file binarystream.cpp. References DEFAULT_BUFFER_SIZE, InputStream, m_mode, SetBufferSize(), and SetEndianness(). Referenced by BinaryStream(), and sheep::TRILoader::open_geometry_file(). |
|
||||||||||
|
Definition at line 168 of file binarystream.h. |
|
||||||||||||
|
Reads a sequence of contiguous bytes from the stream. No byte reordering is performed. Definition at line 172 of file binarystream.cpp. References sheep::min(). Referenced by toxic::PhotonMap::CreateFromFile(), and sheep::TRILoader::read_geometry_file(). |
|
||||||||||||
|
Definition at line 103 of file binarystream.cpp. Referenced by sheep::TRILoader::Load(). |
|
|
Sets the I/O buffer size. 'size' is expressed in bytes. The smallest value for 'size' is 1. This method must be called before using the stream. Definition at line 82 of file binarystream.cpp. References InputStream, m_buffer_base, m_buffer_end, m_buffer_ptr, m_buffer_size, and m_mode. Referenced by toxic::PhotonMap::CreateFromFile(), Open(), and toxic::PhotonMap::WriteToFile(). |
|
|
Definition at line 97 of file binarystream.cpp. References get_host_endianness(), m_swap, and NativeEndian. Referenced by Open(), and sheep::TRILoader::read_geometry_file(). |
|
||||||||||
|
Byte swapping function.
Definition at line 178 of file binarystream.h. |
|
|
Definition at line 126 of file binarystream.cpp. Referenced by sheep::TRILoader::Load(), and sheep::TRILoader::read_geometry_file(). |
|
||||||||||
|
Definition at line 160 of file binarystream.h. |
|
||||||||||||
|
Writes a sequence of contiguous bytes to the stream. No byte reordering is performed. Definition at line 137 of file binarystream.cpp. References sheep::min(). Referenced by toxic::PhotonMap::WriteToFile(). |
|
|
Base address of the buffer.
Definition at line 115 of file binarystream.h. Referenced by initialize(), invalidate_input_buffer(), and SetBufferSize(). |
|
|
In InputStream mode: one byte past the end of the data. In OutputStream mode: one byte past the end of the buffer.
Definition at line 116 of file binarystream.h. Referenced by initialize(), invalidate_input_buffer(), and SetBufferSize(). |
|
|
Current location in the buffer (points to the next byte to read/write).
Definition at line 117 of file binarystream.h. Referenced by initialize(), and SetBufferSize(). |
|
|
Total size of the buffer.
Definition at line 118 of file binarystream.h. Referenced by initialize(), and SetBufferSize(). |
|
|
The file to which is binded the stream.
Definition at line 112 of file binarystream.h. |
|
|
Stream mode (input or output).
Definition at line 113 of file binarystream.h. Referenced by initialize(), Open(), and SetBufferSize(). |
|
|
True if bytes must be swapped (if host and target endianness differ).
Definition at line 114 of file binarystream.h. Referenced by initialize(), and SetEndianness(). |
1.3.6