HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_IStream.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_IStream.h ( UT Library, C++)
7  *
8  * COMMENTS: Since the semantics of C++ streams leave a little bit to be
9  * desired, this class provides an efficient mechanism to read
10  * streams line by line.
11  *
12  * However, since this class buffers the stream input itself, it's
13  * not safe to use the stream outside of the class.
14  */
15 
16 #ifndef __UT_IStream__
17 #define __UT_IStream__
18 
19 #include "UT_API.h"
20 #include "UT_Array.h"
21 #include "UT_IOS.h"
22 #include "UT_IStreamBuf.h"
23 #include "UT_SmallArray.h"
24 #include "UT_StringHolder.h"
25 #include "UT_UniquePtr.h"
26 #include "UT_WorkBuffer.h"
27 #include <SYS/SYS_Inline.h>
28 #include <SYS/SYS_Types.h>
29 #include <fstream> // Only needed for gcc4.4 for handling of getc()
30 #include <stdio.h>
31 #include <string.h>
32 #include <string>
33 #include <iosfwd>
34 
35 class UT_String;
36 class UT_Options;
37 
38 typedef enum {
39  UT_ISTREAM_ASCII = UT_IOS_ASCII, // Ascii stream
42 
43 //
44 // When saving/loading binary strings, we store the run length of the string
45 // prior to saving the string data. This enum specifies the minimum value
46 // possible for the run-length.
47 //
48 // It is somewhat dangerous to use 8 bit lengths.
49 //
50 typedef enum {
56 
58 public:
59  /// WARNING: You MUST call init before using a default-constructed
60  /// UT_IStream!
62 
63  /// FIXME: Many functions will assert when bufferable is false,
64  /// because they assume that they can read directly from
65  /// the buffer.
67  bool bufferable=true)
68  { init(fp, binary, bufferable); }
70  bool bufferable=true)
71  { init(is, binary, bufferable); }
73  { init(buffer, bufsize, binary); }
76  { init(buffer, binary); }
77 
78  virtual ~UT_IStream();
79 
81  bool bufferable=true);
82  void init(std::istream &is, UT_ISTREAM_READTYPE binary=UT_ISTREAM_BINARY,
83  bool bufferable=true);
84  void init(const char *buffer, size_t bufsize, UT_ISTREAM_READTYPE binary);
85  void init(const UT_WorkBuffer &buffer,
87 
88  /// NOTE: This counts the memory of the UT_IStreamBuf, even though it
89  /// may be shared among multiple UT_IStream objects.
90  virtual int64 getMemoryUsage(bool inclusive) const;
91 
92  /// Retrieves the filename of this stream if it was created from file
93  /// returns NULL otherwise
94  const char* getFilename() const;
95 
96  void setIsFile(bool isFile) { myIsFile = isFile; }
97 
98  /// It can be useful to know if this stream is a substream, particularly
99  /// when this stream is flagged as a file.
100  void setIsSubStream(bool is_sub_stream) { myIsSubStream = is_sub_stream; }
101  bool isSubStream() const { return myIsSubStream; }
102 
103  // Typically, when reading from a non-tty stdin, istreams are able to
104  // buffer the contents. However, in some cases, when there's a
105  // controlling application sending commands sporadically, it's important
106  // to set compatibility on stdin. This will result in slightly slower
107  // input and should only be used when required.
108  static void setStdinCompatible(bool state);
109 
110  enum {
111  UT_SEEK_BEG=UT_IOS_SEEK_BEG, // Seek from beginning of stream
112  UT_SEEK_CUR=UT_IOS_SEEK_CUR, // Seek from current location
113  UT_SEEK_END=UT_IOS_SEEK_END // Seek from the end of the stream
114  };
115 
116  /// @{
117  /// Query or seek to a position in the stream. Please see documentation
118  /// for standard istreams for further information.
119  exint tellg() const
120  { return myStream->tellg(); }
121  bool seekg(exint pos, int seekdir=UT_SEEK_BEG);
122  /// @}
123 
124  /// Check whether the stream refers to a filename and whether the file
125  /// supports random seeks.
126  bool isRandomAccessFile(UT_WorkBuffer &filename) const;
127 
128  /// Return whether the stream refers to a local drive or a network path.
129  typedef enum {
130  UT_FSYSTEM_UNKNOWN, // Unknown file system
131  UT_FSYSTEM_LOCAL, // Local file system
132  UT_FSYSTEM_NETWORK, // NFS or SMB file system
133  } FileSystemType;
134  FileSystemType getFileSystemType() const;
135 
136  /// Returns the open file descriptor, if any. Be careful what you do with
137  /// it.
138  int getFileDescriptor() const;
139 
140  // Returns true if the stream is out of data OR if there's an error on the
141  // stream.
142  bool isEof() const;
143 
144  // Return the error status.
145  bool isError() const { return myError; }
146  void setError(bool is_error) { myError = is_error; }
147 
148  bool isAscii() const { return !myBinary; }
149  bool isBinary() const { return myBinary; }
150 
151  /// The version information can be used to stash version information with
152  /// the stream itself rather than having to pass the version information
153  /// through to all other loading methods. This is used primarily in
154  /// legacy geometry loading.
155  void setVersion(int version) { myVersion = version; }
156  int getVersion() const { return myVersion; }
157 
158  /// The label methods provide a way to give the stream a label which is
159  /// used to identify the stream in error messages. For example,
160  /// UT_IFStream sets the label to the filename.
161  void setLabel(const UT_StringHolder& label) { myLabel = label; }
162  const UT_StringHolder &getLabel() const { return myLabel; }
163 
164  /// The read() methods use the binary state of the stream to determine
165  /// whether to read ASCII or binary values. Rather than calling this
166  /// method directly, it would be better to create a UT_IStreamAutoBinary,
167  /// which will automatically pop the state on its destruction.
168  void pushBinary(UT_ISTREAM_READTYPE binary);
169  void popBinary();
170 
171  /// For error handling. If an error occurs on the stream, the operation
172  /// will be added to the error message (i.e. "loading image"). Rather
173  /// than calling this method directly, it would probably be better to use
174  /// UT_IStreamAutoOp which automatically pops the operation.
175  void pushOperation(const char *operation);
176  void popOperation();
177 
178  // Set a sub-range of the stream. The stream will automatically seek the
179  // the start position specified. The stream will hit EOF when nbytes have
180  // been read from the stream. Seeking should work (assertions will be
181  // triggered if the seek is out of bounds). Absolute seek positions are
182  // specified based on the original stream.
183  UT_IStreamBuf *getStreamBuffer() { return myStream; }
184 
185  /// Returns a stream represenging a substream of the parent stream starting
186  /// at 'start' byte and containin 'nbytes'.
187  UT_UniquePtr<UT_IStream> getSubStream(exint start, exint nbytes);
188 
189  // The zlib, gzip, and blosc streams are available for decompression.
190  // The difference between zlib and gzip is subtle, but very important.
191  // - zlib compression uses the zlib library to perform inflation of the
192  // data. However, the bit window specified is slightly different
193  // than for gzip compression.
194  // - gzip compression uses the zlib library to perform inflation of the
195  // data. However, it expects that the data has a gzip header
196  // before the compressed data begins. As well, the window size is
197  // slightly different than raw zlib compression.
198  UT_UniquePtr<UT_IStream> getZlibStream();
199  UT_UniquePtr<UT_IStream> getGzipStream();
200  UT_UniquePtr<UT_IStream> getBloscStream();
201  UT_UniquePtr<UT_IStream> getSCStream();
202 
203  bool getLine(UT_WorkBuffer &buffer, int end='\n');
204  bool skipLine(int end='\n');
205  bool getWord(UT_WorkBuffer &buffer);
206  bool getString(UT_WorkBuffer &buffer);
207  bool skipWhitespace(int64 &line_count, int64 &line_start_pos);
208  bool skipWhitespace();
209 
210  /// Read a JSON token. This assumes that leading white space has been
211  /// trimmed and will read all characters until:
212  /// - a space (\\f, \\v, \\r, \\n, \\t, ' ')
213  /// - a separator ('/', '{', '}', '[', ']', ',', ':', '"')
214  /// @note The real flag will be set if the word contains ('.', 'e', or 'E')
215  bool getJSONWord(UT_WorkBuffer &buffer, bool &real);
216 
217  /// Reads in the entire stream from the current position to the end.
218  /// Returns true if anything was read in, false otherwise. Use
219  /// isError() to test error state.
220  bool getAll(UT_WorkBuffer &buffer);
221 
222  /// Does the same as getAll, except any carriage return-newline (\r\n)
223  /// sequences are converted into newlines (\n).
224  bool getAllAscii(UT_WorkBuffer &buffer);
225 
226  /// Skips all the comment lines and reads the next token in the stream.
227  /// Returns true if successful and false otherwise.
228  bool getNonCommentWord(UT_WorkBuffer &buffer, int comment='#');
229 
230  /// Skips all the comment lines and reads the next line in the stream.
231  /// Returns the number of lines read. Note that the resulting line will
232  /// be stripped of leading white space as well. The
233  /// strip_inline_comments argument determines whether or not the resulting
234  /// line should have comments at the end, if any, stripped.
235  exint getNonCommentLine(UT_WorkBuffer &buffer, int comment='#',
236  bool strip_inline_comments = true);
237 
238  /// Reads in the next token (skipping comments) and compares it to the
239  /// expected value. Returns true if the tokens match, and false otherwise.
240  bool checkNonCommentToken(const char *expected, int comment='#')
241  {
242  UT_WorkBuffer wbuf;
243  if (!getNonCommentWord(wbuf, comment))
244  return false;
245  return !strcmp(wbuf.buffer(), expected);
246  }
247 
248  /// Reads in the next token and compares it to the expected value.
249  /// Returns true if the tokens match, and false otherwise.
250  bool checkToken(const char *expected)
251  {
252  if (!myError)
253  {
254  if (myStream->checkToken(expected))
255  return true;
256  setError();
257  }
258  return false;
259  }
260 
261  /// getc and peek return the character read as an unsigned char cast to an
262  /// int, or -1 (EOF) on failure. In other words, characters with the high
263  /// bit set will return a number from 128 to 255, not a negative number.
265  { return myStream->getc(); }
267  { return myStream->peekc(); }
268 
269  // Returns the number of characters the stream was able to rewind. The
270  // class is guaranteed to be able to put back one character if myBufferable.
271  // Otherwise, you takes your chances. This is not true if you peek into the
272  // stream. Calling peek() may cause backup to fail.
273  SYS_FORCE_INLINE exint ungetc() { return unwind(1); }
275  { return myStream->unwind(amount); }
276 
277  // Read data into an array of the given type. The data will be
278  // byte-swapped according to the Houdini standard. The size specified is
279  // the number of elements in the array (not the size in bytes).
280  //
281  // Due to an ambiguity when reading characters from an ASCII stream,
282  // there is no generic method to read characters. Use the bread() method
283  // to read raw characters, or the getWord() method to read a word.
284  exint read(bool *array, exint sz=1)
285  {
286  return myBinary ? bread(array, sz) : aread(array, sz);
287  }
288  exint read(int16 *array, exint sz=1)
289  {
290  return myBinary ? bread(array, sz) : aread(array, sz);
291  }
292  exint read(uint16 *array, exint sz=1)
293  {
294  return myBinary ? bread(array, sz) : aread(array, sz);
295  }
296  exint read(int32 *array, exint sz=1)
297  {
298  return myBinary ? bread(array, sz) : aread(array, sz);
299  }
300  exint read(uint32 *array, exint sz=1)
301  {
302  return myBinary ? bread(array, sz) : aread(array, sz);
303  }
304  exint read(int64 *array, exint sz=1)
305  {
306  return myBinary ? bread(array, sz) : aread(array, sz);
307  }
308  exint read(uint64 *array, exint sz=1)
309  {
310  return myBinary ? bread(array, sz) : aread(array, sz);
311  }
312  bool read(UT_String &string)
313  {
314  return myBinary ? bread(string) : aread(string);
315  }
316  bool read(std::string &bytes)
317  {
318  return myBinary ? bread(bytes) : aread(bytes);
319  }
320  bool read(UT_StringHolder &string)
321  {
322  return readStringHolder(string, myBinary);
323  }
324 
325  // Helpers for reading sz elements from the stream, but only storing
326  // the first max_elem number of elements.
327  template <typename SOURCE_TYPE, typename T>
328  exint read(T *array, exint sz, exint max_elem)
329  {
330  exint n = (max_elem <= sz) ? max_elem : sz;
331  exint i = read<SOURCE_TYPE>(array, n);
332  if (i <= max_elem)
333  return i;
334  SOURCE_TYPE dummy;
335  for (i = max_elem; i < sz; i++)
336  {
337  if (!read<SOURCE_TYPE>(&dummy))
338  break;
339  }
340  return i;
341  }
342  exint read(bool *array, exint sz, exint max_elem)
343  {
344  exint n = (max_elem <= sz) ? max_elem : sz;
345  exint i = read(array, n);
346  if (i <= max_elem)
347  return i;
348  bool dummy;
349  for (i = max_elem; i < sz; i++)
350  {
351  if (!read(&dummy))
352  break;
353  }
354  return i;
355  }
356 
357  // Read a string that was saved by first writing the number of bytes in the
358  // stream, followed by the string itself. The length was stored using as
359  // few bytes as possible, and startbits specifies the minimum number of
360  // size bits it can expect. Note that a UT_String cannot contain data with
361  // null's, so use readBinaryData below or read(std::string &) for binary
362  // data.
363  bool readBinaryString(UT_String &str, UT_ISTREAM_RLE_IO startbits);
364  bool readBinaryString(UT_StringHolder &string,
365  UT_ISTREAM_RLE_IO startbits);
366 
367  // Read a chunk of binary data, returning NULL if the data could not be
368  // read for some reason. The exint size of the data is returned in the
369  // "size" parameter. If add_null is true, the data is null-terminated
370  // and "size" includes the space for the null terminator. The caller
371  // is responsible for calling free() on the result. It is safe to adopt
372  // the result into a UT_String.
373  char *readBinaryData(
374  exint &size, UT_ISTREAM_RLE_IO startbits, bool add_null=false);
375 
376  bool readBool(bool &result)
377  {
378  return (read(&result) == 1);
379  }
380  bool readChar(char &result)
381  {
382  if (isBinary())
383  return bread(&result) == 1;
384  return areadChar(result);
385  }
386  bool areadChar(char &result)
387  {
388  if (!skipWhitespace())
389  return false;
390  return bread(&result, 1) == 1;
391  }
392 
393  /// Read a floating point value of the specified source type into the given
394  /// destination variable, performing a conversion as necessary.
395  // @{
396  template <typename SOURCE_TYPE> exint read(int32 *val, exint sz=1)
397  { return myBinary ? bread<SOURCE_TYPE>(val, sz) : aread(val, sz); }
398  template <typename SOURCE_TYPE> exint read(int64 *val, exint sz=1)
399  { return myBinary ? bread<SOURCE_TYPE>(val, sz) : aread(val, sz); }
400  template <typename SOURCE_TYPE> exint read(fpreal16 *val, exint sz=1)
401  { return myBinary ? bread<SOURCE_TYPE>(val, sz) : aread(val, sz); }
402  template <typename SOURCE_TYPE> exint read(fpreal32 *val, exint sz=1)
403  { return myBinary ? bread<SOURCE_TYPE>(val, sz) : aread(val, sz); }
404  template <typename SOURCE_TYPE> exint read(fpreal64 *val, exint sz=1)
405  { return myBinary ? bread<SOURCE_TYPE>(val, sz) : aread(val, sz); }
406 
407  template <typename SOURCE_TYPE> exint bread(int32 *buffer, exint asize=1);
408  template <typename SOURCE_TYPE> exint bread(int64 *buffer, exint asize=1);
409  template <typename SOURCE_TYPE> exint bread(fpreal16 *buffer, exint asize=1);
410  template <typename SOURCE_TYPE> exint bread(fpreal32 *buffer, exint asize=1);
411  template <typename SOURCE_TYPE> exint bread(fpreal64 *buffer, exint asize=1);
412  // @}
413 
414  // Platform consistent binary reads of data. The read methods return the
415  // number of elements read.
416  inline exint bread(bool *buffer, exint size=1)
417  {
418  UT_ASSERT_COMPILETIME(sizeof(bool) == sizeof(char));
419  return bread(reinterpret_cast<char *>(buffer), size);
420  }
421  exint bread(char *buffer, exint asize=1);
422  exint bread(unsigned char *buffer, exint asize=1)
423  { return bread((char *)buffer, asize); }
424  exint bread(signed char *buffer, exint asize=1)
425  { return bread((char *)buffer, asize); }
426  exint bread(int16 *buffer, exint asize=1);
428  { return bread((int16 *)buffer, asize); }
429  exint bread(int32 *buffer, exint asize=1);
431  { return bread((int32 *)buffer, asize); }
432  exint bread(int64 *buffer, exint asize=1);
434  { return bread((int64 *)buffer, asize); }
435  bool bread(UT_String &str) { return readString(str, true); }
436  bool bread(std::string &bytes)
437  { return readStdString(bytes, true); }
438  bool bread(UT_StringHolder &bytes)
439  { return readStringHolder(bytes, true); }
440 
441  // Read ASCII values into the buffers. The process is that we read a word,
442  // then run atoi() or atof() on the token. This does NOT set an error bit
443  // if the word is not an integer.
444  //
445  // The aread(char *) method does not exist due to an ambiguity.
446  // The following code:
447  // char chr;
448  // is.read(&chr);
449  // would skip whitespace when reading from an ASCII stream. Since this is
450  // error prone (i.e. you might expect the next character of the stream to
451  // be read), there is no implicit ASCII read method for an array of
452  // characters. To read a single character, please call readChar() or
453  // areadChar().
454  //
455  exint aread(bool *buffer, exint asize=1);
456  exint aread(int16 *buffer, exint asize=1);
457  exint aread(uint16 *buffer, exint asize=1);
458  exint aread(int32 *buffer, exint asize=1);
459  exint aread(uint32 *buffer, exint asize=1);
460  exint aread(int64 *buffer, exint asize=1);
461  exint aread(uint64 *buffer, exint asize=1);
462  exint aread(fpreal16 *buffer, exint asize=1);
463  exint aread(fpreal32 *buffer, exint asize=1);
464  exint aread(fpreal64 *buffer, exint asize=1);
465  bool aread(UT_String &str) { return readString(str, false); }
466  bool aread(std::string &bytes)
467  { return readStdString(bytes, false); }
468  bool aread(UT_StringHolder &bytes)
469  { return readStringHolder(bytes, false); }
470 
471 protected:
472  // Protected constructors (used either internally or by sub-classes)
473 
474  // If you can't access this, you want a UT_IFStream subclass
475  UT_IStream(const UT_StringHolder &filename, const UT_Options *open_options,
476  bool bufferable);
478 
479 protected:
480  void initCommon(UT_ISTREAM_READTYPE binary);
481  bool readString(UT_String &str, bool binary);
482  bool readStdString(std::string &bytes, bool binary);
483  bool readStringHolder(UT_StringHolder &bytes, bool binary);
484  void setError();
485  inline void clearError()
486  { myError = false; }
487 
488  // In practice, myBinaryStack has a max size of 2 for any given session
490 
492 
496  bool myBinary, myEof, myError;
497  bool myIsFile;
499 };
500 
501 inline bool
503 {
504  if (!myError)
505  {
506  if (myStream->skipLine(newline))
507  return true;
508  setError();
509  }
510  return false;
511 }
512 
513 inline bool
515 {
516  if (!myError)
517  {
518  if (myStream->skipWhitespace())
519  return true;
520  setError();
521  }
522  return false;
523 }
524 
525 inline bool
526 UT_IStream::skipWhitespace(int64 &line_count, int64 &line_start_pos)
527 {
528  if (!myError)
529  {
530  if (myStream->skipWhitespace(&line_count, &line_start_pos))
531  return true;
532  setError();
533  }
534  return false;
535 }
536 
537 //
538 // Simple wrapper class for file streams that handles open and close of the
539 // file automatically.
540 class UT_API UT_IFStream : public UT_IStream {
541 public:
542  UT_IFStream();
543 
544  /// Open a file for input
545  ///
546  /// Known Options
547  /// cache_mode "random" or "sequential" hint
548  /// ascii true or false (performs CRLF translation on Windows)
549  /// @{
550  UT_IFStream(
551  const UT_StringHolder &filename,
553  const UT_Options *options=NULL,
554  bool bufferable=true);
555  bool open(
556  const UT_StringHolder &filename,
558  const UT_Options *options=NULL,
559  bool bufferable=true);
560  /// @}
561 
562  virtual ~UT_IFStream();
563 
564  bool close();
565 };
566 
567 //
568 // Compressed data input.
569 // Please see the getZlib and getGzip stream methods on UT_IStream.
570 class UT_API UT_IZStream : public UT_IStream {
571 public:
573  virtual ~UT_IZStream();
574 };
575 
577 public:
579  virtual ~UT_IGZStream();
580 };
581 
582 // Data input encrypted with a blowfish algorithm.
584 public:
585  UT_IBlowfishStream(UT_IStream &src, const unsigned char * key,
586  exint key_size,
588  virtual ~UT_IBlowfishStream();
589 
590  /// Obtains the length of data after it has been decrypted from the stream.
591  static exint getPlainTextLength(UT_IStream &src);
592 };
593 
594 //
595 // Turn the stream into binary or ASCII while scoped
597 public:
599  : myIs(is)
600  {
601  myIs.pushBinary(binary);
602  }
604  : myIs(is)
605  {
606  myIs.pushBinary(binary ? UT_ISTREAM_BINARY : UT_ISTREAM_ASCII);
607  }
609  {
610  myIs.popBinary();
611  }
612 private:
613  UT_IStream &myIs;
614 };
615 
616 //
617 // Push operations being performed on the stream. This is for error
618 // reporting.
620 public:
621  // Typically the strings will be compile time defined, which means they
622  // don't need to be hardened. The UT_IStream expects the operation string
623  // to be around for the duration of the operation.
624  explicit UT_IStreamAutoOp(UT_IStream &is, const char *operation,
625  bool harden = false)
626  : myIs(is),
627  myOperation(operation, harden ? 1 : 0)
628  {
629  myIs.pushOperation(myOperation);
630  }
632  {
633  myIs.popOperation();
634  }
635 private:
636  UT_IStream &myIs;
637  UT_String myOperation;
638 };
639 
640 #endif
UT_IStream(FILE *fp, UT_ISTREAM_READTYPE binary=UT_ISTREAM_BINARY, bool bufferable=true)
Definition: UT_IStream.h:66
bool checkNonCommentToken(const char *expected, int comment='#')
Definition: UT_IStream.h:240
bool myError
Definition: UT_IStream.h:496
UT_StringHolder myLabel
Definition: UT_IStream.h:494
GT_API const UT_StringHolder filename
GLenum GLuint GLsizei bufsize
Definition: glcorearb.h:1817
SYS_FORCE_INLINE exint unwind(exint amount)
Definition: UT_IStream.h:274
UT_IStreamBuf * getStreamBuffer()
Definition: UT_IStream.h:183
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2544
exint read(uint64 *array, exint sz=1)
Definition: UT_IStream.h:308
UT_IStream(std::istream &is, UT_ISTREAM_READTYPE binary=UT_ISTREAM_BINARY, bool bufferable=true)
Definition: UT_IStream.h:69
exint read(T *array, exint sz, exint max_elem)
Definition: UT_IStream.h:328
exint read(int16 *array, exint sz=1)
Definition: UT_IStream.h:288
bool isAscii() const
Definition: UT_IStream.h:148
bool readBool(bool &result)
Definition: UT_IStream.h:376
GLuint start
Definition: glcorearb.h:474
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
const GLuint GLenum const void * binary
Definition: glcorearb.h:1923
UT_ISTREAM_RLE_IO
Definition: UT_IStream.h:50
UT_IStream(const UT_WorkBuffer &buffer, UT_ISTREAM_READTYPE binary=UT_ISTREAM_ASCII)
Definition: UT_IStream.h:74
void setIsFile(bool isFile)
Definition: UT_IStream.h:96
bool checkToken(const char *expected)
Definition: UT_IStream.h:250
bool skipWhitespace()
Definition: UT_IStream.h:514
bool aread(UT_String &str)
Definition: UT_IStream.h:465
SYS_FORCE_INLINE const char * buffer() const
void setError()
bool read(std::string &bytes)
Definition: UT_IStream.h:316
#define UT_API
Definition: UT_API.h:13
exint tellg() const
Definition: UT_IStream.h:119
int getVersion() const
Definition: UT_IStream.h:156
bool read(UT_String &string)
Definition: UT_IStream.h:312
void read(T &in, bool &v)
Definition: ImfXdr.h:611
GLuint buffer
Definition: glcorearb.h:659
png_uint_32 i
Definition: png.h:2877
GLsizeiptr size
Definition: glcorearb.h:663
exint bread(signed char *buffer, exint asize=1)
Definition: UT_IStream.h:424
exint read(int64 *val, exint sz=1)
Definition: UT_IStream.h:398
exint bread(bool *buffer, exint size=1)
Definition: UT_IStream.h:416
exint bread(uint64 *buffer, exint asize=1)
Definition: UT_IStream.h:433
UT_IStreamBuf * myStream
Definition: UT_IStream.h:493
exint bread(uint16 *buffer, exint asize=1)
Definition: UT_IStream.h:427
exint bread(uint32 *buffer, exint asize=1)
Definition: UT_IStream.h:430
long long int64
Definition: SYS_Types.h:107
png_FILE_p fp
Definition: png.h:2028
GLdouble n
Definition: glcorearb.h:2007
UT_SmallArray< int, sizeof(int)*4 > myBinaryStack
Definition: UT_IStream.h:489
bool skipWhitespace()
void setVersion(int version)
Definition: UT_IStream.h:155
unsigned long long uint64
Definition: SYS_Types.h:108
bool isError() const
Definition: UT_IStream.h:145
exint read(fpreal32 *val, exint sz=1)
Definition: UT_IStream.h:402
bool bread(std::string &bytes)
Definition: UT_IStream.h:436
SYS_FORCE_INLINE exint ungetc()
Definition: UT_IStream.h:273
exint read(fpreal16 *val, exint sz=1)
Definition: UT_IStream.h:400
int64 exint
Definition: SYS_Types.h:116
double fpreal64
Definition: SYS_Types.h:192
exint read(bool *array, exint sz=1)
Definition: UT_IStream.h:284
GLuint GLuint end
Definition: glcorearb.h:474
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
UT_IStream(const char *buffer, size_t bufsize, UT_ISTREAM_READTYPE binary)
Definition: UT_IStream.h:72
bool myIsFile
Definition: UT_IStream.h:497
const UT_StringHolder & getLabel() const
Definition: UT_IStream.h:162
bool myIsSubStream
Definition: UT_IStream.h:498
UT_IStreamAutoOp(UT_IStream &is, const char *operation, bool harden=false)
Definition: UT_IStream.h:624
int int32
Definition: SYS_Types.h:35
virtual int open(float queuesize)
exint read(uint32 *array, exint sz=1)
Definition: UT_IStream.h:300
int myVersion
Definition: UT_IStream.h:495
bool isSubStream() const
Definition: UT_IStream.h:101
GT_API const UT_StringHolder version
void setError(bool is_error)
Definition: UT_IStream.h:146
UT_IStreamAutoBinary(UT_IStream &is, UT_ISTREAM_READTYPE binary)
Definition: UT_IStream.h:598
unsigned short uint16
Definition: SYS_Types.h:34
bool bread(UT_String &str)
Definition: UT_IStream.h:435
A map of string to various well defined value types.
Definition: UT_Options.h:42
bool areadChar(char &result)
Definition: UT_IStream.h:386
bool aread(UT_StringHolder &bytes)
Definition: UT_IStream.h:468
void setIsSubStream(bool is_sub_stream)
Definition: UT_IStream.h:100
UT_ISTREAM_READTYPE
Definition: UT_IStream.h:38
exint read(int64 *array, exint sz=1)
Definition: UT_IStream.h:304
SYS_FORCE_INLINE int getc()
Definition: UT_IStream.h:264
virtual void close()
bool isBinary() const
Definition: UT_IStream.h:149
GLuint GLfloat * val
Definition: glcorearb.h:1607
bool aread(std::string &bytes)
Definition: UT_IStream.h:466
Name readString(std::istream &is)
Definition: Name.h:47
exint read(int32 *array, exint sz=1)
Definition: UT_IStream.h:296
SYS_FORCE_INLINE int peek()
Definition: UT_IStream.h:266
void clearError()
Definition: UT_IStream.h:485
exint read(int32 *val, exint sz=1)
Definition: UT_IStream.h:396
bool read(UT_StringHolder &string)
Definition: UT_IStream.h:320
void setLabel(const UT_StringHolder &label)
Definition: UT_IStream.h:161
bool readChar(char &result)
Definition: UT_IStream.h:380
exint bread(unsigned char *buffer, exint asize=1)
Definition: UT_IStream.h:422
exint read(uint16 *array, exint sz=1)
Definition: UT_IStream.h:292
exint read(bool *array, exint sz, exint max_elem)
Definition: UT_IStream.h:342
bool skipLine(int end='\n')
short int16
Definition: SYS_Types.h:33
UT_ASSERT_COMPILETIME(BRAY_EVENT_MAXFLAGS<=32)
UT_IStreamAutoBinary(UT_IStream &is, bool binary)
Definition: UT_IStream.h:603
float fpreal32
Definition: SYS_Types.h:191
bool skipLine(int end='\n')
Definition: UT_IStream.h:502
bool bread(UT_StringHolder &bytes)
Definition: UT_IStream.h:438
UT_Array< const char * > myOperationStack
Definition: UT_IStream.h:491
exint read(fpreal64 *val, exint sz=1)
Definition: UT_IStream.h:404
GLenum src
Definition: glcorearb.h:1792
unsigned int uint32
Definition: SYS_Types.h:36