Download the string header file.

#ifndef _STRCLASS
#define _STRCLASS

#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <iostream.h>
#include <strstream.h>


class Str
{
  protected:
    char *string;
    long length;
    long size;

    void  AlError();
    void  RaError();
    void  NvError();

  public:
    Str();
    Str(long);
    Str(const Str&);
    Str(const Str*);
    Str(const char*);
    Str(const char);
    Str(const char, long);
    ~Str()
               { delete [] string; };
    char  *String()                                          const
               { return string; };
    long   Length()                                          const
               { return length; };
    long   Size()                                            const
               { return size; };
    void   Clear();
    void   SetSize();
    void   SetSize(long);
    void   SetLength(long);
    char  &operator[](long);
    char   Get(long);
    void   Put(const char, long);
    bool   InRange(const long n)                             const
               { return (0 < n && n < length); };
    bool   HasContent()                                      const;

    bool   operator==(const Str &src)                        const
               { return !strcmp(string, src.string); };
    bool   operator==(const char *src)                       const
               { return !strcmp(string, src); };
    bool   operator==(const char src)                        const
               { return (length == 1 && *string == src); };
    bool   operator!=(const Str &src)                        const
               { return strcmp(string, src.string) != 0; };
    bool   operator!=(const char *src)                       const
               { return strcmp(string, src) != 0; };
    bool   operator!=(const char src)                        const
               { return (length != 1 || *string != src); };
    bool   operator<(const Str &src)                         const
               { return strcmp(string, src.string) < 0; };
    bool   operator<(const char *src)                        const
               { return strcmp(string, src) < 0; };
    bool   operator<(const char src)                         const
               { return (!length || (length == 1 && *string < src)); };
    bool   operator<=(const Str &src)                        const
               { return strcmp(string, src.string) < 0; };
    bool   operator<=(const char *src)                       const
               { return strcmp(string, src) < 0; };
    bool   operator<=(const char src)                        const
               { return (!length || (length == 1 && *string < src)); };
    bool   operator>(const Str &src)                         const
               { return strcmp(string, src.string) > 0; };
    bool   operator>(const char *src)                        const
               { return strcmp(string, src) > 0; };
    bool   operator>(const char src)                         const
               { return (length>1 || (length == 1 && *string > src)); };
    bool   operator>=(const Str &src)                        const
               { return strcmp(string, src.string) >= 0; };
    bool   operator>=(const char *src)                       const
               { return strcmp(string, src) >= 0; };
    bool   operator>=(const char src)                        const
               { return (length>1 || (length == 1 && *string >= src)); };
    bool   Equals(const Str& src)                            const
               { return !strcmp(string, src.string); };
    bool   Equals(const Str* src)                            const
               { return !strcmp(string, src->string); };
    bool   Equals(const char* src)                           const
               { return !strcmp(string, src); };
    bool   Equals(const char src)                            const
               { return (length == 1 && *string == src); };
    bool   Compare(const Str&)                               const;
    bool   Compare(const char*)                              const;
    bool   Compare(const char)                               const;
    bool   Compare(const Str&, long);
    bool   Compare(const char*, long);
    bool   Compare(const char, long);
    bool   CompareRight(const Str&)                          const;
    bool   CompareRight(const char*)                         const;
    bool   CompareRight(const char)                          const;
    bool   Contains(const Str&)                              const;
    bool   Contains(const char*)                             const;
    bool   Contains(const char)                              const;
    bool   IsIn(const char*)                                 const;
    long   Find(const Str&)                                  const;
    long   Find(const char*)                                 const;
    long   Find(const char)                                  const;
    bool   Find(const Str&, long&)                           const;
    bool   Find(const char*, long&)                          const;
    bool   Find(const char, long&)                           const;
    long   FindRight(const Str&)                             const;
    long   FindRight(const char*)                            const;
    long   FindRight(const char)                             const;
    bool   FindRight(const Str&, long&)                      const;
    bool   FindRight(const char*, long&)                     const;
    bool   FindRight(const char, long&)                      const;

    Str   &operator=(const Str&);
    Str   &operator=(const char*);
    Str   &operator=(const char);
    Str   &operator=(const long);
    Str   &operator=(const double);
    void   Copy(const Str&);
    void   Copy(const char*);
    void   Copy(const char);
    void   Copy(const long);
    void   Copy(const double);
    void   Copy(const Str&, char);
    void   Copy(const char*, char);
    void   Copy(const char, char);
    void   Copy(const long, char);
    void   Copy(const double, char);
    void   CopyLeft(const Str&, long);
    void   CopyLeft(const char*, long);
    void   CopyMid(const Str&, long, long);
    void   CopyMid(const char*, long, long);
    void   CopyEnd(const Str&, long);
    void   CopyEnd(const char*, long);
    void   CopyRight(const Str&, long);
    void   CopyRight(const char*, long);
    void   CopyField(const Str&, long, bool rt=false);
    void   CopyField(const char*, long, bool rt=false);
    void   CopyField(const char, long, bool rt=false);
    void   CopyField(const long, long, bool rt=false);
    void   CopyField(const double, long, bool rt=false);
    char  *CopyToChar();
    char  *CopyToChar(long);
    char  *CopyToChar(long, long);
    void   CopyToChar(char*, long);
    void   CopyToChar(char*, long, long);
    void   Justify(long, bool rt=false);

    Str    operator+(const Str&);
    Str    operator+(const char*);
    Str    operator+(const char);
    Str    operator+(const long);
    Str    operator+(const double);
    void   operator+=(const Str&);
    void   operator+=(const char*);
    void   operator+=(const char);
    void   operator+=(const long);
    void   operator+=(const double);
    Str   &operator<<(const Str&);
    Str   &operator<<(const char*);
    Str   &operator<<(const char);
    Str   &operator<<(const long);
    Str   &operator<<(const double);
    void   Append(const Str&);
    void   Append(const char*);
    void   Append(const char);
    void   Append(const long);
    void   Append(const double);
    void   Append(const Str&, char);
    void   Append(const char*, char);
    void   Append(const char, char);
    void   Append(const long, char);
    void   Append(const double, char);
    void   Append(const Str&, long);
    void   Append(const char*, long);
    void   Append(const Str&, long, long);
    void   Append(const char*, long, long);
    void   AppendField(const Str&, long, bool rt=false);
    void   AppendField(const char*, long, bool rt=false);
    void   AppendField(const char, long, bool rt=false);
    void   AppendField(const long, long, bool rt=false);
    void   AppendField(const double, long, bool rt=false);

    void   Replace(const Str&, long);
    void   Replace(const char*, long);
    void   Replace(char, long);
    void   ReplaceEnd(const Str&, long);
    void   ReplaceEnd(const char*, long);
    void   ReplaceEnd(const char, long);
    void   ReplaceEnd(const long, long);
    void   ReplaceEnd(const double, long);
    void   Insert(const Str&, long);
    void   Insert(const char*, long);
    void   Insert(const char, long);
    void   InsertLeft(const Str&);
    void   InsertLeft(const char*);
    void   InsertLeft(const char);
    void   Delete(long);
    void   Delete(long, long);
    void   DeleteLeft(long);
    void   DeleteRight(long);

    void   RemoveLeftSpaces();
    void   RemoveRightSpaces();
    void   UpperCase();
    void   LowerCase();
    void   Fill(char);
    void   Fill(char, long);
    void   Reverse();
    void   ToString(const long);
    void   ToString(const double);
    void   ToString(const double, int, int, char *format=NULL);
    void   ToString(tm*, char*);
    void   HexToString(const long, int n=1);
    long   ToInteger()                                       const
               { return atoi(string); };
    double ToFloat()                                         const
               { return atof(string); };
    long   ToHex();
    bool   IsNumber()                                        const;

    friend Str      operator+(const char*, const Str&);
    friend Str      operator+(const char, const Str&);
    friend Str      operator+(const long, const Str&);
    friend Str      operator+(const double, const Str&);
    friend istream &operator>>(istream&, Str&);
    friend ostream &operator<<(ostream&, const Str&);

    friend class    Parser;
    friend class    FileReader;
    friend class    FileWriter;
};

//_________________________________________________________

class Parser
{
    Str   *source;
    char  *cursor;

  public:
           Parser();
           Parser(Str&);
    void   SetString(Str&);
    void   Begin()                       { cursor = source->string; };
    bool   IsNotEnd()                    { return *cursor; };
    bool   Previous(int n=1);
    bool   Next(int n=1);
    bool   SetCursor(long);
    bool   SetCursor(char);
    bool   SkipSpaces();
    long   GetCursor()            const  { return cursor - source->string; };
    char   Get()                  const  { return *cursor; };
    bool   GetCharacter(char&);
    bool   GetToken(Str&);
    bool   SkipToken(int n=1);
    void   SkipBack();
    bool   GetToken(Str&, char);
    bool   SkipToken(char, int n=1);
    void   SkipBack(char);
    bool   GetToken(Str&, long);
    bool   GetLine(Str&);
    bool   SkipLine(int n=1);
    void   GetLeft(Str&);
    bool   GetRight(Str&);
    bool   IsAlpha()              const  { return isalpha(*cursor); };
    bool   Compare(const Str&)    const;
    bool   Compare(const char*)   const;
    bool   Compare(const char s)  const  { return s && *cursor == s; };
    bool   Contains(const Str&);
    bool   Contains(const char*);
    bool   Contains(const char);
};


#endif