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  /// Reads the length of a string buffer. This will be an integer of
372  /// the provided startbits. If the value is negative, it signifies
373  /// that the next larger integer will be stored after. The usual
374  /// default value is 16 to match UT_String default saving.
375  exint readStringRLE(UT_ISTREAM_RLE_IO startbits);
376 
377 private:
378  /// Read a chunk of binary data, returning NULL if the data could not be
379  /// read for some reason or it is zero size.
380  /// The exint size of the data is returned in the
381  /// "size" parameter. If add_null is true, the data is null-terminated
382  /// and allocation includes the space for the null terminator. The caller
383  /// is responsible for calling free() on the result. It is safe to adopt
384  /// the result into a UT_String.
385  /// "size" will be negative on error.
386  char *readBinaryData(
387  exint &size, UT_ISTREAM_RLE_IO startbits, bool add_null=false);
388 public:
389 
390  bool readBool(bool &result)
391  {
392  return (read(&result) == 1);
393  }
394  bool readChar(char &result)
395  {
396  if (isBinary())
397  return bread(&result) == 1;
398  return areadChar(result);
399  }
400  bool areadChar(char &result)
401  {
402  if (!skipWhitespace())
403  return false;
404  return bread(&result, 1) == 1;
405  }
406 
407  /// Read a floating point value of the specified source type into the given
408  /// destination variable, performing a conversion as necessary.
409  // @{
410  template <typename SOURCE_TYPE> exint read(int32 *val, exint sz=1)
411  { return myBinary ? bread<SOURCE_TYPE>(val, sz) : aread(val, sz); }
412  template <typename SOURCE_TYPE> exint read(int64 *val, exint sz=1)
413  { return myBinary ? bread<SOURCE_TYPE>(val, sz) : aread(val, sz); }
414  template <typename SOURCE_TYPE> exint read(fpreal16 *val, exint sz=1)
415  { return myBinary ? bread<SOURCE_TYPE>(val, sz) : aread(val, sz); }
416  template <typename SOURCE_TYPE> exint read(fpreal32 *val, exint sz=1)
417  { return myBinary ? bread<SOURCE_TYPE>(val, sz) : aread(val, sz); }
418  template <typename SOURCE_TYPE> exint read(fpreal64 *val, exint sz=1)
419  { return myBinary ? bread<SOURCE_TYPE>(val, sz) : aread(val, sz); }
420 
421  template <typename SOURCE_TYPE> exint bread(int32 *buffer, exint asize=1);
422  template <typename SOURCE_TYPE> exint bread(int64 *buffer, exint asize=1);
423  template <typename SOURCE_TYPE> exint bread(fpreal16 *buffer, exint asize=1);
424  template <typename SOURCE_TYPE> exint bread(fpreal32 *buffer, exint asize=1);
425  template <typename SOURCE_TYPE> exint bread(fpreal64 *buffer, exint asize=1);
426  // @}
427 
428  // Platform consistent binary reads of data. The read methods return the
429  // number of elements read.
430  inline exint bread(bool *buffer, exint size=1)
431  {
432  UT_ASSERT_COMPILETIME(sizeof(bool) == sizeof(char));
433  return bread(reinterpret_cast<char *>(buffer), size);
434  }
435  exint bread(char *buffer, exint asize=1);
436  exint bread(unsigned char *buffer, exint asize=1)
437  { return bread((char *)buffer, asize); }
438  exint bread(signed char *buffer, exint asize=1)
439  { return bread((char *)buffer, asize); }
440  exint bread(int16 *buffer, exint asize=1);
442  { return bread((int16 *)buffer, asize); }
443  exint bread(int32 *buffer, exint asize=1);
445  { return bread((int32 *)buffer, asize); }
446  exint bread(int64 *buffer, exint asize=1);
448  { return bread((int64 *)buffer, asize); }
449  bool bread(UT_String &str) { return readString(str, true); }
451  { return readStdString(bytes, true); }
453  { return readStringHolder(bytes, true); }
455  { return readWorkBuffer(bytes, true); }
456 
457  // Read ASCII values into the buffers. The process is that we read a word,
458  // then run atoi() or atof() on the token. This does NOT set an error bit
459  // if the word is not an integer.
460  //
461  // The aread(char *) method does not exist due to an ambiguity.
462  // The following code:
463  // char chr;
464  // is.read(&chr);
465  // would skip whitespace when reading from an ASCII stream. Since this is
466  // error prone (i.e. you might expect the next character of the stream to
467  // be read), there is no implicit ASCII read method for an array of
468  // characters. To read a single character, please call readChar() or
469  // areadChar().
470  //
471  exint aread(bool *buffer, exint asize=1);
472  exint aread(int16 *buffer, exint asize=1);
473  exint aread(uint16 *buffer, exint asize=1);
474  exint aread(int32 *buffer, exint asize=1);
475  exint aread(uint32 *buffer, exint asize=1);
476  exint aread(int64 *buffer, exint asize=1);
477  exint aread(uint64 *buffer, exint asize=1);
478  exint aread(fpreal16 *buffer, exint asize=1);
479  exint aread(fpreal32 *buffer, exint asize=1);
480  exint aread(fpreal64 *buffer, exint asize=1);
481  bool aread(UT_String &str) { return readString(str, false); }
483  { return readStdString(bytes, false); }
485  { return readStringHolder(bytes, false); }
487  { return readWorkBuffer(bytes, false); }
488 
489 protected:
490  // Protected constructors (used either internally or by sub-classes)
491 
492  // If you can't access this, you want a UT_IFStream subclass
493  UT_IStream(const UT_StringHolder &filename, const UT_Options *open_options,
494  bool bufferable);
496 
497 protected:
498  void initCommon(UT_ISTREAM_READTYPE binary);
499  bool readString(UT_String &str, bool binary);
500  bool readStdString(std::string &bytes, bool binary);
501  bool readStringHolder(UT_StringHolder &bytes, bool binary);
502  bool readWorkBuffer(UT_WorkBuffer &bytes, bool binary);
503  void setError();
504  inline void clearError()
505  { myError = false; }
506 
507  // In practice, myBinaryStack has a max size of 2 for any given session
509 
511 
515  bool myBinary, myEof, myError;
516  bool myIsFile;
518 };
519 
520 inline bool
522 {
523  if (!myError)
524  {
525  if (myStream->skipLine(newline))
526  return true;
527  setError();
528  }
529  return false;
530 }
531 
532 inline bool
534 {
535  if (!myError)
536  {
537  if (myStream->skipWhitespace())
538  return true;
539  setError();
540  }
541  return false;
542 }
543 
544 inline bool
545 UT_IStream::skipWhitespace(int64 &line_count, int64 &line_start_pos)
546 {
547  if (!myError)
548  {
549  if (myStream->skipWhitespace(&line_count, &line_start_pos))
550  return true;
551  setError();
552  }
553  return false;
554 }
555 
556 //
557 // Simple wrapper class for file streams that handles open and close of the
558 // file automatically.
559 class UT_API UT_IFStream : public UT_IStream {
560 public:
561  UT_IFStream();
562 
563  /// Open a file for input
564  ///
565  /// Known Options
566  /// cache_mode "random" or "sequential" hint
567  /// ascii true or false (performs CRLF translation on Windows)
568  /// @{
569  UT_IFStream(
570  const UT_StringHolder &filename,
572  const UT_Options *options=NULL,
573  bool bufferable=true);
574  bool open(
575  const UT_StringHolder &filename,
577  const UT_Options *options=NULL,
578  bool bufferable=true);
579  /// @}
580 
581  ~UT_IFStream() override;
582 
583  bool close();
584 };
585 
586 //
587 // Compressed data input.
588 // Please see the getZlib and getGzip stream methods on UT_IStream.
589 class UT_API UT_IZStream : public UT_IStream {
590 public:
592  ~UT_IZStream() override;
593 };
594 
596 public:
598  ~UT_IGZStream() override;
599 };
600 
601 // Data input encrypted with a blowfish algorithm.
603 public:
604  UT_IBlowfishStream(UT_IStream &src, const unsigned char * key,
605  exint key_size,
607  ~UT_IBlowfishStream() override;
608 
609  /// Obtains the length of data after it has been decrypted from the stream.
610  static exint getPlainTextLength(UT_IStream &src);
611 };
612 
613 //
614 // Turn the stream into binary or ASCII while scoped
616 public:
618  : myIs(is)
619  {
620  myIs.pushBinary(binary);
621  }
623  : myIs(is)
624  {
625  myIs.pushBinary(binary ? UT_ISTREAM_BINARY : UT_ISTREAM_ASCII);
626  }
628  {
629  myIs.popBinary();
630  }
631 private:
632  UT_IStream &myIs;
633 };
634 
635 //
636 // Push operations being performed on the stream. This is for error
637 // reporting.
639 public:
640  // Typically the strings will be compile time defined, which means they
641  // don't need to be hardened. The UT_IStream expects the operation string
642  // to be around for the duration of the operation.
643  explicit UT_IStreamAutoOp(UT_IStream &is, const char *operation,
644  bool harden = false)
645  : myIs(is),
646  myOperation(operation, /*deep_copy*/harden)
647  {
648  myIs.pushOperation(myOperation);
649  }
651  {
652  myIs.popOperation();
653  }
654 private:
655  UT_IStream &myIs;
656  UT_String myOperation;
657 };
658 
659 #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:515
UT_ASSERT_COMPILETIME(BRAY_EVENT_MAXFLAGS<=32)
UT_StringHolder myLabel
Definition: UT_IStream.h:513
GT_API const UT_StringHolder filename
GLenum GLuint GLsizei bufsize
Definition: glcorearb.h:1818
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:390
GLuint start
Definition: glcorearb.h:475
const GLuint GLenum const void * binary
Definition: glcorearb.h:1924
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:533
bool aread(UT_String &str)
Definition: UT_IStream.h:481
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:1793
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:502
exint bread(signed char *buffer, exint asize=1)
Definition: UT_IStream.h:438
exint read(int64 *val, exint sz=1)
Definition: UT_IStream.h:412
exint bread(bool *buffer, exint size=1)
Definition: UT_IStream.h:430
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
GLsizeiptr size
Definition: glcorearb.h:664
double fpreal64
Definition: SYS_Types.h:201
exint bread(uint64 *buffer, exint asize=1)
Definition: UT_IStream.h:447
UT_IStreamBuf * myStream
Definition: UT_IStream.h:512
exint bread(uint16 *buffer, exint asize=1)
Definition: UT_IStream.h:441
exint bread(uint32 *buffer, exint asize=1)
Definition: UT_IStream.h:444
GLenum array
Definition: glew.h:9108
UT_SmallArray< int, sizeof(int)*4 > myBinaryStack
Definition: UT_IStream.h:508
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
Definition: core.h:760
exint read(fpreal32 *val, exint sz=1)
Definition: UT_IStream.h:416
int open(float queuesize) override
bool bread(std::string &bytes)
Definition: UT_IStream.h:450
SYS_FORCE_INLINE exint ungetc()
Definition: UT_IStream.h:277
exint read(fpreal16 *val, exint sz=1)
Definition: UT_IStream.h:414
exint read(bool *array, exint sz=1)
Definition: UT_IStream.h:288
GLuint GLuint end
Definition: glcorearb.h:475
#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:516
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
bool aread(UT_WorkBuffer &bytes)
Definition: UT_IStream.h:486
bool bread(UT_WorkBuffer &bytes)
Definition: UT_IStream.h:454
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2545
const UT_StringHolder & getLabel() const
Definition: UT_IStream.h:166
long long int64
Definition: SYS_Types.h:116
bool myIsSubStream
Definition: UT_IStream.h:517
UT_IStreamAutoOp(UT_IStream &is, const char *operation, bool harden=false)
Definition: UT_IStream.h:643
exint read(uint32 *array, exint sz=1)
Definition: UT_IStream.h:304
int myVersion
Definition: UT_IStream.h:514
bool isSubStream() const
Definition: UT_IStream.h:105
GT_API const UT_StringHolder version
GLdouble n
Definition: glcorearb.h:2008
void setError(bool is_error)
Definition: UT_IStream.h:150
UT_IStreamAutoBinary(UT_IStream &is, UT_ISTREAM_READTYPE binary)
Definition: UT_IStream.h:617
GLuint GLfloat * val
Definition: glcorearb.h:1608
bool bread(UT_String &str)
Definition: UT_IStream.h:449
A map of string to various well defined value types.
Definition: UT_Options.h:84
bool areadChar(char &result)
Definition: UT_IStream.h:400
bool aread(UT_StringHolder &bytes)
Definition: UT_IStream.h:484
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:482
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:504
exint read(int32 *val, exint sz=1)
Definition: UT_IStream.h:410
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:394
exint bread(unsigned char *buffer, exint asize=1)
Definition: UT_IStream.h:436
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:622
bool skipLine(int end='\n')
Definition: UT_IStream.h:521
Definition: format.h:2459
bool bread(UT_StringHolder &bytes)
Definition: UT_IStream.h:452
UT_Array< const char * > myOperationStack
Definition: UT_IStream.h:510
exint read(fpreal64 *val, exint sz=1)
Definition: UT_IStream.h:418