Back to index

tetex-bin  3.0
Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes
FileStream Class Reference

#include <Stream.h>

Inheritance diagram for FileStream:
Inheritance graph
[legend]
Collaboration diagram for FileStream:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 FileStream (FILE *fA, Guint startA, GBool limitedA, Guint lengthA, Object *dictA)
virtual ~FileStream ()
virtual StreammakeSubStream (Guint startA, GBool limitedA, Guint lengthA, Object *dictA)
virtual StreamKind getKind ()
virtual void reset ()
virtual void close ()
virtual int getChar ()
virtual int lookChar ()
virtual int getPos ()
virtual void setPos (Guint pos, int dir=0)
virtual void ignoreLength ()
virtual Guint getStart ()
virtual void moveStart (int delta)
virtual GBool isBinary (GBool last=gTrue)
virtual BaseStreamgetBaseStream ()
virtual DictgetDict ()
virtual void doDecryption (Guchar *fileKey, int keyLength, int objNum, int objGen)
int incRef ()
int decRef ()
virtual int getRawChar ()
virtual char * getLine (char *buf, int size)
virtual GStringgetPSFilter (int psLevel, char *indent)
virtual GBool isEncoder ()
StreamaddFilters (Object *dict)

Protected Attributes

Decryptdecrypt

Private Member Functions

GBool fillBuf ()

Private Attributes

FILEf
Guint start
GBool limited
Guint length
char buf [fileStreamBufSize]
char * bufPtr
char * bufEnd
Guint bufPos
int savePos
GBool saved

Detailed Description

Definition at line 261 of file Stream.h.


Constructor & Destructor Documentation

FileStream::FileStream ( FILE fA,
Guint  startA,
GBool  limitedA,
Guint  lengthA,
Object dictA 
)

Definition at line 563 of file Stream.cc.

                                                  :
    BaseStream(dictA) {
  f = fA;
  start = startA;
  limited = limitedA;
  length = lengthA;
  bufPtr = bufEnd = buf;
  bufPos = start;
  savePos = 0;
  saved = gFalse;
}

Here is the caller graph for this function:

FileStream::~FileStream ( ) [virtual]

Definition at line 576 of file Stream.cc.

                        {
  close();
}

Here is the call graph for this function:


Member Function Documentation

Stream * Stream::addFilters ( Object dict) [inherited]

Definition at line 92 of file Stream.cc.

                                       {
  Object obj, obj2;
  Object params, params2;
  Stream *str;
  int i;

  str = this;
  dict->dictLookup("Filter", &obj);
  if (obj.isNull()) {
    obj.free();
    dict->dictLookup("F", &obj);
  }
  dict->dictLookup("DecodeParms", &params);
  if (params.isNull()) {
    params.free();
    dict->dictLookup("DP", &params);
  }
  if (obj.isName()) {
    str = makeFilter(obj.getName(), str, &params);
  } else if (obj.isArray()) {
    for (i = 0; i < obj.arrayGetLength(); ++i) {
      obj.arrayGet(i, &obj2);
      if (params.isArray())
       params.arrayGet(i, &params2);
      else
       params2.initNull();
      if (obj2.isName()) {
       str = makeFilter(obj2.getName(), str, &params2);
      } else {
       error(getPos(), "Bad filter name");
       str = new EOFStream(str);
      }
      obj2.free();
      params2.free();
    }
  } else if (!obj.isNull()) {
    error(getPos(), "Bad 'Filter' attribute in stream");
  }
  obj.free();
  params.free();

  return str;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void FileStream::close ( ) [virtual]

Reimplemented from Stream.

Definition at line 605 of file Stream.cc.

                       {
  if (saved) {
#if HAVE_FSEEKO
    fseeko(f, savePos, SEEK_SET);
#elif HAVE_FSEEK64
    fseek64(f, savePos, SEEK_SET);
#else
    fseek(f, savePos, SEEK_SET);
#endif
    saved = gFalse;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int Stream::decRef ( ) [inline, inherited]

Definition at line 58 of file Stream.h.

{ return --ref; }
void BaseStream::doDecryption ( Guchar fileKey,
int  keyLength,
int  objNum,
int  objGen 
) [virtual, inherited]

Reimplemented in MemStream.

Definition at line 289 of file Stream.cc.

                                                   {
  decrypt = new Decrypt(fileKey, keyLength, objNum, objGen);
}

Here is the caller graph for this function:

GBool FileStream::fillBuf ( ) [private]

Definition at line 618 of file Stream.cc.

                          {
  int n;
#ifndef NO_DECRYPTION
  char *p;
#endif

  bufPos += bufEnd - buf;
  bufPtr = bufEnd = buf;
  if (limited && bufPos >= start + length) {
    return gFalse;
  }
  if (limited && bufPos + fileStreamBufSize > start + length) {
    n = start + length - bufPos;
  } else {
    n = fileStreamBufSize;
  }
  n = fread(buf, 1, n, f);
  bufEnd = buf + n;
  if (bufPtr >= bufEnd) {
    return gFalse;
  }
#ifndef NO_DECRYPTION
  if (decrypt) {
    for (p = buf; p < bufEnd; ++p) {
      *p = (char)decrypt->decryptByte((Guchar)*p);
    }
  }
#endif
  return gTrue;
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual BaseStream* BaseStream::getBaseStream ( ) [inline, virtual, inherited]

Implements Stream.

Definition at line 136 of file Stream.h.

{ return this; }
virtual int FileStream::getChar ( ) [inline, virtual]

Implements Stream.

Definition at line 272 of file Stream.h.

    { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr++ & 0xff); }

Here is the call graph for this function:

virtual Dict* BaseStream::getDict ( ) [inline, virtual, inherited]

Implements Stream.

Definition at line 137 of file Stream.h.

{ return dict.getDict(); }

Here is the call graph for this function:

virtual StreamKind FileStream::getKind ( ) [inline, virtual]

Implements Stream.

Definition at line 269 of file Stream.h.

{ return strFile; }
char * Stream::getLine ( char *  buf,
int  size 
) [virtual, inherited]

Definition at line 67 of file Stream.cc.

                                         {
  int i;
  int c;

  if (lookChar() == EOF)
    return NULL;
  for (i = 0; i < size - 1; ++i) {
    c = getChar();
    if (c == EOF || c == '\n')
      break;
    if (c == '\r') {
      if ((c = lookChar()) == '\n')
       getChar();
      break;
    }
    buf[i] = c;
  }
  buf[i] = '\0';
  return buf;
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual int FileStream::getPos ( ) [inline, virtual]

Implements Stream.

Definition at line 276 of file Stream.h.

{ return bufPos + (bufPtr - buf); }
GString * Stream::getPSFilter ( int  psLevel,
char *  indent 
) [virtual, inherited]

Reimplemented in RunLengthEncoder, ASCII85Encoder, ASCIIHexEncoder, FixedLengthEncoder, EOFStream, FlateStream, DCTStream, CCITTFaxStream, RunLengthStream, LZWStream, ASCII85Stream, ASCIIHexStream, JPXStream, and JBIG2Stream.

Definition at line 88 of file Stream.cc.

                                                      {
  return new GString();
}

Here is the caller graph for this function:

int Stream::getRawChar ( ) [virtual, inherited]

Reimplemented in FlateStream, and LZWStream.

Definition at line 62 of file Stream.cc.

                       {
  error(-1, "Internal: called getRawChar() on non-predictor stream");
  return EOF;
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual Guint FileStream::getStart ( ) [inline, virtual]

Implements BaseStream.

Definition at line 279 of file Stream.h.

{ return start; }
virtual void FileStream::ignoreLength ( ) [inline, virtual]

Reimplemented from Stream.

Definition at line 278 of file Stream.h.

{ limited = gFalse; }
int Stream::incRef ( ) [inline, inherited]

Definition at line 57 of file Stream.h.

{ return ++ref; }
virtual GBool BaseStream::isBinary ( GBool  last = gTrue) [inline, virtual, inherited]

Implements Stream.

Definition at line 135 of file Stream.h.

{ return last; }
virtual GBool Stream::isEncoder ( ) [inline, virtual, inherited]

Reimplemented in RunLengthEncoder, ASCII85Encoder, ASCIIHexEncoder, and FixedLengthEncoder.

Definition at line 103 of file Stream.h.

{ return gFalse; }

Here is the caller graph for this function:

virtual int FileStream::lookChar ( ) [inline, virtual]

Implements Stream.

Definition at line 274 of file Stream.h.

    { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); }

Here is the call graph for this function:

Stream * FileStream::makeSubStream ( Guint  startA,
GBool  limitedA,
Guint  lengthA,
Object dictA 
) [virtual]

Implements BaseStream.

Definition at line 580 of file Stream.cc.

                                                            {
  return new FileStream(f, startA, limitedA, lengthA, dictA);
}

Here is the call graph for this function:

void FileStream::moveStart ( int  delta) [virtual]

Implements BaseStream.

Definition at line 692 of file Stream.cc.

                                    {
  start += delta;
  bufPtr = bufEnd = buf;
  bufPos = start;
}
void FileStream::reset ( ) [virtual]

Implements Stream.

Definition at line 585 of file Stream.cc.

                       {
#if HAVE_FSEEKO
  savePos = (Guint)ftello(f);
  fseeko(f, start, SEEK_SET);
#elif HAVE_FSEEK64
  savePos = (Guint)ftell64(f);
  fseek64(f, start, SEEK_SET);
#else
  savePos = (Guint)ftell(f);
  fseek(f, start, SEEK_SET);
#endif
  saved = gTrue;
  bufPtr = bufEnd = buf;
  bufPos = start;
#ifndef NO_DECRYPTION
  if (decrypt)
    decrypt->reset();
#endif
}

Here is the call graph for this function:

void FileStream::setPos ( Guint  pos,
int  dir = 0 
) [virtual]

Implements BaseStream.

Definition at line 649 of file Stream.cc.

                                          {
  Guint size;

  if (dir >= 0) {
#if HAVE_FSEEKO
    fseeko(f, pos, SEEK_SET);
#elif HAVE_FSEEK64
    fseek64(f, pos, SEEK_SET);
#else
    fseek(f, pos, SEEK_SET);
#endif
    bufPos = pos;
  } else {
#if HAVE_FSEEKO
    fseeko(f, 0, SEEK_END);
    size = (Guint)ftello(f);
#elif HAVE_FSEEK64
    fseek64(f, 0, SEEK_END);
    size = (Guint)ftell64(f);
#else
    fseek(f, 0, SEEK_END);
    size = (Guint)ftell(f);
#endif
    if (pos > size)
      pos = (Guint)size;
#ifdef __CYGWIN32__
    //~ work around a bug in cygwin's implementation of fseek
    rewind(f);
#endif
#if HAVE_FSEEKO
    fseeko(f, -(int)pos, SEEK_END);
    bufPos = (Guint)ftello(f);
#elif HAVE_FSEEK64
    fseek64(f, -(int)pos, SEEK_END);
    bufPos = (Guint)ftell64(f);
#else
    fseek(f, -(int)pos, SEEK_END);
    bufPos = (Guint)ftell(f);
#endif
  }
  bufPtr = bufEnd = buf;
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 290 of file Stream.h.

char* FileStream::bufEnd [private]

Definition at line 292 of file Stream.h.

Definition at line 293 of file Stream.h.

char* FileStream::bufPtr [private]

Definition at line 291 of file Stream.h.

Decrypt* BaseStream::decrypt [protected, inherited]

Definition at line 152 of file Stream.h.

FILE* FileStream::f [private]

Definition at line 286 of file Stream.h.

Definition at line 289 of file Stream.h.

Definition at line 288 of file Stream.h.

Definition at line 295 of file Stream.h.

Definition at line 294 of file Stream.h.

Definition at line 287 of file Stream.h.


The documentation for this class was generated from the following files: