/*
 Header fuer eine Klasse zur einfachen Bearbeitung von Strings
 von                : Oliver Nitsche
 erstellt am        : 20.05.1996
 letzte Aenderung am : 20.05.1996
*/


/* erweitert von Wolfgang Schneider */

#ifndef __cstring_h__
#define __cstring_h__

#include <iostream.h>
#include <string.h>



enum Orientation {LEFT, RIGHT, CENTER};


class CString {
  public:
	 CString();
	 CString(const char *str);
	 CString(CString &str);
	 ~CString() {delete []data;};
	 char& operator[](int i) {return data[i];} // Indexoperator
	 CString& operator=(CString &str);   // Zuweisungsoperatoren
	 CString& operator=(char *str);
	 friend CString operator+(CString &A, CString &B); // Verknuepfen
	 friend ostream& operator<<(ostream &s, CString str); // Ausgabeoperator
	 friend int operator==(CString A, CString B); // Vergleichsoperatoren
	 friend int operator==(CString A, char* B);

	 char *get(int pos=0) {return data+pos;}
	 int getLength() {return strlen(data);}
	 friend CString operator+(CString &A, CString *B); // Verknuepfen
	 friend CString operator+(CString &A, char *);
	 CString& operator+=(CString &str);
	 CString& operator+=(CString *str);
	 CString& operator+=(char *str);
	 friend ostream& operator<<(ostream &s, CString *str); // Ausgabeoperator
	 operator char*() {return data;} // Umwandlung in char*
	 void setFieldWidth(int i) {fieldWidth=i;}
	 void setFieldOrientation(Orientation o) {fieldOrientation=o;}

  protected:
	 char *convertToField(char **);
//	 char *convertToField(CString *);
//	 char *convertToField(CString &);
	 char* data;
	 Orientation fieldOrientation;
	 int fieldWidth;
};


// Prototyping
typedef CString String;
void strCatWithTab(int fieldWidth, char **text, char *cat, Orientation fieldOrientation);


#endif
