#ifndef my_include_output_hh
#define my_include_output_hh
#include <stdio.h>
#include "gccprefs.hh"
class String;
ABSTRACT class Writer
{
public:
virtual ~Writer() {}
virtual Writer& operator<< (const char* string) = null;
virtual Writer& operator<< (char ch) = null;
virtual Writer& operator<< (int i) = null;
virtual Writer& operator<< (double d) = null;
};
final class File_Writer : public Writer
{
private:
FILE* f;
bool ours_to_close;
public:
File_Writer(String file_name);
File_Writer(const char* file_name);
File_Writer(FILE* f);
~File_Writer();
Writer& operator<< (const char* string);
Writer& operator<< (char ch);
Writer& operator<< (int i);
Writer& operator<< (double d);
};
extern File_Writer cout;
extern File_Writer cerr;
const char endl = '\n';
const int string_internal_mem = 1000;
const int string_internal_max_len = string_internal_mem - 1;
class String_Internal
{
public:
int n;
int length;
char array[string_internal_mem];
String_Internal() {
n = 1;
length = 0;
array[0] = 0;
}
};
final class String : public Writer
{
String_Internal* p;
public:
String();
String(const String& x);
String(const char* s);
~String();
String& operator= (const char* s);
String& operator= (const String& x);
char* to_char_star(char* s, int mem_size) const;
friend bool operator== (const String& x, const String& y);
friend bool operator!= (const String& x, const String& y);
Writer& operator<< (char ch);
Writer& operator<< (const char* string);
Writer& operator<< (int i);
Writer& operator<< (double d);
friend Writer& operator<<(Writer& w, const String& x);
String to_quoted_string() const;
String to_reverse() const;
String to_capitalised() const;
String to_substring(int start, int stop) const;
String clone() const;
bool equals(const String& x) const;
bool equals(const char* s) const;
void set_char_at(int index, char ch);
char char_at(int index) const;
int length() const;
private:
static int number_of_errors;
};
#endif