GNU   davin.50webs.com/research
Bringing to you notes for the ages

       Main Menu          Research Projects         Photo Album            Curriculum Vitae      The Greatest Artists
    Email Address       Computer Games          Web Design          Java Training Wheels      The Fly (A Story)   
  Political Activism   Scruff the Cat       My Life Story          Smoking Cessation          Other Links      
Debugging Macros     String Class I     Linked List System I Java for C Programmers Naming Convention
    String Class II         How I use m4              Strings III                 Symmetrical I/O             Linked Lists II     
Run-Time Type Info   Virtual Methods      An Array System        Science & Religion            Submodes       
  Nested Packages      Memory Leaks    Garbage Collection      Internet & Poverty      What is Knowledge?
Limits of Evolution   Emacs Additions      Function Plotter           Romantic Love        The Next Big Thing
    Science Fiction     Faster Compilation Theory of Morality         Elisp Scoping               Elisp Advice      
  S.O.G.M. Pattern       Safe Properties         School Bullying          Charisma Control          Life and Death    
     Splitting Java          Multiple Ctors       Religious Beliefs         Conversation 1           Conversation 2    
   J.T.W. Language    Emacs Additions II      Build Counter             Relation Plotter          Lisp++ Language  
  Memory Leaks II   Super Constructors CRUD Implementation Order a Website Form There Is An Afterlife
More Occam's Razor C to Java Translator Theory of Morality II


output.hh

    
#ifndef my_include_output_hh
#define my_include_output_hh

#include <stdio.h>
#include "gccprefs.hh"

// GENERAL-PURPOSE OUTPUT ROUTINES...
// The operator << is used for output
// for both built-in and user-defined types.
// For built-in types, the functions are
// defined here.  For user-defined types,
// functions are defined in the appropriate
// classes.

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]; // GUARANTEED: array[length] == 0 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; // // It doesn't make sense to == or != with a const char*, // since the answer would always be false... // friend bool operator== (const String& x, const String& y); friend bool operator!= (const String& x, const String& y); // // WRITER PATTERN: s << x // 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); // // TO_XXXX METHODS: these methods return an object // based on "this" object, leaving this object unchanged. // String to_quoted_string() const; String to_reverse() const; String to_capitalised() const; String to_substring(int start, int stop) const; String clone() const; // deviates from the to_XXX pattern since // the name "clone" indicates the behaviour 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 /* my_include_output_hh */
Back
| Main Menu | Research Projects | Photo Album | Curriculum Vitae | The Greatest Artists |
| Email Address | Computer Games | Web Design | Java Training Wheels | The Fly (A Story) |
| Political Activism | Scruff the Cat | My Life Story | Smoking Cessation | Other Links |
| Debugging Macros | String Class I | Linked List System I | Java for C Programmers | Naming Convention |
| String Class II | How I use m4 | Strings III | Symmetrical I/O | Linked Lists II |
| Run-Time Type Info | Virtual Methods | An Array System | Science & Religion | Submodes |
| Nested Packages | Memory Leaks | Garbage Collection | Internet & Poverty | What is Knowledge? |
| Limits of Evolution | Emacs Additions | Function Plotter | Romantic Love | The Next Big Thing |
| Science Fiction | Faster Compilation | Theory of Morality | Elisp Scoping | Elisp Advice |
| S.O.G.M. Pattern | Safe Properties | School Bullying | Charisma Control | Life and Death |
| Splitting Java | Multiple Ctors | Religious Beliefs | Conversation 1 | Conversation 2 |
| J.T.W. Language | Emacs Additions II | Build Counter | Relation Plotter | Lisp++ Language |
| Memory Leaks II | Super Constructors | CRUD Implementation | Order a Website Form | There Is An Afterlife |
| More Occam's Razor | C to Java Translator | Theory of Morality II
Last modified: Sun Sep 25 16:08:41 NZDT 2016
Best viewed at 800x600 or above resolution.
© Copyright 1999-2016 Davin Pearson.
Please report any broken links to