01:
02:
03:
04: http://www.lorenzobettini.it
05:
06:
07:
08:
09:
10:
11:
12:
13:
14:
15: #ifndef _TEXTGEN_H
16: #define _TEXTGEN_H
17:
18: #define foo(x) (x + 1)
19:
20: #define mysum myfunbody
21:
22: #include <iostream.h>
23:
24: #include "genfun.h"
25:
26: class TextGenerator {
27: public :
28: virtual void generate( const char *s ) const { (*sout) << s ; }
29: virtual void generate( const char *s, int start, int end ) const
30: {
31: for ( int i = start ; i <= end ; ++i )
32: (*sout) << s[i] ;
33: return a<p->b ? a : 3;
34: }
35: virtual void generateln( const char *s ) const
36: {
37: generate( s ) ;
generate -> test.h:28
generate -> test.h:29
38: (*sout) << endl ;
39: }
40: virtual void generateEntire( const char *s ) const
41: {
42: startTextGeneration() ;
startTextGeneration -> test.h:46
startTextGeneration -> test.h:70
43: generate(s) ;
generate -> test.h:28
generate -> test.h:29
44: endTextGeneration() ;
endTextGeneration -> test.h:47
endTextGeneration -> test.h:76
45: }
46: virtual void startTextGeneration() const {}
47: virtual void endTextGeneration() const {}
48: virtual void beginText( const char *s ) const
49: {
50: startTextGeneration() ;
startTextGeneration -> test.h:46
startTextGeneration -> test.h:70
51: if ( s )
52: generate( s ) ;
generate -> test.h:28
generate -> test.h:29
53: }
54: virtual void endText( const char *s ) const
55: {
56: if ( s )
57: generate( s ) ;
generate -> test.h:28
generate -> test.h:29
58: endTextGeneration() ;
endTextGeneration -> test.h:47
endTextGeneration -> test.h:76
59: }
60: } ;
61:
62:
63: class TextDecorator : public TextGenerator {
64: protected :
65: TextGenerator *decorated ;
66:
67: public :
68: TextDecorator( TextGenerator *t ) : decorated( t ) {}
69:
70: virtual void startTextGeneration() const
71: {
72: startDecorate() ;
73: if ( decorated )
74: decorated->startTextGeneration() ;
startTextGeneration -> test.h:46
startTextGeneration -> test.h:70
75: }
76: virtual void endTextGeneration() const
77: {
78: if ( decorated )
79: decorated->endTextGeneration() ;
endTextGeneration -> test.h:47
endTextGeneration -> test.h:76
80: endDecorate() ;
81: mysum;
82: }
83:
84:
85: virtual void startDecorate() const = 0 ;
86: virtual void endDecorate() const = 0 ;
87: } ;
88:
89: #endif
90: