00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
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 ®istry_) :
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 ®istry;
00170
00171
00172 private:
00173
00174 int _line;
00175 string _file;
00176
00180 string _indent;
00181 };
00182
00183 #endif