Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

writer.hh

Go to the documentation of this file.
00001 /*
00002  *  File:       writer.hh
00003  *              $Id: writer.hh,v 1.4 2002/07/09 03:04:58 alec Exp $
00004  *
00005  *  Author:     Alec Panoviciu (alecu@email.com)
00006  *
00007  *  Comments:
00008  *
00009  *  Revision history:
00010  *
00011  *  $Log: writer.hh,v $
00012  *  Revision 1.4  2002/07/09 03:04:58  alec
00013  *  OWN_STRINGS bu*beep*it finally vanished
00014  *  gcc 3.1&mingw - related cleanups
00015  *
00016  *  Revision 1.3  2002/06/26 20:51:47  alec
00017  *  g++ 3.x happy
00018  *
00019  *  Revision 1.2  2002/06/13 11:43:42  alec
00020  *  added #line stuff
00021  *
00022  *  Revision 1.1  2002/05/04 17:46:53  alec
00023  *  *** empty log message ***
00024  *
00025  */
00026 
00027 
00028 /* 
00029   Copyright (C) 2002 Alexandru Panoviciu (alecu@email.com)
00030 
00031   This program is free software; you can redistribute it and/or modify
00032   it under the terms of the GNU General Public License as published by
00033   the Free Software Foundation; either version 2 of the License, or
00034   (at your option) any later version.
00035 
00036   This program is distributed in the hope that it will be useful,
00037   but WITHOUT ANY WARRANTY; without even the implied warranty of
00038   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00039   GNU General Public License for more details.
00040 
00041   You should have received a copy of the GNU General Public License
00042   along with this program; if not, write to the Free Software
00043   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00044 
00045  */
00046 
00047 #ifndef __WRITER_HH__
00048 #define __WRITER_HH__
00049 
00050 #include <iostream>
00051 #include <string>
00052 #include <fstream>
00053 using namespace std;
00054 
00055 #include "debug.h"
00056 
00057 struct t_CodeChunk;
00058 typedef struct t_CodeChunk CodeChunk;
00059 class PropRegistry;
00060 
00077 class Writer
00078 {
00079 protected:
00080 
00081   Writer (PropRegistry &registry_) :
00082     registry(registry_)
00083   {}
00084   
00089   string className2cc (const string &className);
00090 
00095   string className2hh (const string &className);
00096 
00101   string className2macro (const string &className);
00102   
00108   string fullPath (const string &fileName);
00109 
00118   void openStream (const string &fullPathName);
00119 
00124   void closeStream ();
00125   
00126   void indent ()
00127   {
00128     _indent.resize(_indent.size() + 2, ' ');
00129   }
00130   
00131   void unindent ()
00132   {
00133     ASSERT(_indent.size() >= 2, "extra un_indent !");
00134     _indent.resize(_indent.size() - 2);
00135   }
00136   
00137   ostream& line (bool dumpSharpLine = false)
00138   {
00139     ofs << endl;
00140     _line++;
00141     if (dumpSharpLine) {
00142       ofs << "#line " << _line << " \"" << _file << "\"" <<  endl;
00143     }
00144     return ofs << _indent;
00145   }
00146 
00160   ostream& writeChunk (const CodeChunk &cc, const string &terminator = "");
00161   
00167   ofstream ofs;
00168 
00169   PropRegistry &registry;
00170 
00171   
00172 private:
00173 
00174   int _line;
00175   string _file;
00176   
00180   string _indent;
00181 };
00182 
00183 #endif /* #ifndef __WRITER_HH__ */

Generated at Tue Jul 9 21:05:46 2002 for CppCC by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001