#ifndef STRING_H
#define STRING_H

/*
 * @(#)String.h
 *
 * This file is part of webCDwriter - Network CD Writing.
 *
 * Copyright (C) 2002 Jörg P. M. Haeger
 *
 * webCDwriter is free software. See CDWserver.cpp for details.
 */

#include "Object.h"

class String: public Object {
	class StringBuffer *buf;
	char *bytes;
	boolean tmp;
	int validityMark;
	static const int originalValidityMark;
public:
	String();
	String(const String &str);
	String(String *str);
	String(const char *str);
	String(class StringBuffer &buffer);
	String(class StringBuffer *buffer);
	~String();
	String &operator=(String &str);
	String &operator=(String *str);
	String &operator=(const char *str);
	String &operator+(char c);
	String &operator+(int i);
	String &operator+(long l);
	String &operator+(String &str);
	String &operator+(const char *str);

	String &operator+(String *str) {
		this->operator+(*str);
		delete str;
		return *this;
	}

	int charAt(int index);
	int compareToIgnoreCase(const char *str);
	int endsWith(const char *suffix);
	int equals(const char *str);
	int equals(String &str);
	int equalsIgnoreCase(const char *str);
	static void free(String *str);
	const char *getBytes();
	int indexOf(const char *str);

	public: boolean instanceof(const char *objectName) {
		return equal(objectName, "String")
			|| Object::instanceof(objectName);
	}

	int lastIndexOf(const char *str);
	int length();
	int startsWith(const char *prefix);
	String *substring(int beginIndex);
	String *substring(int beginIndex, int endIndex);

	public: String *toString() {
		return new String(*this);
	}

	static String *valueOf(int i);
	static String *valueOf(long l);
};

class EmptyString {
public:
	String e;
};

extern EmptyString S;

#endif
