Back to index

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

#include <PSTokenizer.h>

List of all members.

Public Member Functions

 PSTokenizer (int(*getCharFuncA)(void *), void *dataA)
 ~PSTokenizer ()
GBool getToken (char *buf, int size, int *length)

Private Member Functions

int lookChar ()
int getChar ()

Private Attributes

int(* getCharFunc )(void *)
voiddata
int charBuf

Detailed Description

Definition at line 22 of file PSTokenizer.h.


Constructor & Destructor Documentation

PSTokenizer::PSTokenizer ( int(*)(void *)  getCharFuncA,
void dataA 
)

Definition at line 44 of file PSTokenizer.cc.

                                                                 {
  getCharFunc = getCharFuncA;
  data = dataA;
  charBuf = -1;
}

Definition at line 50 of file PSTokenizer.cc.

                          {
}

Member Function Documentation

int PSTokenizer::getChar ( ) [private]

Definition at line 126 of file PSTokenizer.cc.

                         {
  int c;

  if (charBuf < 0) {
    charBuf = (*getCharFunc)(data);
  }
  c = charBuf;
  charBuf = -1;
  return c;
}

Here is the caller graph for this function:

GBool PSTokenizer::getToken ( char *  buf,
int  size,
int length 
)

Definition at line 53 of file PSTokenizer.cc.

                                                            {
  GBool comment, backslash;
  int c;
  int i;

  // skip whitespace and comments
  comment = gFalse;
  while (1) {
    if ((c = getChar()) == EOF) {
      buf[0] = '\0';
      *length = 0;
      return gFalse;
    }
    if (comment) {
      if (c == '\x0a' || c == '\x0d') {
       comment = gFalse;
      }
    } else if (c == '%') {
      comment = gTrue;
    } else if (specialChars[c] != 1) {
      break;
    }
  }

  // read a token
  i = 0;
  buf[i++] = c;
  if (c == '(') {
    backslash = gFalse;
    while ((c = lookChar()) != EOF) {
      if (i < size - 1) {
       buf[i++] = c;
      }
      getChar();
      if (c == '\\') {
       backslash = gTrue;
      } else if (!backslash && c == ')') {
       break;
      } else {
       backslash = gFalse;
      }
    }
  } else if (c == '<') {
    while ((c = lookChar()) != EOF) {
      getChar();
      if (i < size - 1) {
       buf[i++] = c;
      }
      if (c == '>') {
       break;
      }
    }
  } else if (c != '[' && c != ']') {
    while ((c = lookChar()) != EOF && !specialChars[c]) {
      getChar();
      if (i < size - 1) {
       buf[i++] = c;
      }
    }
  }
  buf[i] = '\0';
  *length = i;

  return gTrue;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int PSTokenizer::lookChar ( ) [private]

Definition at line 119 of file PSTokenizer.cc.

                          {
  if (charBuf < 0) {
    charBuf = (*getCharFunc)(data);
  }
  return charBuf;
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 38 of file PSTokenizer.h.

void* PSTokenizer::data [private]

Definition at line 37 of file PSTokenizer.h.

Definition at line 36 of file PSTokenizer.h.


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