Back to index

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

#include <Stream.h>

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

List of all members.

Public Member Functions

 MemStream (char *bufA, Guint startA, Guint lengthA, Object *dictA)
virtual ~MemStream ()
virtual StreammakeSubStream (Guint start, GBool limited, 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 Guint getStart ()
virtual void moveStart (int delta)
virtual void doDecryption (Guchar *fileKey, int keyLength, int objNum, int objGen)
virtual GBool isBinary (GBool last=gTrue)
virtual BaseStreamgetBaseStream ()
virtual DictgetDict ()
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)
virtual void ignoreLength ()

Protected Attributes

Decryptdecrypt

Private Attributes

char * buf
Guint start
Guint length
char * bufEnd
char * bufPtr
GBool needFree

Detailed Description

Definition at line 302 of file Stream.h.


Constructor & Destructor Documentation

MemStream::MemStream ( char *  bufA,
Guint  startA,
Guint  lengthA,
Object dictA 
)

Definition at line 702 of file Stream.cc.

                                                                          :
    BaseStream(dictA) {
  buf = bufA;
  start = startA;
  length = lengthA;
  bufEnd = buf + start + length;
  bufPtr = buf + start;
  needFree = gFalse;
}

Here is the caller graph for this function:

MemStream::~MemStream ( ) [virtual]

Definition at line 712 of file Stream.cc.

                      {
  if (needFree) {
    gfree(buf);
  }
}

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 MemStream::close ( ) [virtual]

Reimplemented from Stream.

Definition at line 741 of file Stream.cc.

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

Definition at line 58 of file Stream.h.

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

Reimplemented from BaseStream.

Definition at line 766 of file Stream.cc.

                                                  {
  char *newBuf;
  char *p, *q;

  this->BaseStream::doDecryption(fileKey, keyLength, objNum, objGen);
  if (decrypt) {
    newBuf = (char *)gmalloc(length);
    for (p = buf + start, q = newBuf; p < bufEnd; ++p, ++q) {
      *q = (char)decrypt->decryptByte((Guchar)*p);
    }
    bufEnd = newBuf + length;
    bufPtr = newBuf + (bufPtr - (buf + start));
    start = 0;
    buf = newBuf;
    needFree = gTrue;
  }
}

Here is the call 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 MemStream::getChar ( ) [inline, virtual]

Implements Stream.

Definition at line 312 of file Stream.h.

    { return (bufPtr < bufEnd) ? (*bufPtr++ & 0xff) : EOF; }
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 MemStream::getKind ( ) [inline, virtual]

Implements Stream.

Definition at line 309 of file Stream.h.

{ return strWeird; }
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 MemStream::getPos ( ) [inline, virtual]

Implements Stream.

Definition at line 316 of file Stream.h.

{ return (int)(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 MemStream::getStart ( ) [inline, virtual]

Implements BaseStream.

Definition at line 318 of file Stream.h.

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

Reimplemented in FileStream, and FilterStream.

Definition at line 112 of file Stream.h.

{}

Here is the caller graph for this function:

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 MemStream::lookChar ( ) [inline, virtual]

Implements Stream.

Definition at line 314 of file Stream.h.

    { return (bufPtr < bufEnd) ? (*bufPtr & 0xff) : EOF; }
Stream * MemStream::makeSubStream ( Guint  start,
GBool  limited,
Guint  lengthA,
Object dictA 
) [virtual]

Implements BaseStream.

Definition at line 718 of file Stream.cc.

                                                           {
  MemStream *subStr;
  Guint newLength;

  if (!limited || startA + lengthA > start + length) {
    newLength = start + length - startA;
  } else {
    newLength = lengthA;
  }
  subStr = new MemStream(buf, startA, newLength, dictA);
  return subStr;
}

Here is the call graph for this function:

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

Implements BaseStream.

Definition at line 760 of file Stream.cc.

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

Implements Stream.

Definition at line 732 of file Stream.cc.

                      {
  bufPtr = buf + start;
#ifndef NO_DECRYPTION
  if (decrypt) {
    decrypt->reset();
  }
#endif
}

Here is the call graph for this function:

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

Implements BaseStream.

Definition at line 744 of file Stream.cc.

                                         {
  Guint i;

  if (dir >= 0) {
    i = pos;
  } else {
    i = start + length - pos;
  }
  if (i < start) {
    i = start;
  } else if (i > start + length) {
    i = start + length;
  }
  bufPtr = buf + i;
}

Member Data Documentation

char* MemStream::buf [private]

Definition at line 327 of file Stream.h.

char* MemStream::bufEnd [private]

Definition at line 330 of file Stream.h.

char* MemStream::bufPtr [private]

Definition at line 331 of file Stream.h.

Decrypt* BaseStream::decrypt [protected, inherited]

Definition at line 152 of file Stream.h.

Definition at line 329 of file Stream.h.

Definition at line 332 of file Stream.h.

Definition at line 328 of file Stream.h.


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