Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
stream.h
Go to the documentation of this file.
1 /*
2  This file is part of Mitsuba, a physically based rendering system.
3 
4  Copyright (c) 2007-2014 by Wenzel Jakob and others.
5 
6  Mitsuba is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License Version 3
8  as published by the Free Software Foundation.
9 
10  Mitsuba is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #pragma once
20 #if !defined(__MITSUBA_CORE_STREAM_H_)
21 #define __MITSUBA_CORE_STREAM_H_
22 
23 #include <mitsuba/mitsuba.h>
24 #include <mitsuba/core/half.h>
25 
27 
28 /// \brief This exception is thrown after an incomplete IO read/write operation
29 class EOFException : public std::runtime_error {
30 public:
31  inline EOFException(const std::string &str, size_t completed)
32  : std::runtime_error(str), m_completed(completed) { }
33 
34  /// Return the number of bytes that successfully completed
35  inline size_t getCompleted() const {
36  return m_completed;
37  }
38 private:
39  size_t m_completed;
40 };
41 
42 /** \brief Abstract seekable stream class
43  *
44  * Specifies all functions to be implemented by stream
45  * subclasses and provides various convenience functions
46  * layered on top of on them.
47  *
48  * All read<b>X</b>() and write<b>X</b>() methods support transparent
49  * conversion based on the endianness of the underlying system and the
50  * value passed to \ref setByteOrder(). Whenever \ref getHostByteOrder()
51  * and \ref getByteOrder() disagree, the endianness is swapped.
52  *
53  * \sa FileStream, MemoryStream, SocketStream,
54  * ConsoleStream, SSHStream, ZStream
55  * \ingroup libcore
56  * \ingroup libpython
57  */
58 class MTS_EXPORT_CORE Stream : public Object {
59 public:
60  /// Defines the byte order to use in this Stream
61  enum EByteOrder {
62  EBigEndian = 0, ///< PowerPC, SPARC, Motorola 68K
63  ELittleEndian = 1, ///< x86, x86_64
64  ENetworkByteOrder = EBigEndian ///< Network byte order (an alias for big endian)
65  };
66 
67  /**
68  * \brief Create a new stream.
69  *
70  * By default, it assumes the byte order of the
71  * underlying system, i.e. no endianness conversion
72  * is performed.
73  */
74  Stream();
75 
76  /// Return a string representation
77  virtual std::string toString() const;
78 
79  // ======================================================================
80  /// @{ \name Endianness-related
81  // ======================================================================
82 
83  /// Set the stream byte order
84  void setByteOrder(EByteOrder byteOrder);
85 
86  /// Return the byte order of this stream
87  inline EByteOrder getByteOrder() const { return m_byteOrder; }
88 
89  /// Return the byte order of the underlying machine
90  inline static EByteOrder getHostByteOrder() { return m_hostByteOrder; }
91 
92  /// @}
93  // ======================================================================
94 
95  // ======================================================================
96  //! @{ \name Abstract methods that need to be implemented by subclasses
97  // ======================================================================
98 
99  /**
100  * \brief Read a specified amount of data from the stream
101  *
102  * Throws an exception when the stream ended prematurely
103  */
104  virtual void read(void *ptr, size_t size) = 0;
105 
106  /**
107  * \brief Write a specified amount of data into the stream
108  *
109  * Throws an exception when not all data could be written
110  */
111  virtual void write(const void *ptr, size_t size) = 0;
112 
113  /// Seek to a position inside the stream
114  virtual void seek(size_t pos) = 0;
115 
116  /// Truncate the stream to a given size
117  virtual void truncate(size_t size) = 0;
118 
119  /// Get the current position inside the stream
120  virtual size_t getPos() const = 0;
121 
122  /// Return the size of the stream
123  virtual size_t getSize() const = 0;
124 
125  /// Flush the stream's buffers
126  virtual void flush() = 0;
127 
128  /// Can we write to the stream?
129  virtual bool canWrite() const = 0;
130 
131  /// Can we read from the stream?
132  virtual bool canRead() const = 0;
133 
134  //! @}
135  // ======================================================================
136 
137  // ======================================================================
138  //! @{ \name Convenience functions with automatic endianness conversion
139  // ======================================================================
140 
141  /// Skip the given number of bytes
142  void skip(size_t amount);
143 
144  /// Write a null-terminated string to the stream
145  void writeString(const std::string &value);
146 
147  /// Write a string followed by a newline
148  void writeLine(const std::string &value);
149 
150  /// Write a signed short (16 bit) to the stream
151  void writeShort(short value);
152 
153  /// Write an array of signed shorts (16 bit) to the stream
154  void writeShortArray(const short *values, size_t size);
155 
156  /// Write an array of known size of signed shorts (16 bit) to the stream
157  template <size_t N>
158  inline void writeShortArray(const short (&values)[N]) {
159  writeShortArray(&values[0], N);
160  }
161 
162  /// Write an unsigned short (16 bit) to the stream
163  void writeUShort(unsigned short value);
164 
165  /// Write an array of unsigned shorts (16 bit) to the stream
166  void writeUShortArray(const unsigned short *values, size_t size);
167 
168  /// Write an array of known size of unsigned shorts (16 bit) to the stream
169  template <size_t N>
170  inline void writeUShortArray(const unsigned short (&values)[N]) {
171  writeUShortArray(&values[0], N);
172  }
173 
174  /// Write a signed int (32 bit) to the stream
175  void writeInt(int value);
176 
177  /// Write an array of signed ints (32 bit) to the stream
178  void writeIntArray(const int *values, size_t size);
179 
180  /// Write an array of known size of signed ints (32 bit) to the stream
181  template <size_t N>
182  inline void writeIntArray(const int (&values)[N]) {
183  writeIntArray(&values[0], N);
184  }
185 
186  /// Write an unsigned int (32 bit) to the stream
187  void writeUInt(unsigned int value);
188 
189  /// Write an array of unsigned ints (32 bit) to the stream
190  void writeUIntArray(const unsigned int *values, size_t size);
191 
192  /// Write an array of known size of unsigned ints (32 bit) to the stream
193  template <size_t N>
194  inline void writeUIntArray(const unsigned int (&values)[N]) {
195  writeUIntArray(&values[0], N);
196  }
197 
198  /// Write a signed int (64 bit) to the stream
199  void writeLong(int64_t value);
200 
201  /// Write an array of signed ints (64 bit) to the stream
202  void writeLongArray(const int64_t *values, size_t size);
203 
204  /// Write an array of known size of signed ints (64 bit) to the stream
205  template <size_t N>
206  inline void writeLongArray(const int64_t (&values)[N]) {
207  writeLongArray(&values[0], N);
208  }
209 
210  /// Write an unsigned int (64 bit) to the stream
211  void writeULong(uint64_t value);
212 
213  /// Write a size value to the stream
214  void writeSize(size_t value) { writeULong((uint64_t) value); }
215 
216  /// Write an array of unsigned ints (64 bit) to the stream
217  void writeULongArray(const uint64_t *values, size_t size);
218 
219  /// Write an array of known size of unsigned ints (64 bit) to the stream
220  template <size_t N>
221  inline void writeULongArray(const uint64_t (&values)[N]) {
222  writeULongArray(&values[0], N);
223  }
224 
225  /// Write a signed character (8 bit) to the stream
226  void writeChar(char value);
227 
228  /// Write an unsigned character (8 bit) to the stream
229  void writeUChar(unsigned char value);
230 
231  /// Write a boolean (8 bit) to the stream
232  inline void writeBool(bool value) { writeUChar(value); }
233 
234  /// Write a half-precision floating point number (16 bit) to the stream
235  void writeHalf(half value);
236 
237  /// Write a half-precision floating point array (16 bit) to the stream
238  void writeHalfArray(const half *data, size_t size);
239 
240  /// Write a known size half-precision floating point array (16 bit) to the stream
241  template <size_t N>
242  inline void writeHalfArray(const half (&values)[N]) {
243  writeHalfArray(&values[0], N);
244  }
245 
246  /// Write a single-precision floating point number (32 bit) to the stream
247  void writeSingle(float value);
248 
249  /// Write a single-precision floating point array (32 bit) to the stream
250  void writeSingleArray(const float *data, size_t size);
251 
252  /// Write a known size single-precision floating point array (32 bit) to the stream
253  template <size_t N>
254  inline void writeSingleArray(const float (&values)[N]) {
255  writeSingleArray(&values[0], N);
256  }
257 
258  /// Write a double-precision floating point number (64 bit) to the stream
259  void writeDouble(double value);
260 
261  /// Write a double-precision floating point array (64 bit) to the stream
262  void writeDoubleArray(const double *data, size_t size);
263 
264  /// Write a known size double-precision floating point array (64 bit) to the stream
265  template <size_t N>
266  inline void writeDoubleArray(const double (&values)[N]) {
267  writeDoubleArray(&values[0], N);
268  }
269 
270  /// Write a floating point number (configured precision) to the stream
271  inline void writeFloat(Float value) {
272 #ifdef SINGLE_PRECISION
273  writeSingle(value);
274 #else
275  writeDouble(value);
276 #endif
277  }
278 
279  /// Write an array of floating point values (configured precision) to the stream
280  inline void writeFloatArray(const Float *data, size_t size) {
281 #ifdef SINGLE_PRECISION
282  writeSingleArray(data, size);
283 #else
284  writeDoubleArray(data, size);
285 #endif
286  }
287 
288  /// Write a known size array of floating point values (configured precision) to the stream
289  template <size_t N>
290  inline void writeFloatArray(const Float (&values)[N]) {
291  writeFloatArray(&values[0], N);
292  }
293 
294  /// Return whether we are at the end of the stream
295  bool isEOF() const;
296 
297  /// Read a line from the stream and return it as a string
298  std::string readLine();
299 
300  /// Read a null-terminated string from the stream
301  std::string readString();
302 
303  /// Read a signed short (16 bit) from the stream
304  short readShort();
305 
306  /// Read an array of signed shorts (16 bit) from the stream
307  void readShortArray(short *dest, size_t size);
308 
309  /// Read an array of known size of signed shorts (16 bit) from the stream
310  template <size_t N>
311  inline void readShortArray(short (&values)[N]) {
312  readShortArray(&values[0], N);
313  }
314 
315  /// Read an unsigned short (16 bit) from the stream
316  unsigned short readUShort();
317 
318  /// Read an array of unsigned shorts (16 bit) from the stream
319  void readUShortArray(unsigned short *dest, size_t size);
320 
321  /// Read an array of known size of unsigned shorts (16 bit) from the stream
322  template <size_t N>
323  inline void readUShortArray(short (&values)[N]) {
324  readUShortArray(&values[0], N);
325  }
326 
327  /// Read a signed int (32 bit) from the stream
328  int readInt();
329 
330  /// Read an array of signed ints (32 bit) from the stream
331  void readIntArray(int *dst, size_t size);
332 
333  /// Read an array of known size of signed ints (32 bit) from the stream
334  template <size_t N>
335  inline void readIntArray(int (&values)[N]) {
336  readIntArray(&values[0], N);
337  }
338 
339  /// Read an unsigned int (32 bit) from the stream
340  unsigned int readUInt();
341 
342  /// Read an array of unsigned ints (32 bit) from the stream
343  void readUIntArray(unsigned int *dest, size_t size);
344 
345  /// Read an array of known size of unsigned ints (32 bit) from the stream
346  template <size_t N>
347  inline void readUIntArray(int (&values)[N]) {
348  readUIntArray(&values[0], N);
349  }
350 
351  /// Read a signed int (64 bit) from the stream
352  int64_t readLong();
353 
354  /// Read an array of signed ints (64 bit) from the stream
355  void readLongArray(int64_t *dst, size_t size);
356 
357  /// Read an array of known size of signed ints (64 bit) from the stream
358  template <size_t N>
359  inline void readLongArray(int64_t (&values)[N]) {
360  readLongArray(&values[0], N);
361  }
362 
363  /// Read an unsigned int (64 bit) from the stream
364  uint64_t readULong();
365 
366  /// Read a size value from the stream
367  size_t readSize() { return (size_t) readULong(); }
368 
369  /// Read an array of unsigned ints (64 bit) from the stream
370  void readULongArray(uint64_t *dst, size_t size);
371 
372  /// Read an array of known size of unsigned ints (64 bit) from the stream
373  template <size_t N>
374  inline void readULongArray(uint64_t (&values)[N]) {
375  readULongArray(&values[0], N);
376  }
377 
378  /// Read a signed character (8 bit) from the stream
379  char readChar();
380 
381  /// Read an unsigned character (8 bit) from the stream
382  unsigned char readUChar();
383 
384  /// Read a boolean (8 bit) from the stream
385  inline bool readBool() { return static_cast<bool> (readUChar()); }
386 
387  /// Read a half-precision floating point number (16 bit) from the stream
388  half readHalf();
389 
390  /// Read a half-precision floating point array (16 bit) from the stream
391  void readHalfArray(half *data, size_t size);
392 
393  /// Read a known-size half-precision floating point array (16 bit) from the stream
394  template <size_t N>
395  inline void readHalfArray(half (&values)[N]) {
396  readHalfArray(&values[0], N);
397  }
398 
399  /// Read a single-precision floating point number (32 bit) from the stream
400  float readSingle();
401 
402  /// Read a single-precision floating point array (32 bit) from the stream
403  void readSingleArray(float *data, size_t size);
404 
405  /// Read a known-size single-precision floating point array (32 bit) from the stream
406  template <size_t N>
407  inline void readSingleArray(float (&values)[N]) {
408  readSingleArray(&values[0], N);
409  }
410 
411  /// Read a double-precision floating point number (64 bit) from the stream
412  double readDouble();
413 
414  /// Read a double-precision floating point array (64 bit) from the stream
415  void readDoubleArray(double *data, size_t size);
416 
417  /// Read a known-size double-precision floating point array (64 bit) from the stream
418  template <size_t N>
419  inline void readDoubleArray(double (&values)[N]) {
420  readDoubleArray(&values[0], N);
421  }
422 
423  /// Write a floating point number (configured precision) to the stream
424  inline Float readFloat() {
425 #ifdef SINGLE_PRECISION
426  return readSingle();
427 #else
428  return readDouble();
429 #endif
430  }
431 
432  /// Write an array of floating point values (configured precision) to the stream
433  inline void readFloatArray(Float *data, size_t size) {
434 #ifdef SINGLE_PRECISION
435  readSingleArray(data, size);
436 #else
437  readDoubleArray(data, size);
438 #endif
439  }
440 
441  /// Read a known-size array of floating point values (configured precision) to the stream
442  template <size_t N>
443  inline void readFloatArray(Float (&values)[N]) {
444  readFloatArray(&values[0], N);
445  }
446 
447  /**
448  * \brief Copy content from this stream into another stream
449  * \param stream Destination stream
450  * \param numBytes
451  * The number of bytes to copy. When -1 is specified,
452  * copying proceeds until the end of the source stream.
453  */
454  void copyTo(Stream *stream, int64_t numBytes = -1);
455 
456  /**
457  * \brief Read an element from the stream (uses partial template
458  * specialization to select a method appropriate to the data type)
459  */
460  template <typename T> T readElement();
461 
462  /**
463  * \brief Write an element to the stream (uses partial template
464  * specialization to select a method appropriate to the data type)
465  */
466  template <typename T> void writeElement(T value);
467 
468  /**
469  * \brief Read an array from the stream (uses partial template
470  * specialization to select a method appropriate to the data type)
471  */
472  template <typename T> void readArray(T *array, size_t count);
473 
474  /**
475  * \brief Read a known-size array from the stream (uses partial template
476  * specialization to select a method appropriate to the data type)
477  */
478  template <typename T, size_t N> inline void readArray(T (&arr)[N]) {
479  readArray(&arr[0], N);
480  }
481 
482  /**
483  * \brief Write an array to the stream (uses partial template
484  * specialization to select a method appropriate to the data type)
485  */
486  template <typename T> void writeArray(const T *array, size_t count);
487 
488  /**
489  * \brief Write a known-size array to the stream (uses partial template
490  * specialization to select a method appropriate to the data type)
491  */
492  template <typename T, size_t N> inline void writeArray(const T (&arr)[N]) {
493  writeArray(&arr[0], N);
494  }
495 
496  //! @}
497 
499 protected:
500  /// Virtual destructor
501  virtual ~Stream() { }
502 private:
503  static EByteOrder m_hostByteOrder;
504  EByteOrder m_byteOrder;
505 };
506 
507 
508 template <typename T> inline T Stream::readElement() {
509  Log(EError, "Stream::readElement<T>: not implemented!");
510 }
511 
512 template <typename T> inline void Stream::writeElement(T value) {
513  Log(EError, "Stream::writeElement<T>: not implemented!");
514 }
515 
516 template <typename T> inline void Stream::readArray(T *array, size_t count) {
517  Log(EError, "Stream::readArray<T>: not implemented!");
518 }
519 
520 template <typename T> inline void Stream::writeArray(const T *array, size_t count) {
521  Log(EError, "Stream::writeArray<T>: not implemented!");
522 }
523 
524 /// \cond
525 template <> inline half Stream::readElement() { return readHalf(); }
526 template <> inline float Stream::readElement() { return readSingle(); }
527 template <> inline double Stream::readElement() { return readDouble(); }
528 template <> inline char Stream::readElement() { return readChar(); }
529 template <> inline unsigned char Stream::readElement() { return readUChar(); }
530 template <> inline bool Stream::readElement() { return readBool(); }
531 template <> inline int16_t Stream::readElement() { return readShort(); }
532 template <> inline uint16_t Stream::readElement() { return readUShort(); }
533 template <> inline int32_t Stream::readElement() { return readInt(); }
534 template <> inline uint32_t Stream::readElement() { return readUInt(); }
535 template <> inline int64_t Stream::readElement() { return readLong(); }
536 template <> inline uint64_t Stream::readElement() { return readULong(); }
537 template <> inline std::string Stream::readElement() { return readString(); }
538 
539 template <> inline void Stream::writeElement(half val) { return writeHalf(val); }
540 template <> inline void Stream::writeElement(float val) { return writeSingle(val); }
541 template <> inline void Stream::writeElement(double val) { return writeDouble(val); }
542 template <> inline void Stream::writeElement(char val) { return writeChar(val); }
543 template <> inline void Stream::writeElement(unsigned char val) { return writeUChar(val); }
544 template <> inline void Stream::writeElement(bool val) { return writeBool(val); }
545 template <> inline void Stream::writeElement(int16_t val) { return writeShort(val); }
546 template <> inline void Stream::writeElement(uint16_t val) { return writeUShort(val); }
547 template <> inline void Stream::writeElement(int32_t val) { return writeInt(val); }
548 template <> inline void Stream::writeElement(uint32_t val) { return writeUInt(val); }
549 template <> inline void Stream::writeElement(int64_t val) { return writeLong(val); }
550 template <> inline void Stream::writeElement(uint64_t val) { return writeULong(val); }
551 template <> inline void Stream::writeElement(const std::string &val) { return writeString(val); }
552 
553 template <> inline void Stream::readArray(half *array, size_t count) { return readHalfArray(array, count); }
554 template <> inline void Stream::readArray(float *array, size_t count) { return readSingleArray(array, count); }
555 template <> inline void Stream::readArray(double *array, size_t count) { return readDoubleArray(array, count); }
556 template <> inline void Stream::readArray(char *array, size_t count) { return read((uint8_t *) array, count); }
557 template <> inline void Stream::readArray(unsigned char *array, size_t count) { return read((uint8_t *) array, count); }
558 template <> inline void Stream::readArray(bool *array, size_t count) { return read((uint8_t *) array, count); }
559 template <> inline void Stream::readArray(int16_t *array, size_t count) { return readShortArray(array, count); }
560 template <> inline void Stream::readArray(uint16_t *array, size_t count) { return readUShortArray(array, count); }
561 template <> inline void Stream::readArray(int32_t *array, size_t count) { return readIntArray(array, count); }
562 template <> inline void Stream::readArray(uint32_t *array, size_t count) { return readUIntArray(array, count); }
563 template <> inline void Stream::readArray(int64_t *array, size_t count) { return readLongArray(array, count); }
564 template <> inline void Stream::readArray(uint64_t *array, size_t count) { return readULongArray(array, count); }
565 
566 template <> inline void Stream::writeArray(const half *array, size_t count) { return writeHalfArray(array, count); }
567 template <> inline void Stream::writeArray(const float *array, size_t count) { return writeSingleArray(array, count); }
568 template <> inline void Stream::writeArray(const double *array, size_t count) { return writeDoubleArray(array, count); }
569 template <> inline void Stream::writeArray(const char *array, size_t count) { return write((uint8_t *) array, count); }
570 template <> inline void Stream::writeArray(const unsigned char *array, size_t count) { return write((uint8_t *) array, count); }
571 template <> inline void Stream::writeArray(const bool *array, size_t count) { return write((uint8_t *) array, count); }
572 template <> inline void Stream::writeArray(const int16_t *array, size_t count) { return writeShortArray(array, count); }
573 template <> inline void Stream::writeArray(const uint16_t *array, size_t count) { return writeUShortArray(array, count); }
574 template <> inline void Stream::writeArray(const int32_t *array, size_t count) { return writeIntArray(array, count); }
575 template <> inline void Stream::writeArray(const uint32_t *array, size_t count) { return writeUIntArray(array, count); }
576 template <> inline void Stream::writeArray(const int64_t *array, size_t count) { return writeLongArray(array, count); }
577 template <> inline void Stream::writeArray(const uint64_t *array, size_t count) { return writeULongArray(array, count); }
578 
579 extern MTS_EXPORT_CORE std::ostream &operator<<(std::ostream &os, const Stream::EByteOrder &value);
580 
581 /// \endcond
582 
584 
585 #endif /* __MITSUBA_CORE_STREAM_H_ */
bool readBool()
Read a boolean (8 bit) from the stream.
Definition: stream.h:385
void writeArray(const T(&arr)[N])
Write a known-size array to the stream (uses partial template specialization to select a method appro...
Definition: stream.h:492
void readUShortArray(short(&values)[N])
Read an array of known size of unsigned shorts (16 bit) from the stream.
Definition: stream.h:323
EByteOrder getByteOrder() const
Return the byte order of this stream.
Definition: stream.h:87
void readFloatArray(Float(&values)[N])
Read a known-size array of floating point values (configured precision) to the stream.
Definition: stream.h:443
void readLongArray(int64_t(&values)[N])
Read an array of known size of signed ints (64 bit) from the stream.
Definition: stream.h:359
void writeDoubleArray(const double(&values)[N])
Write a known size double-precision floating point array (64 bit) to the stream.
Definition: stream.h:266
void readShortArray(short(&values)[N])
Read an array of known size of signed shorts (16 bit) from the stream.
Definition: stream.h:311
void writeShortArray(const short(&values)[N])
Write an array of known size of signed shorts (16 bit) to the stream.
Definition: stream.h:158
void writeHalfArray(const half(&values)[N])
Write a known size half-precision floating point array (16 bit) to the stream.
Definition: stream.h:242
void writeIntArray(const int(&values)[N])
Write an array of known size of signed ints (32 bit) to the stream.
Definition: stream.h:182
void readSingleArray(float(&values)[N])
Read a known-size single-precision floating point array (32 bit) from the stream. ...
Definition: stream.h:407
#define MTS_EXPORT_CORE
Definition: getopt.h:29
Float readFloat()
Write a floating point number (configured precision) to the stream.
Definition: stream.h:424
EOFException(const std::string &str, size_t completed)
Definition: stream.h:31
#define MTS_NAMESPACE_BEGIN
Definition: platform.h:137
std::ostream & operator<<(std::ostream &out, const DScalar1< Scalar, VecType > &s)
Definition: autodiff.h:392
void readDoubleArray(double(&values)[N])
Read a known-size double-precision floating point array (64 bit) from the stream. ...
Definition: stream.h:419
void readArray(T(&arr)[N])
Read a known-size array from the stream (uses partial template specialization to select a method appr...
Definition: stream.h:478
void writeSingleArray(const float(&values)[N])
Write a known size single-precision floating point array (32 bit) to the stream.
Definition: stream.h:254
void writeLongArray(const int64_t(&values)[N])
Write an array of known size of signed ints (64 bit) to the stream.
Definition: stream.h:206
void writeFloatArray(const Float *data, size_t size)
Write an array of floating point values (configured precision) to the stream.
Definition: stream.h:280
void readULongArray(uint64_t(&values)[N])
Read an array of known size of unsigned ints (64 bit) from the stream.
Definition: stream.h:374
void readHalfArray(half(&values)[N])
Read a known-size half-precision floating point array (16 bit) from the stream.
Definition: stream.h:395
size_t getCompleted() const
Return the number of bytes that successfully completed.
Definition: stream.h:35
#define Log(level, fmt,...)
Write a Log message to the console (to be used within subclasses of Object)
Definition: logger.h:35
void writeFloat(Float value)
Write a floating point number (configured precision) to the stream.
Definition: stream.h:271
Abstract seekable stream class.
Definition: stream.h:58
#define MTS_DECLARE_CLASS()
This macro must be used in the initial definition in classes that derive from Object.
Definition: class.h:158
void writeUIntArray(const unsigned int(&values)[N])
Write an array of known size of unsigned ints (32 bit) to the stream.
Definition: stream.h:194
void readFloatArray(Float *data, size_t size)
Write an array of floating point values (configured precision) to the stream.
Definition: stream.h:433
Error message, causes an exception to be thrown.
Definition: formatter.h:33
void readUIntArray(int(&values)[N])
Read an array of known size of unsigned ints (32 bit) from the stream.
Definition: stream.h:347
void writeUShortArray(const unsigned short(&values)[N])
Write an array of known size of unsigned shorts (16 bit) to the stream.
Definition: stream.h:170
static EByteOrder getHostByteOrder()
Return the byte order of the underlying machine.
Definition: stream.h:90
void writeFloatArray(const Float(&values)[N])
Write a known size array of floating point values (configured precision) to the stream.
Definition: stream.h:290
void writeULongArray(const uint64_t(&values)[N])
Write an array of known size of unsigned ints (64 bit) to the stream.
Definition: stream.h:221
void readIntArray(int(&values)[N])
Read an array of known size of signed ints (32 bit) from the stream.
Definition: stream.h:335
Parent of all Mitsuba classes.
Definition: object.h:38
EByteOrder
Defines the byte order to use in this Stream.
Definition: stream.h:61
virtual std::string toString() const
Return a human-readable string representation of the object&#39;s contents.
void writeBool(bool value)
Write a boolean (8 bit) to the stream.
Definition: stream.h:232
void writeSize(size_t value)
Write a size value to the stream.
Definition: stream.h:214
Definition: half.h:96
#define MTS_NAMESPACE_END
Definition: platform.h:138
size_t readSize()
Read a size value from the stream.
Definition: stream.h:367
This exception is thrown after an incomplete IO read/write operation.
Definition: stream.h:29