01: /** 02: ** Copyright (C) 1999-2007 Lorenzo Bettini 03: ** 04: http://www.lorenzobettini.it 05: 06: r2 = r2 XOR (1<<10); 07: cout << "hello world" << endl; 08: ** 09: */ 10: 11: // this file also contains the definition of mysum as a #define 12: 13: // textgenerator.h : Text Generator class && 14: 15: #ifndef_TEXTGEN_H 16: #define_TEXTGEN_H 17: 18: #definefoo (x)(x +1) 19: 20: #definemysum myfunbody 21: 22: #include<iostream.h>// for cerr 23: 24: #include"genfun.h"/* for generating functions */ 25: 26: classTextGenerator { 27: public: 28: virtualvoidgenerate (constchar*s )const{(*sout)<< s ;} 29: virtualvoidgenerate (constchar*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: virtualvoidgenerateln (constchar*s )const 36: { 37: generate( s ); generate -> test.h:28 generate -> test.h:29 38: (*sout)<< endl ; 39: } 40: virtualvoidgenerateEntire (constchar*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: virtualvoidstartTextGeneration ()const{} 47: virtualvoidendTextGeneration ()const{} 48: virtualvoidbeginText (constchar*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: virtualvoidendText (constchar*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: // Decorator 63: classTextDecorator :publicTextGenerator { 64: protected: 65: TextGenerator *decorated ; 66: 67: public: 68: TextDecorator (TextGenerator *t ):decorated ( t ){} 69: 70: virtualvoidstartTextGeneration ()const 71: { 72: startDecorate(); 73: if(decorated ) 74: decorated ->startTextGeneration(); startTextGeneration -> test.h:46 startTextGeneration -> test.h:70 75: } 76: virtualvoidendTextGeneration ()const 77: { 78: if(decorated ) 79: decorated ->endTextGeneration(); endTextGeneration -> test.h:47 endTextGeneration -> test.h:76 80: endDecorate(); 81: mysum ; 82: } 83: 84: // pure virtual functions 85: virtualvoidstartDecorate()const=0; 86: virtualvoidendDecorate()const=0; 87: }; 88: 89: #endif// _TEXTGEN_H 90: