Back to index

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

#include <Stream.h>

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

List of all members.

Public Member Functions

 RunLengthEncoder (Stream *strA)
virtual ~RunLengthEncoder ()
virtual StreamKind getKind ()
virtual void reset ()
virtual int getChar ()
virtual int lookChar ()
virtual GStringgetPSFilter (int psLevel, char *indent)
virtual GBool isBinary (GBool last=gTrue)
virtual GBool isEncoder ()
virtual void close ()
virtual int getPos ()
virtual void setPos (Guint pos, int dir=0)
virtual BaseStreamgetBaseStream ()
virtual DictgetDict ()
virtual void ignoreLength ()
int incRef ()
int decRef ()
virtual int getRawChar ()
virtual char * getLine (char *buf, int size)
StreamaddFilters (Object *dict)

Protected Attributes

Streamstr

Private Member Functions

GBool fillBuf ()

Private Attributes

char buf [131]
char * bufPtr
char * bufEnd
char * nextEnd
GBool eof

Detailed Description

Definition at line 817 of file Stream.h.


Constructor & Destructor Documentation

Definition at line 3880 of file Stream.cc.

                                              :
    FilterStream(strA) {
  bufPtr = bufEnd = nextEnd = buf;
  eof = gFalse;
}

Definition at line 3886 of file Stream.cc.

                                    {
  if (str->isEncoder())
    delete str;
}

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 FilterStream::close ( ) [virtual, inherited]

Reimplemented from Stream.

Definition at line 306 of file Stream.cc.

                         {
  str->close();
}

Here is the call graph for this function:

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

Definition at line 58 of file Stream.h.

{ return --ref; }

Definition at line 3905 of file Stream.cc.

                                {
  int c, c1, c2;
  int n;

  // already hit EOF?
  if (eof)
    return gFalse;

  // grab two bytes
  if (nextEnd < bufEnd + 1) {
    if ((c1 = str->getChar()) == EOF) {
      eof = gTrue;
      return gFalse;
    }
  } else {
    c1 = bufEnd[0] & 0xff;
  }
  if (nextEnd < bufEnd + 2) {
    if ((c2 = str->getChar()) == EOF) {
      eof = gTrue;
      buf[0] = 0;
      buf[1] = c1;
      bufPtr = buf;
      bufEnd = &buf[2];
      return gTrue;
    }
  } else {
    c2 = bufEnd[1] & 0xff;
  }

  // check for repeat
  c = 0; // make gcc happy
  if (c1 == c2) {
    n = 2;
    while (n < 128 && (c = str->getChar()) == c1)
      ++n;
    buf[0] = (char)(257 - n);
    buf[1] = c1;
    bufEnd = &buf[2];
    if (c == EOF) {
      eof = gTrue;
    } else if (n < 128) {
      buf[2] = c;
      nextEnd = &buf[3];
    } else {
      nextEnd = bufEnd;
    }

  // get up to 128 chars
  } else {
    buf[1] = c1;
    buf[2] = c2;
    n = 2;
    while (n < 128) {
      if ((c = str->getChar()) == EOF) {
       eof = gTrue;
       break;
      }
      ++n;
      buf[n] = c;
      if (buf[n] == buf[n-1])
       break;
    }
    if (buf[n] == buf[n-1]) {
      buf[0] = (char)(n-2-1);
      bufEnd = &buf[n-1];
      nextEnd = &buf[n+1];
    } else {
      buf[0] = (char)(n-1);
      bufEnd = nextEnd = &buf[n+1];
    }
  }
  bufPtr = buf;
  return gTrue;
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Implements Stream.

Definition at line 174 of file Stream.h.

{ return str->getBaseStream(); }

Here is the call graph for this function:

virtual int RunLengthEncoder::getChar ( ) [inline, virtual]

Implements Stream.

Definition at line 824 of file Stream.h.

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

Here is the call graph for this function:

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

Implements Stream.

Definition at line 175 of file Stream.h.

{ return str->getDict(); }

Here is the call graph for this function:

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

Implements Stream.

Definition at line 822 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 FilterStream::getPos ( ) [inline, virtual, inherited]

Implements Stream.

Definition at line 172 of file Stream.h.

{ return str->getPos(); }

Here is the call graph for this function:

virtual GString* RunLengthEncoder::getPSFilter ( int  psLevel,
char *  indent 
) [inline, virtual]

Reimplemented from Stream.

Definition at line 828 of file Stream.h.

{ return NULL; }
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 void FilterStream::ignoreLength ( ) [inline, virtual, inherited]

Reimplemented from Stream.

Definition at line 176 of file Stream.h.

{ str->ignoreLength(); }

Here is the call graph for this function:

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

Definition at line 57 of file Stream.h.

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

Implements Stream.

Definition at line 829 of file Stream.h.

{ return gTrue; }
virtual GBool RunLengthEncoder::isEncoder ( ) [inline, virtual]

Reimplemented from Stream.

Definition at line 830 of file Stream.h.

{ return gTrue; }
virtual int RunLengthEncoder::lookChar ( ) [inline, virtual]

Implements Stream.

Definition at line 826 of file Stream.h.

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

Here is the call graph for this function:

Implements Stream.

Definition at line 3891 of file Stream.cc.

                             {
  str->reset();
  bufPtr = bufEnd = nextEnd = buf;
  eof = gFalse;
}

Here is the call graph for this function:

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

Implements Stream.

Definition at line 310 of file Stream.cc.

                                            {
  error(-1, "Internal: called setPos() on FilterStream");
}

Here is the call graph for this function:


Member Data Documentation

char RunLengthEncoder::buf[131] [private]

Definition at line 834 of file Stream.h.

char* RunLengthEncoder::bufEnd [private]

Definition at line 836 of file Stream.h.

char* RunLengthEncoder::bufPtr [private]

Definition at line 835 of file Stream.h.

Definition at line 838 of file Stream.h.

char* RunLengthEncoder::nextEnd [private]

Definition at line 837 of file Stream.h.

Stream* FilterStream::str [protected, inherited]

Definition at line 180 of file Stream.h.


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