16 #ifndef __UT_IStream__
17 #define __UT_IStream__
68 { init(fp,
binary, bufferable); }
71 { init(is,
binary, bufferable); }
73 { init(buffer, bufsize, binary); }
85 bool bufferable=true);
87 bool bufferable=true);
96 virtual
int64 getMemoryUsage(
bool inclusive) const;
100 const
char* getFilename() const;
102 void setIsFile(
bool isFile) { myIsFile = isFile; }
114 static void setStdinCompatible(
bool state);
126 {
return myStream->tellg(); }
127 bool seekg(
exint pos,
int seekdir=UT_SEEK_BEG);
140 FileSystemType getFileSystemType()
const;
144 int getFileDescriptor()
const;
152 void setError(
bool is_error) { myError = is_error; }
196 bool skipLine(
int end=
'\n');
199 bool skipWhitespace(
int64 &line_count,
int64 &line_start_pos);
200 bool skipWhitespace();
228 bool strip_inline_comments =
true);
235 if (!getNonCommentWord(wbuf, comment))
237 return !strcmp(wbuf.
buffer(), expected);
246 if (myStream->checkToken(expected))
257 {
return myStream->getc(); }
259 {
return myStream->peekc(); }
267 {
return myStream->unwind(amount); }
278 return myBinary ? bread(array, sz) : aread(array, sz);
282 return myBinary ? bread(array, sz) : aread(array, sz);
286 return myBinary ? bread(array, sz) : aread(array, sz);
290 return myBinary ? bread(array, sz) : aread(array, sz);
294 return myBinary ? bread(array, sz) : aread(array, sz);
298 return myBinary ? bread(array, sz) : aread(array, sz);
302 return myBinary ? bread(array, sz) : aread(array, sz);
306 return myBinary ? bread(
string) : aread(
string);
310 return myBinary ? bread(bytes) : aread(bytes);
314 return readStringHolder(
string, myBinary);
319 template <
typename SOURCE_TYPE,
typename T>
322 exint n = (max_elem <= sz) ? max_elem : sz;
323 exint i = read<SOURCE_TYPE>(array,
n);
327 for (i = max_elem; i < sz; i++)
329 if (!read<SOURCE_TYPE>(&dummy))
336 exint n = (max_elem <= sz) ? max_elem : sz;
337 exint i = read(array, n);
341 for (i = max_elem; i < sz; i++)
374 char *readBinaryData(
380 return (read(&result) == 1);
385 return bread(&result) == 1;
386 return areadChar(result);
390 if (!skipWhitespace())
392 return bread(&result, 1) == 1;
399 {
return myBinary ? bread<SOURCE_TYPE>(
val, sz) : aread(val, sz); }
401 {
return myBinary ? bread<SOURCE_TYPE>(
val, sz) : aread(val, sz); }
403 {
return myBinary ? bread<SOURCE_TYPE>(
val, sz) : aread(val, sz); }
405 {
return myBinary ? bread<SOURCE_TYPE>(
val, sz) : aread(val, sz); }
407 {
return myBinary ? bread<SOURCE_TYPE>(
val, sz) : aread(val, sz); }
421 return bread(reinterpret_cast<char *>(buffer),
size);
425 {
return bread((
char *)buffer, asize); }
427 {
return bread((
char *)buffer, asize); }
430 {
return bread((
int16 *)buffer, asize); }
433 {
return bread((
int32 *)buffer, asize); }
436 {
return bread((
int64 *)buffer, asize); }
439 {
return readStdString(bytes,
true); }
441 {
return readStringHolder(bytes,
true); }
443 {
return readWorkBuffer(bytes,
true); }
471 {
return readStdString(bytes,
false); }
473 {
return readStringHolder(bytes,
false); }
475 {
return readWorkBuffer(bytes,
false); }
560 bool bufferable=
true);
565 bool bufferable=
true);
620 , myPrevBinary(is.myBinary)
626 , myPrevBinary(is.myBinary)
UT_IStream(FILE *fp, UT_ISTREAM_READTYPE binary=UT_ISTREAM_BINARY, bool bufferable=true)
bool checkNonCommentToken(const char *expected, int comment='#')
UT_ASSERT_COMPILETIME(BRAY_EVENT_MAXFLAGS<=32)
GT_API const UT_StringHolder filename
GLenum GLuint GLsizei bufsize
SYS_FORCE_INLINE exint unwind(exint amount)
UT_IStreamBuf * getStreamBuffer()
GLuint GLsizei const GLchar * label
exint read(uint64 *array, exint sz=1)
UT_IStream(std::istream &is, UT_ISTREAM_READTYPE binary=UT_ISTREAM_BINARY, bool bufferable=true)
exint read(T *array, exint sz, exint max_elem)
exint read(int16 *array, exint sz=1)
bool readBool(bool &result)
GLsizei const GLchar *const * string
const GLuint GLenum const void * binary
UT_IStream(const UT_WorkBuffer &buffer, UT_ISTREAM_READTYPE binary=UT_ISTREAM_ASCII)
bool checkToken(const char *expected)
bool aread(UT_String &str)
SYS_FORCE_INLINE const char * buffer() const
bool read(std::string &bytes)
**But if you need a result
bool read(UT_String &string)
unsigned long long uint64
exint bread(signed char *buffer, exint asize=1)
exint read(int64 *val, exint sz=1)
exint bread(bool *buffer, exint size=1)
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
exint bread(uint64 *buffer, exint asize=1)
exint bread(uint16 *buffer, exint asize=1)
exint bread(uint32 *buffer, exint asize=1)
void setVersion(int version)
exint read(fpreal32 *val, exint sz=1)
bool bread(std::string &bytes)
SYS_FORCE_INLINE exint ungetc()
exint read(fpreal16 *val, exint sz=1)
exint read(bool *array, exint sz=1)
UT_IStream(const char *buffer, size_t bufsize, UT_ISTREAM_READTYPE binary)
bool aread(UT_WorkBuffer &bytes)
bool bread(UT_WorkBuffer &bytes)
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
constexpr enabler dummy
An instance to use in EnableIf.
const UT_StringHolder & getLabel() const
exint read(uint32 *array, exint sz=1)
GT_API const UT_StringHolder version
void setError(bool is_error)
UT_IStreamAutoBinary(UT_IStream &is, UT_ISTREAM_READTYPE binary)
bool bread(UT_String &str)
A map of string to various well defined value types.
bool areadChar(char &result)
bool aread(UT_StringHolder &bytes)
void setIsSubStream(bool is_sub_stream)
exint read(int64 *array, exint sz=1)
SYS_FORCE_INLINE int getc()
bool aread(std::string &bytes)
Name readString(std::istream &is)
exint read(int32 *array, exint sz=1)
SYS_FORCE_INLINE int peek()
exint read(int32 *val, exint sz=1)
bool read(UT_StringHolder &string)
void setLabel(const UT_StringHolder &label)
bool readChar(char &result)
exint bread(unsigned char *buffer, exint asize=1)
exint read(uint16 *array, exint sz=1)
exint read(bool *array, exint sz, exint max_elem)
bool skipLine(int end='\n')
UT_IStreamAutoBinary(UT_IStream &is, bool binary)
bool skipLine(int end='\n')
bool bread(UT_StringHolder &bytes)
exint read(fpreal64 *val, exint sz=1)