Back to index

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

#include <GString.h>

List of all members.

Public Member Functions

 GString ()
 GString (const char *sA)
 GString (const char *sA, int lengthA)
 GString (GString *str, int idx, int lengthA)
 GString (GString *str)
GStringcopy ()
 GString (GString *str1, GString *str2)
 ~GString ()
int getLength ()
char * getCString ()
char getChar (int i)
void setChar (int i, char c)
GStringclear ()
GStringappend (char c)
GStringappend (GString *str)
GStringappend (const char *str)
GStringappend (const char *str, int lengthA)
GStringinsert (int i, char c)
GStringinsert (int i, GString *str)
GStringinsert (int i, const char *str)
GStringinsert (int i, const char *str, int lengthA)
GStringdel (int i, int n=1)
GStringupperCase ()
GStringlowerCase ()
int cmp (GString *str)
int cmpN (GString *str, int n)
int cmp (const char *sA)
int cmpN (const char *sA, int n)

Static Public Member Functions

static GStringfromInt (int x)

Private Member Functions

void resize (int length1)

Private Attributes

int length
char * s

Detailed Description

Definition at line 22 of file GString.h.


Constructor & Destructor Documentation

Definition at line 44 of file GString.cc.

                 {
  s = NULL;
  resize(length = 0);
  s[0] = '\0';
}

Here is the call graph for this function:

Here is the caller graph for this function:

GString::GString ( const char *  sA)

Definition at line 50 of file GString.cc.

                               {
  int n = strlen(sA);

  s = NULL;
  resize(length = n);
  memcpy(s, sA, n + 1);
}

Here is the call graph for this function:

GString::GString ( const char *  sA,
int  lengthA 
)

Definition at line 58 of file GString.cc.

                                            {
  s = NULL;
  resize(length = lengthA);
  memcpy(s, sA, length * sizeof(char));
  s[length] = '\0';
}

Here is the call graph for this function:

GString::GString ( GString str,
int  idx,
int  lengthA 
)

Definition at line 65 of file GString.cc.

                                                   {
  s = NULL;
  resize(length = lengthA);
  memcpy(s, str->getCString() + idx, length);
  s[length] = '\0';
}

Here is the call graph for this function:

Definition at line 72 of file GString.cc.

                             {
  s = NULL;
  resize(length = str->getLength());
  memcpy(s, str->getCString(), length + 1);
}

Here is the call graph for this function:

GString::GString ( GString str1,
GString str2 
)

Definition at line 78 of file GString.cc.

                                             {
  int n1 = str1->getLength();
  int n2 = str2->getLength();

  s = NULL;
  resize(length = n1 + n2);
  memcpy(s, str1->getCString(), n1);
  memcpy(s + n1, str2->getCString(), n2 + 1);
}

Here is the call graph for this function:

Definition at line 114 of file GString.cc.

                  {
  delete[] s;
}

Member Function Documentation

GString * GString::append ( char  c)

Definition at line 124 of file GString.cc.

                               {
  resize(length + 1);
  s[length++] = c;
  s[length] = '\0';
  return this;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 131 of file GString.cc.

                                     {
  int n = str->getLength();

  resize(length + n);
  memcpy(s + length, str->getCString(), n + 1);
  length += n;
  return this;
}

Here is the call graph for this function:

GString * GString::append ( const char *  str)

Definition at line 140 of file GString.cc.

                                        {
  int n = strlen(str);

  resize(length + n);
  memcpy(s + length, str, n + 1);
  length += n;
  return this;
}

Here is the call graph for this function:

GString * GString::append ( const char *  str,
int  lengthA 
)

Definition at line 149 of file GString.cc.

                                                     {
  resize(length + lengthA);
  memcpy(s + length, str, lengthA);
  length += lengthA;
  s[length] = '\0';
  return this;
}

Here is the call graph for this function:

Definition at line 118 of file GString.cc.

                        {
  s[length = 0] = '\0';
  resize(0);
  return this;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int GString::cmp ( GString str) [inline]

Definition at line 87 of file GString.h.

{ return strcmp(s, str->getCString()); }

Here is the call graph for this function:

Here is the caller graph for this function:

int GString::cmp ( const char *  sA) [inline]

Definition at line 89 of file GString.h.

{ return strcmp(s, sA); }

Here is the call graph for this function:

int GString::cmpN ( GString str,
int  n 
) [inline]

Definition at line 88 of file GString.h.

{ return strncmp(s, str->getCString(), n); }

Here is the call graph for this function:

int GString::cmpN ( const char *  sA,
int  n 
) [inline]

Definition at line 90 of file GString.h.

{ return strncmp(s, sA, n); }

Here is the call graph for this function:

GString* GString::copy ( ) [inline]

Definition at line 40 of file GString.h.

{ return new GString(this); }

Here is the call graph for this function:

Here is the caller graph for this function:

GString * GString::del ( int  i,
int  n = 1 
)

Definition at line 203 of file GString.cc.

                                  {
  int j;

  if (n > 0) {
    if (i + n > length) {
      n = length - i;
    }
    for (j = i; j <= length - n; ++j) {
      s[j] = s[j + n];
    }
    resize(length -= n);
  }
  return this;
}

Here is the call graph for this function:

Here is the caller graph for this function:

GString * GString::fromInt ( int  x) [static]

Definition at line 88 of file GString.cc.

                               {
  char buf[24]; // enough space for 64-bit ints plus a little extra
  GBool neg;
  Guint y;
  int i;

  i = 24;
  if (x == 0) {
    buf[--i] = '0';
  } else {
    if ((neg = x < 0)) {
      y = (Guint)-x;
    } else {
      y = (Guint)x;
    }
    while (i > 0 && y > 0) {
      buf[--i] = '0' + y % 10;
      y /= 10;
    }
    if (neg && i > 0) {
      buf[--i] = '-';
    }
  }
  return new GString(buf + i, 24 - i);
}

Here is the call graph for this function:

char GString::getChar ( int  i) [inline]

Definition at line 58 of file GString.h.

{ return s[i]; }

Here is the caller graph for this function:

char* GString::getCString ( ) [inline]

Definition at line 55 of file GString.h.

{ return s; }
int GString::getLength ( ) [inline]

Definition at line 52 of file GString.h.

{ return length; }

Here is the caller graph for this function:

GString * GString::insert ( int  i,
char  c 
)

Definition at line 157 of file GString.cc.

                                      {
  int j;

  resize(length + 1);
  for (j = length + 1; j > i; --j)
    s[j] = s[j-1];
  s[i] = c;
  ++length;
  return this;
}

Here is the call graph for this function:

Here is the caller graph for this function:

GString * GString::insert ( int  i,
GString str 
)

Definition at line 168 of file GString.cc.

                                            {
  int n = str->getLength();
  int j;

  resize(length + n);
  for (j = length; j >= i; --j)
    s[j+n] = s[j];
  memcpy(s+i, str->getCString(), n);
  length += n;
  return this;
}

Here is the call graph for this function:

GString * GString::insert ( int  i,
const char *  str 
)

Definition at line 180 of file GString.cc.

                                               {
  int n = strlen(str);
  int j;

  resize(length + n);
  for (j = length; j >= i; --j)
    s[j+n] = s[j];
  memcpy(s+i, str, n);
  length += n;
  return this;
}

Here is the call graph for this function:

GString * GString::insert ( int  i,
const char *  str,
int  lengthA 
)

Definition at line 192 of file GString.cc.

                                                            {
  int j;

  resize(length + lengthA);
  for (j = length; j >= i; --j)
    s[j+lengthA] = s[j];
  memcpy(s+i, str, lengthA);
  length += lengthA;
  return this;
}

Here is the call graph for this function:

Definition at line 228 of file GString.cc.

                            {
  int i;

  for (i = 0; i < length; ++i) {
    if (isupper(s[i]))
      s[i] = tolower(s[i]);
  }
  return this;
}

Here is the caller graph for this function:

void GString::resize ( int  length1) [inline, private]

Definition at line 31 of file GString.cc.

                                       {
  char *s1;

  if (!s) {
    s = new char[size(length1)];
  } else if (size(length1) != size(length)) {
    s1 = new char[size(length1)];
    memcpy(s1, s, length + 1);
    delete[] s;
    s = s1;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void GString::setChar ( int  i,
char  c 
) [inline]

Definition at line 61 of file GString.h.

{ s[i] = c; }

Here is the caller graph for this function:

Definition at line 218 of file GString.cc.

                            {
  int i;

  for (i = 0; i < length; ++i) {
    if (islower(s[i]))
      s[i] = toupper(s[i]);
  }
  return this;
}

Here is the caller graph for this function:


Member Data Documentation

int GString::length [private]

Definition at line 94 of file GString.h.

char* GString::s [private]

Definition at line 95 of file GString.h.


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