Back to index

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

#include <Object.h>

List of all members.

Public Member Functions

 Object ()
ObjectinitBool (GBool boolnA)
ObjectinitInt (int intgA)
ObjectinitReal (double realA)
ObjectinitString (GString *stringA)
ObjectinitName (char *nameA)
ObjectinitNull ()
ObjectinitArray (XRef *xref)
ObjectinitDict (XRef *xref)
ObjectinitDict (Dict *dictA)
ObjectinitStream (Stream *streamA)
ObjectinitRef (int numA, int genA)
ObjectinitCmd (char *cmdA)
ObjectinitError ()
ObjectinitEOF ()
Objectcopy (Object *obj)
Objectfetch (XRef *xref, Object *obj)
void free ()
ObjType getType ()
GBool isBool ()
GBool isInt ()
GBool isReal ()
GBool isNum ()
GBool isString ()
GBool isName ()
GBool isNull ()
GBool isArray ()
GBool isDict ()
GBool isStream ()
GBool isRef ()
GBool isCmd ()
GBool isError ()
GBool isEOF ()
GBool isNone ()
GBool isName (char *nameA)
GBool isDict (char *dictType)
GBool isStream (char *dictType)
GBool isCmd (char *cmdA)
GBool getBool ()
int getInt ()
double getReal ()
double getNum ()
GStringgetString ()
char * getName ()
ArraygetArray ()
DictgetDict ()
StreamgetStream ()
Ref getRef ()
int getRefNum ()
int getRefGen ()
char * getCmd ()
int arrayGetLength ()
void arrayAdd (Object *elem)
ObjectarrayGet (int i, Object *obj)
ObjectarrayGetNF (int i, Object *obj)
int dictGetLength ()
void dictAdd (char *key, Object *val)
GBool dictIs (char *dictType)
ObjectdictLookup (char *key, Object *obj)
ObjectdictLookupNF (char *key, Object *obj)
char * dictGetKey (int i)
ObjectdictGetVal (int i, Object *obj)
ObjectdictGetValNF (int i, Object *obj)
GBool streamIs (char *dictType)
void streamReset ()
void streamClose ()
int streamGetChar ()
int streamLookChar ()
char * streamGetLine (char *buf, int size)
Guint streamGetPos ()
void streamSetPos (Guint pos, int dir=0)
DictstreamGetDict ()
char * getTypeName ()
void print (FILE *f=stdout)

Static Public Member Functions

static void memCheck (FILE *f)

Private Attributes

ObjType type
union {
GBool booln
int intg
double real
GStringstring
char * name
Arrayarray
Dictdict
Streamstream
Ref ref
char * cmd
}; 

Detailed Description

Definition at line 76 of file Object.h.


Constructor & Destructor Documentation

Object::Object ( ) [inline]

Definition at line 80 of file Object.h.

          :
    type(objNone) {}

Member Function Documentation

void Object::arrayAdd ( Object elem) [inline]

Definition at line 225 of file Object.h.

  { array->add(elem); }

Here is the caller graph for this function:

Object * Object::arrayGet ( int  i,
Object obj 
) [inline]

Definition at line 228 of file Object.h.

  { return array->get(i, obj); }

Here is the caller graph for this function:

Definition at line 222 of file Object.h.

  { return array->getLength(); }

Here is the caller graph for this function:

Object * Object::arrayGetNF ( int  i,
Object obj 
) [inline]

Definition at line 231 of file Object.h.

  { return array->getNF(i, obj); }

Here is the caller graph for this function:

Object * Object::copy ( Object obj)

Definition at line 74 of file Object.cc.

                                {
  *obj = *this;
  switch (type) {
  case objString:
    obj->string = string->copy();
    break;
  case objName:
    obj->name = copyString(name);
    break;
  case objArray:
    array->incRef();
    break;
  case objDict:
    dict->incRef();
    break;
  case objStream:
    stream->incRef();
    break;
  case objCmd:
    obj->cmd = copyString(cmd);
    break;
  default:
    break;
  }
#ifdef DEBUG_MEM
  ++numAlloc[type];
#endif
  return obj;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Object::dictAdd ( char *  key,
Object val 
) [inline]

Definition at line 243 of file Object.h.

  { dict->add(key, val); }

Here is the caller graph for this function:

char * Object::dictGetKey ( int  i) [inline]

Definition at line 258 of file Object.h.

  { return dict->getKey(i); }

Here is the caller graph for this function:

int Object::dictGetLength ( ) [inline]

Definition at line 240 of file Object.h.

  { return dict->getLength(); }

Here is the caller graph for this function:

Object * Object::dictGetVal ( int  i,
Object obj 
) [inline]

Definition at line 261 of file Object.h.

  { return dict->getVal(i, obj); }

Here is the caller graph for this function:

Object * Object::dictGetValNF ( int  i,
Object obj 
) [inline]

Definition at line 264 of file Object.h.

  { return dict->getValNF(i, obj); }

Here is the caller graph for this function:

GBool Object::dictIs ( char *  dictType) [inline]

Definition at line 246 of file Object.h.

  { return dict->is(dictType); }

Here is the caller graph for this function:

Object * Object::dictLookup ( char *  key,
Object obj 
) [inline]

Definition at line 252 of file Object.h.

  { return dict->lookup(key, obj); }

Here is the caller graph for this function:

Object * Object::dictLookupNF ( char *  key,
Object obj 
) [inline]

Definition at line 255 of file Object.h.

  { return dict->lookupNF(key, obj); }

Here is the caller graph for this function:

Object * Object::fetch ( XRef xref,
Object obj 
)

Definition at line 104 of file Object.cc.

                                             {
  return (type == objRef && xref) ?
         xref->fetch(ref.num, ref.gen, obj) : copy(obj);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 109 of file Object.cc.

                  {
  switch (type) {
  case objString:
    delete string;
    break;
  case objName:
    gfree(name);
    break;
  case objArray:
    if (!array->decRef()) {
      delete array;
    }
    break;
  case objDict:
    if (!dict->decRef()) {
      delete dict;
    }
    break;
  case objStream:
    if (!stream->decRef()) {
      delete stream;
    }
    break;
  case objCmd:
    gfree(cmd);
    break;
  default:
    break;
  }
#ifdef DEBUG_MEM
  --numAlloc[type];
#endif
  type = objNone;
}

Here is the call graph for this function:

Array* Object::getArray ( ) [inline]

Definition at line 152 of file Object.h.

{ return array; }

Here is the caller graph for this function:

GBool Object::getBool ( ) [inline]

Definition at line 146 of file Object.h.

{ return booln; }

Here is the caller graph for this function:

char* Object::getCmd ( ) [inline]

Definition at line 158 of file Object.h.

{ return cmd; }

Here is the caller graph for this function:

Dict* Object::getDict ( ) [inline]

Definition at line 153 of file Object.h.

{ return dict; }

Here is the caller graph for this function:

int Object::getInt ( ) [inline]

Definition at line 147 of file Object.h.

{ return intg; }

Here is the caller graph for this function:

char* Object::getName ( ) [inline]

Definition at line 151 of file Object.h.

{ return name; }

Here is the caller graph for this function:

double Object::getNum ( ) [inline]

Definition at line 149 of file Object.h.

{ return type == objInt ? (double)intg : real; }
double Object::getReal ( ) [inline]

Definition at line 148 of file Object.h.

{ return real; }

Here is the caller graph for this function:

Ref Object::getRef ( ) [inline]

Definition at line 155 of file Object.h.

{ return ref; }

Here is the caller graph for this function:

int Object::getRefGen ( ) [inline]

Definition at line 157 of file Object.h.

{ return ref.gen; }

Here is the caller graph for this function:

int Object::getRefNum ( ) [inline]

Definition at line 156 of file Object.h.

{ return ref.num; }

Here is the caller graph for this function:

Stream* Object::getStream ( ) [inline]

Definition at line 154 of file Object.h.

{ return stream; }

Here is the caller graph for this function:

GString* Object::getString ( ) [inline]

Definition at line 150 of file Object.h.

{ return string; }

Here is the caller graph for this function:

ObjType Object::getType ( ) [inline]

Definition at line 120 of file Object.h.

{ return type; }
char * Object::getTypeName ( )

Definition at line 144 of file Object.cc.

                          {
  return objTypeNames[type];
}

Here is the caller graph for this function:

Object * Object::initArray ( XRef xref)

Definition at line 49 of file Object.cc.

                                    {
  initObj(objArray);
  array = new Array(xref);
  return this;
}

Here is the caller graph for this function:

Object* Object::initBool ( GBool  boolnA) [inline]

Definition at line 84 of file Object.h.

    { initObj(objBool); booln = boolnA; return this; }

Here is the caller graph for this function:

Object* Object::initCmd ( char *  cmdA) [inline]

Definition at line 102 of file Object.h.

    { initObj(objCmd); cmd = copyString(cmdA); return this; }

Here is the call graph for this function:

Here is the caller graph for this function:

Object * Object::initDict ( XRef xref)

Definition at line 55 of file Object.cc.

                                   {
  initObj(objDict);
  dict = new Dict(xref);
  return this;
}

Here is the caller graph for this function:

Object * Object::initDict ( Dict dictA)

Definition at line 61 of file Object.cc.

                                    {
  initObj(objDict);
  dict = dictA;
  dict->incRef();
  return this;
}

Here is the call graph for this function:

Object* Object::initEOF ( ) [inline]

Definition at line 106 of file Object.h.

    { initObj(objEOF); return this; }

Here is the caller graph for this function:

Object* Object::initError ( ) [inline]

Definition at line 104 of file Object.h.

    { initObj(objError); return this; }

Here is the caller graph for this function:

Object* Object::initInt ( int  intgA) [inline]

Definition at line 86 of file Object.h.

    { initObj(objInt); intg = intgA; return this; }

Here is the caller graph for this function:

Object* Object::initName ( char *  nameA) [inline]

Definition at line 92 of file Object.h.

    { initObj(objName); name = copyString(nameA); return this; }

Here is the call graph for this function:

Here is the caller graph for this function:

Object* Object::initNull ( ) [inline]

Definition at line 94 of file Object.h.

    { initObj(objNull); return this; }

Here is the caller graph for this function:

Object* Object::initReal ( double  realA) [inline]

Definition at line 88 of file Object.h.

    { initObj(objReal); real = realA; return this; }

Here is the caller graph for this function:

Object* Object::initRef ( int  numA,
int  genA 
) [inline]

Definition at line 100 of file Object.h.

    { initObj(objRef); ref.num = numA; ref.gen = genA; return this; }

Here is the caller graph for this function:

Object * Object::initStream ( Stream streamA)

Definition at line 68 of file Object.cc.

                                          {
  initObj(objStream);
  stream = streamA;
  return this;
}

Here is the caller graph for this function:

Object* Object::initString ( GString stringA) [inline]

Definition at line 90 of file Object.h.

    { initObj(objString); string = stringA; return this; }

Here is the caller graph for this function:

GBool Object::isArray ( ) [inline]

Definition at line 128 of file Object.h.

{ return type == objArray; }
GBool Object::isBool ( ) [inline]

Definition at line 121 of file Object.h.

{ return type == objBool; }

Here is the caller graph for this function:

GBool Object::isCmd ( ) [inline]

Definition at line 132 of file Object.h.

{ return type == objCmd; }

Here is the caller graph for this function:

GBool Object::isCmd ( char *  cmdA) [inline]

Definition at line 142 of file Object.h.

    { return type == objCmd && !strcmp(cmd, cmdA); }

Here is the call graph for this function:

GBool Object::isDict ( ) [inline]

Definition at line 129 of file Object.h.

{ return type == objDict; }
GBool Object::isDict ( char *  dictType) [inline]

Definition at line 249 of file Object.h.

  { return type == objDict && dictIs(dictType); }

Here is the call graph for this function:

GBool Object::isEOF ( ) [inline]

Definition at line 134 of file Object.h.

{ return type == objEOF; }

Here is the caller graph for this function:

GBool Object::isError ( ) [inline]

Definition at line 133 of file Object.h.

{ return type == objError; }

Here is the caller graph for this function:

GBool Object::isInt ( ) [inline]

Definition at line 122 of file Object.h.

{ return type == objInt; }

Here is the caller graph for this function:

GBool Object::isName ( ) [inline]

Definition at line 126 of file Object.h.

{ return type == objName; }

Here is the caller graph for this function:

GBool Object::isName ( char *  nameA) [inline]

Definition at line 138 of file Object.h.

    { return type == objName && !strcmp(name, nameA); }

Here is the call graph for this function:

GBool Object::isNone ( ) [inline]

Definition at line 135 of file Object.h.

{ return type == objNone; }

Here is the caller graph for this function:

GBool Object::isNull ( ) [inline]

Definition at line 127 of file Object.h.

{ return type == objNull; }

Here is the caller graph for this function:

GBool Object::isNum ( ) [inline]

Definition at line 124 of file Object.h.

{ return type == objInt || type == objReal; }

Here is the caller graph for this function:

GBool Object::isReal ( ) [inline]

Definition at line 123 of file Object.h.

{ return type == objReal; }

Here is the caller graph for this function:

GBool Object::isRef ( ) [inline]

Definition at line 131 of file Object.h.

{ return type == objRef; }

Here is the caller graph for this function:

GBool Object::isStream ( ) [inline]

Definition at line 130 of file Object.h.

{ return type == objStream; }

Here is the caller graph for this function:

GBool Object::isStream ( char *  dictType) [inline]

Definition at line 276 of file Object.h.

  { return type == objStream && streamIs(dictType); }

Here is the call graph for this function:

GBool Object::isString ( ) [inline]

Definition at line 125 of file Object.h.

{ return type == objString; }

Here is the caller graph for this function:

void Object::memCheck ( FILE f) [static]

Definition at line 215 of file Object.cc.

                             {
#ifdef DEBUG_MEM
  int i;
  int t;

  t = 0;
  for (i = 0; i < numObjTypes; ++i)
    t += numAlloc[i];
  if (t > 0) {
    fprintf(f, "Allocated objects:\n");
    for (i = 0; i < numObjTypes; ++i) {
      if (numAlloc[i] > 0)
       fprintf(f, "  %-20s: %6d\n", objTypeNames[i], numAlloc[i]);
    }
  }
#endif
}

Here is the call graph for this function:

void Object::print ( FILE f = stdout)

Definition at line 148 of file Object.cc.

                          {
  Object obj;
  int i;

  switch (type) {
  case objBool:
    fprintf(f, "%s", booln ? "true" : "false");
    break;
  case objInt:
    fprintf(f, "%d", intg);
    break;
  case objReal:
    fprintf(f, "%g", real);
    break;
  case objString:
    fprintf(f, "(");
    fwrite(string->getCString(), 1, string->getLength(), stdout);
    fprintf(f, ")");
    break;
  case objName:
    fprintf(f, "/%s", name);
    break;
  case objNull:
    fprintf(f, "null");
    break;
  case objArray:
    fprintf(f, "[");
    for (i = 0; i < arrayGetLength(); ++i) {
      if (i > 0)
       fprintf(f, " ");
      arrayGetNF(i, &obj);
      obj.print(f);
      obj.free();
    }
    fprintf(f, "]");
    break;
  case objDict:
    fprintf(f, "<<");
    for (i = 0; i < dictGetLength(); ++i) {
      fprintf(f, " /%s ", dictGetKey(i));
      dictGetValNF(i, &obj);
      obj.print(f);
      obj.free();
    }
    fprintf(f, " >>");
    break;
  case objStream:
    fprintf(f, "<stream>");
    break;
  case objRef:
    fprintf(f, "%d %d R", ref.num, ref.gen);
    break;
  case objCmd:
    fprintf(f, "%s", cmd);
    break;
  case objError:
    fprintf(f, "<error>");
    break;
  case objEOF:
    fprintf(f, "<EOF>");
    break;
  case objNone:
    fprintf(f, "<none>");
    break;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Object::streamClose ( ) [inline]

Definition at line 282 of file Object.h.

  { stream->close(); }

Here is the caller graph for this function:

int Object::streamGetChar ( ) [inline]

Definition at line 285 of file Object.h.

  { return stream->getChar(); }

Here is the caller graph for this function:

Dict * Object::streamGetDict ( ) [inline]

Definition at line 300 of file Object.h.

  { return stream->getDict(); }

Here is the caller graph for this function:

char * Object::streamGetLine ( char *  buf,
int  size 
) [inline]

Definition at line 291 of file Object.h.

  { return stream->getLine(buf, size); }

Definition at line 294 of file Object.h.

  { return stream->getPos(); }

Here is the caller graph for this function:

GBool Object::streamIs ( char *  dictType) [inline]

Definition at line 273 of file Object.h.

  { return stream->getDict()->is(dictType); }

Here is the caller graph for this function:

Definition at line 288 of file Object.h.

  { return stream->lookChar(); }

Here is the caller graph for this function:

void Object::streamReset ( ) [inline]

Definition at line 279 of file Object.h.

  { stream->reset(); }

Here is the caller graph for this function:

void Object::streamSetPos ( Guint  pos,
int  dir = 0 
) [inline]

Definition at line 297 of file Object.h.

  { stream->setPos(pos, dir); }

Here is the caller graph for this function:


Member Data Documentation

union { ... } [private]
ObjType Object::type [private]

Definition at line 196 of file Object.h.


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