Back to index

im-sdk  12.3.91
Public Member Functions | Private Attributes
CompoundString Class Reference

#include <CompoundString.hh>

List of all members.

Public Member Functions

 CompoundString ()
 ~CompoundString ()
 CompoundString (const CompoundString &a)
 CompoundString (const int)
 CompoundString (const int, int)
 operator char * () const
int operator!= (const CompoundString &) const
int compare (const CompoundString &, int) const
int compare (const CompoundString &) const
int search (CompoundString &) const
unsigned char * toUchar () const
native CompoundString (const char[])
native CompoundString (const wchar_t[])
native CompoundStringoperator= (const CompoundString &a)
native CompoundStringoperator= (const char *s)
native CompoundStringoperator= (const unsigned char *s)
native CompoundString operator+ (const CompoundString &) const
native CompoundStringoperator+= (const CompoundString &)
native CompoundStringoperator-= (const CompoundString &)
native int operator== (const CompoundString &) const
native int compare (const char[], int) const
native int compare (const char[]) const
native int search (const char[]) const
native unsigned int length () const

Private Attributes

char * pBuffer

Detailed Description

Definition at line 51 of file CompoundString.hh.


Constructor & Destructor Documentation

Definition at line 48 of file CompoundString.cpp.

                               {
  pBuffer = new char[1];
  pBuffer[0] = 0;
}

Definition at line 67 of file CompoundString.cpp.

                                {
  delete [] pBuffer;
}

Definition at line 63 of file CompoundString.cpp.

                                                      {
  pBuffer = 0; *this = a;
}
CompoundString::CompoundString ( const int  len)

Definition at line 53 of file CompoundString.cpp.

                                            {
  pBuffer = new char[len + 1];
  for(int i=0;i<len;i++) pBuffer[i]=' ';
  pBuffer[len] = 0;
}
CompoundString::CompoundString ( const int  len,
int  dummy 
)

Definition at line 59 of file CompoundString.cpp.

                                                       {
  pBuffer = new char[len + 1];
}
CompoundString::CompoundString ( const char  astring[])

Definition at line 50 of file CompoundStringP.cpp.

                                                   {
  if (astring == 0) {
    pBuffer = new char[1];
    pBuffer[0] = 0;
  } else {
    pBuffer = new char[strlen(astring) + 1];
    strcpy(pBuffer, astring);
  }
}
CompoundString::CompoundString ( const wchar_t  astring[])

Definition at line 60 of file CompoundStringP.cpp.

                                                      {
  if (astring == 0) {
    pBuffer = new char[1];
    pBuffer[0] = 0;
  } else {
    int len = wcstombs(0, astring, 0); // 3rd argument is ignored
    if (len == -1) return;
    pBuffer = new char[len + 1];
    wcstombs(pBuffer, astring, len);
  }
}

Member Function Documentation

int CompoundString::compare ( const CompoundString a,
int  n 
) const

Definition at line 82 of file CompoundString.cpp.

                                                            {
  return compare(a.pBuffer, n);
}

Here is the caller graph for this function:

int CompoundString::compare ( const CompoundString a) const

Definition at line 77 of file CompoundString.cpp.

                                                     {
  return compare(a.pBuffer);
}

Here is the call graph for this function:

int CompoundString::compare ( const char  aBuffer[],
int  n 
) const

Definition at line 159 of file CompoundStringP.cpp.

                                                         {
  return !strncmp(pBuffer, aBuffer, n);
}
int CompoundString::compare ( const char  aBuffer[]) const

Definition at line 164 of file CompoundStringP.cpp.

                                                  {
  return !strcmp(pBuffer, aBuffer);
}
unsigned int CompoundString::length ( ) const

Definition at line 175 of file CompoundStringP.cpp.

                             {
  return strlen(pBuffer);
}

Here is the caller graph for this function:

CompoundString::operator char * ( ) const [inline]

Definition at line 58 of file CompoundString.hh.

{return pBuffer;}
int CompoundString::operator!= ( const CompoundString a) const

Definition at line 72 of file CompoundString.cpp.

                                                        {
  return *this == a ? 0 : 1;
}
CompoundString CompoundString::operator+ ( const CompoundString a) const

Definition at line 98 of file CompoundStringP.cpp.

                                                       {
  CompoundString d;
  unsigned int len1 = length();
  unsigned int len2 = a.length();
  unsigned int len = len1 + len2 + 1;

  char *pTemp = new char[len];

  strcpy(pTemp, pBuffer);
  strcat(pTemp, a.pBuffer);

  d = pTemp;

  delete [] pTemp;
  return d;
}

Here is the call graph for this function:

CompoundString & CompoundString::operator+= ( const CompoundString a)

Definition at line 116 of file CompoundStringP.cpp.

                                                  {
  unsigned int len1 = length();
  unsigned int len2 = a.length();
  unsigned int len = len1 + len2 + 1;

  char *pTemp = new char[len];

  strcpy(pTemp, pBuffer);
  strcat(pTemp, a.pBuffer);

  delete [] pBuffer;

  pBuffer = pTemp;
  return *this;
}

Here is the call graph for this function:

CompoundString & CompoundString::operator-= ( const CompoundString a)

Definition at line 133 of file CompoundStringP.cpp.

                                                  {
  char *p;

  if (a.length() > length()) return *this;

  if ((p = strstr(pBuffer, a.pBuffer)) != 0) {
    unsigned int len = length() - a.length() + 1;
    unsigned int frontLen = p - pBuffer;
    unsigned int backLen = length() - frontLen - a.length();

    char *pTemp = new char[len];
    strncpy(pTemp, pBuffer, frontLen);
    strncat(pTemp, p + a.length(), backLen);
    pTemp[frontLen + backLen] = 0;
    delete [] pBuffer;
    pBuffer = pTemp;
  }
  return *this;
}

Here is the call graph for this function:

CompoundString & CompoundString::operator= ( const CompoundString a)

Definition at line 73 of file CompoundStringP.cpp.

                                                 {
  char *pTemp = new char[a.length() + 1];
  strcpy(pTemp, a.pBuffer);
  delete [] pBuffer;
  pBuffer = pTemp;
  return *this;
}

Here is the call graph for this function:

CompoundString & CompoundString::operator= ( const char *  s)

Definition at line 82 of file CompoundStringP.cpp.

                                        {
  delete [] pBuffer;
  pBuffer = new char[strlen(s) + 1];
  strcpy(pBuffer, s);
  return *this;
}
CompoundString & CompoundString::operator= ( const unsigned char *  s)

Definition at line 90 of file CompoundStringP.cpp.

                                                 {
  delete [] pBuffer;
  pBuffer = new char[strlen((const char *)s) + 1];
  strcpy(pBuffer, (const char *)s);
  return *this;
}
int CompoundString::operator== ( const CompoundString a) const

Definition at line 154 of file CompoundStringP.cpp.

                                                        {
  return strcmp(pBuffer, a.pBuffer) ? 0 : 1;
}

Definition at line 87 of file CompoundString.cpp.

                                              {
  return search(a.pBuffer);
}

Here is the caller graph for this function:

int CompoundString::search ( const char  aBuffer[]) const

Definition at line 169 of file CompoundStringP.cpp.

                                                 {
  char *p = strstr(pBuffer, aBuffer);
  return p == 0 ? -1: p - pBuffer;
}
unsigned char* CompoundString::toUchar ( ) const [inline]

Definition at line 64 of file CompoundString.hh.

{return (unsigned char*)pBuffer;}

Here is the caller graph for this function:


Member Data Documentation

char* CompoundString::pBuffer [private]

Definition at line 80 of file CompoundString.hh.


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