16 #ifndef __UT_IStreamBuf__
17 #define __UT_IStreamBuf__
31 #define UT_STREAMBUF_SIZE 65536
59 bool bufferable=
true);
61 bool bufferable=
true);
63 bool bufferable=
true);
65 bool bufferable=
true);
67 const unsigned char *key,
exint key_length,
68 bool bufferable=
true);
71 static void setStdinCompatible(
bool state);
89 return myBufCur == myBufEnd && endOfFileSet();
101 virtual int streamPeek() = 0;
105 virtual bool closeFile();
111 virtual int getFileSystemType()
const;
115 virtual int getFileDescriptor()
const;
119 const char *getErrorStr()
const;
120 void stealLoadBufferData(
const char *&bufstart,
130 if (size == 1 && myBufCur != myBufEnd)
138 return read(buffer, size);
144 if (myBufCur == myBufEnd)
166 memcpy(buffer+nread, myBufCur, n);
172 nread +=
read(buffer+nread, left);
179 if (myBufCur != NULL)
180 return myBufStartPos + (myBufCur - myBufStart);
188 if (myBufCur != NULL && seekdir != UT_SEEK_END)
192 if (seekdir == UT_SEEK_CUR)
193 relpos = pos + (myBufCur - myBufStart);
197 relpos = pos - myBufStartPos;
200 if (relpos >= 0 && relpos < (myBufEnd - myBufStart))
202 myBufCur = myBufStart + relpos;
209 if (seekdir == UT_SEEK_CUR)
210 pos -= (myBufEnd - myBufCur);
218 return seekPos(pos, seekdir);
221 void clearLoadBuffer();
223 bool skipLine(
int end=
'\n');
228 bool skipWhitespace();
229 bool skipWhitespace(
int64 *line_count,
int64 *line_start_pos);
236 UT_ASSERT_MSG(isBufferable(),
"Unbuffered checkToken() not implemented");
238 if (!skipWhitespace())
242 for ( ; *match; ++myBufCur, ++match)
244 if (myBufCur == myBufEnd && !loadBuffer())
246 if (*match != *myBufCur)
250 if (myBufCur == myBufEnd && !loadBuffer())
252 return !myError && SYSisspace(*myBufCur);
260 if (myBufCur != myBufEnd || loadBuffer())
264 return (
int)(
uchar)c;
270 return (
int)(
uchar)data;
274 if (myBufCur != myBufEnd || loadBuffer())
277 return (
int)(
uchar)c;
288 virtual int64 getMemoryUsage(
bool inclusive)
const;
291 {
return myBufferable; }
295 void setError(
const char *msg=0);
304 virtual void loadBuffer(
exint &bufstartpos,
const char *&bufstart,
const char *&bufend,
bool keepeofif0) = 0;
306 virtual exint tellPos()
const = 0;
307 virtual bool seekPos(
exint pos,
int dir) = 0;
311 virtual bool endOfFileSet()
const = 0;
319 bool loadBuffer(
bool keepeofif0 =
false);
325 const char *myBufStart;
326 const char *myBufCur;
327 const char *myBufEnd;
340 "Unbuffered skipWhitespace() not implemented");
343 if (myBufCur == myBufEnd && !
loadBuffer(
true))
347 for ( ; myBufCur < myBufEnd; ++myBufCur)
349 if (!SYSisspace(*myBufCur))
364 "Unbuffered skipLine not implemented");
367 if (myBufCur == myBufEnd && !
loadBuffer(
true))
371 for ( ; myBufCur < myBufEnd; ++myBufCur)
373 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()
void read(T &in, bool &v)
#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.
bool skipLine(int end='\n')
PXR_NAMESPACE_OPEN_SCOPE typedef unsigned char uchar