16 #ifndef __UT_IStreamBuf__
17 #define __UT_IStreamBuf__
31 #define UT_STREAMBUF_SIZE 65536
63 bool bufferable=
true);
65 bool bufferable=
true);
67 bool bufferable=
true);
69 bool bufferable=
true);
71 const unsigned char *key,
exint key_length,
72 bool bufferable=
true);
75 static void setStdinCompatible(
bool state);
93 return myBufCur == myBufEnd && endOfFileSet();
105 virtual int streamPeek() = 0;
109 virtual bool closeFile();
115 virtual int getFileSystemType()
const;
119 virtual int getFileDescriptor()
const;
123 const char *getErrorStr()
const;
124 void stealLoadBufferData(
const char *&bufstart,
134 if (size == 1 && myBufCur != myBufEnd)
142 return read(buffer, size);
148 if (myBufCur == myBufEnd)
170 memcpy(buffer+nread, myBufCur, n);
176 nread += read(buffer+nread, left);
183 if (myBufCur != NULL)
184 return myBufStartPos + (myBufCur - myBufStart);
192 if (myBufCur != NULL && seekdir != UT_SEEK_END)
196 if (seekdir == UT_SEEK_CUR)
197 relpos = pos + (myBufCur - myBufStart);
201 relpos = pos - myBufStartPos;
204 if (relpos >= 0 && relpos < (myBufEnd - myBufStart))
206 myBufCur = myBufStart + relpos;
213 if (seekdir == UT_SEEK_CUR)
214 pos -= (myBufEnd - myBufCur);
222 return seekPos(pos, seekdir);
225 void clearLoadBuffer();
227 bool skipLine(
int end=
'\n');
232 bool skipWhitespace();
233 bool skipWhitespace(
int64 *line_count,
int64 *line_start_pos);
240 UT_ASSERT_MSG(isBufferable(),
"Unbuffered checkToken() not implemented");
242 if (!skipWhitespace())
246 for ( ; *match; ++myBufCur, ++match)
248 if (myBufCur == myBufEnd && !loadBuffer())
250 if (*match != *myBufCur)
254 if (myBufCur == myBufEnd && !loadBuffer())
256 return !myError && SYSisspace(*myBufCur);
264 if (myBufCur != myBufEnd || loadBuffer())
268 return (
int)(
uchar)c;
271 exint nread = read(&data, 1);
274 return (
int)(
uchar)data;
278 if (myBufCur != myBufEnd || loadBuffer())
281 return (
int)(
uchar)c;
292 virtual int64 getMemoryUsage(
bool inclusive)
const;
295 {
return myBufferable; }
303 void setError(
const char *msg=0);
312 virtual void loadBuffer(
exint &bufstartpos,
const char *&bufstart,
const char *&bufend,
bool keepeofif0) = 0;
314 virtual exint tellPos()
const = 0;
315 virtual bool seekPos(
exint pos,
int dir) = 0;
319 virtual bool endOfFileSet()
const = 0;
327 bool loadBuffer(
bool keepeofif0 =
false);
333 const char *myBufStart;
334 const char *myBufCur;
335 const char *myBufEnd;
348 "Unbuffered skipWhitespace() not implemented");
351 if (myBufCur == myBufEnd && !
loadBuffer(
true))
355 for ( ; myBufCur < myBufEnd; ++myBufCur)
357 if (!SYSisspace(*myBufCur))
372 "Unbuffered skipLine not implemented");
375 if (myBufCur == myBufEnd && !
loadBuffer(
true))
379 for ( ; myBufCur < myBufEnd; ++myBufCur)
381 if (*myBufCur == newline)
GT_API const UT_StringHolder filename
exint bread(char *buffer, exint size)
virtual void loadBuffer(exint &bufstartpos, const char *&bufstart, const char *&bufend, bool keepeofif0)=0
SYS_FORCE_INLINE int getc()
#define UT_STREAMBUF_SIZE
bool seekg(exint pos, int seekdir)
#define UT_ASSERT_MSG(ZZ,...)
SYS_FORCE_INLINE int peekc()
bool isBufferable() const
SYS_FORCE_INLINE exint unwind(exint len)
virtual void setIndex(const UT_CompressedBlockIndexPtr &index)
SYS_FORCE_INLINE bool checkToken(const char *match)
A map of string to various well defined value types.
LeafData & operator=(const LeafData &)=delete
bool skipLine(int end='\n')
PXR_NAMESPACE_OPEN_SCOPE typedef unsigned char uchar