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