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