1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
|
@c Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite
@example
@t{01:} @r{@i{/**}}
@t{02:} @r{@i{** Copyright (C) 1999-2007 Lorenzo Bettini}}
@t{03:} @r{@i{** }}
@t{04:} @r{@i{ }}@t{http://www.lorenzobettini.it}
@t{05:} @r{@i{ }}
@t{06:} @r{@i{ r2 = r2 XOR (1<<10);}}
@t{07:} @r{@i{ cout << "hello world" << endl;}}
@t{08:} @r{@i{** }}
@t{09:} @r{@i{*/}}
@t{10:}
@t{11:} @r{@i{// this file also contains the definition of mysum as a #define}}
@t{12:}
@t{13:} @r{@i{// textgenerator.h : Text Generator class &&}}
@t{14:}
@t{15:} @b{#ifndef} _TEXTGEN_H
@flushright
@r{@i{@xref{test.h:16,_TEXTGEN_H,_TEXTGEN_H test.h:16}.}}
@end flushright
@t{16:} @b{#define} @anchor{test.h:16}_TEXTGEN_H
@t{17:}
@t{18:} @b{#define} @anchor{test.h:18}foo(x) (x + 1)
@t{19:}
@t{20:} @b{#define} @anchor{test.h:20}mysum myfunbody
@t{21:}
@t{22:} @b{#include} @t{<iostream.h>} @r{@i{// for cerr}}
@t{23:}
@t{24:} @b{#include} @t{"genfun.h"} @r{@i{/* for generating functions */}}
@t{25:}
@t{26:} @b{class} @anchor{test.h:26}TextGenerator @{
@t{27:} @b{public} :
@t{28:} @b{virtual} @b{void} @anchor{test.h:28}generate( @b{const} @b{char} *s ) @b{const} @{ (*sout) << s ; @}
@t{29:} @b{virtual} @b{void} @anchor{test.h:29}generate( @b{const} @b{char} *s, @b{int} start, @b{int} end ) @b{const}
@t{30:} @{
@t{31:} @b{for} ( @b{int} i = start ; i <= end ; ++i )
@t{32:} (*sout) << s[i] ;
@t{33:} @b{return} a<p->b ? a : 3;
@t{34:} @}
@t{35:} @b{virtual} @b{void} @anchor{test.h:35}generateln( @b{const} @b{char} *s ) @b{const}
@t{36:} @{
@t{37:} generate( s ) ;
@flushright
@r{@i{@xref{test.h:28,generate,generate test.h:28}.}}
@end flushright
@flushright
@r{@i{@xref{test.h:29,generate,generate test.h:29}.}}
@end flushright
@t{38:} (*sout) << endl ;
@t{39:} @}
@t{40:} @b{virtual} @b{void} @anchor{test.h:40}generateEntire( @b{const} @b{char} *s ) @b{const}
@t{41:} @{
@t{42:} startTextGeneration() ;
@flushright
@r{@i{@xref{test.h:46,startTextGeneration,startTextGeneration test.h:46}.}}
@end flushright
@flushright
@r{@i{@xref{test.h:70,startTextGeneration,startTextGeneration test.h:70}.}}
@end flushright
@t{43:} generate(s) ;
@flushright
@r{@i{@xref{test.h:28,generate,generate test.h:28}.}}
@end flushright
@flushright
@r{@i{@xref{test.h:29,generate,generate test.h:29}.}}
@end flushright
@t{44:} endTextGeneration() ;
@flushright
@r{@i{@xref{test.h:47,endTextGeneration,endTextGeneration test.h:47}.}}
@end flushright
@flushright
@r{@i{@xref{test.h:76,endTextGeneration,endTextGeneration test.h:76}.}}
@end flushright
@t{45:} @}
@t{46:} @b{virtual} @b{void} @anchor{test.h:46}startTextGeneration() @b{const} @{@}
@t{47:} @b{virtual} @b{void} @anchor{test.h:47}endTextGeneration() @b{const} @{@}
@t{48:} @b{virtual} @b{void} @anchor{test.h:48}beginText( @b{const} @b{char} *s ) @b{const}
@t{49:} @{
@t{50:} startTextGeneration() ;
@flushright
@r{@i{@xref{test.h:46,startTextGeneration,startTextGeneration test.h:46}.}}
@end flushright
@flushright
@r{@i{@xref{test.h:70,startTextGeneration,startTextGeneration test.h:70}.}}
@end flushright
@t{51:} @b{if} ( s )
@t{52:} generate( s ) ;
@flushright
@r{@i{@xref{test.h:28,generate,generate test.h:28}.}}
@end flushright
@flushright
@r{@i{@xref{test.h:29,generate,generate test.h:29}.}}
@end flushright
@t{53:} @}
@t{54:} @b{virtual} @b{void} @anchor{test.h:54}endText( @b{const} @b{char} *s ) @b{const}
@t{55:} @{
@t{56:} @b{if} ( s )
@t{57:} generate( s ) ;
@flushright
@r{@i{@xref{test.h:28,generate,generate test.h:28}.}}
@end flushright
@flushright
@r{@i{@xref{test.h:29,generate,generate test.h:29}.}}
@end flushright
@t{58:} endTextGeneration() ;
@flushright
@r{@i{@xref{test.h:47,endTextGeneration,endTextGeneration test.h:47}.}}
@end flushright
@flushright
@r{@i{@xref{test.h:76,endTextGeneration,endTextGeneration test.h:76}.}}
@end flushright
@t{59:} @}
@t{60:} @} ;
@t{61:}
@t{62:} @r{@i{// Decorator}}
@t{63:} @b{class} @anchor{test.h:63}TextDecorator : @b{public} TextGenerator @{
@flushright
@r{@i{@xref{test.h:26,TextGenerator,TextGenerator test.h:26}.}}
@end flushright
@t{64:} @b{protected} :
@t{65:} TextGenerator *@anchor{test.h:65}decorated ;
@flushright
@r{@i{@xref{test.h:26,TextGenerator,TextGenerator test.h:26}.}}
@end flushright
@t{66:}
@t{67:} @b{public} :
@t{68:} @anchor{test.h:68}TextDecorator( TextGenerator *t ) : decorated( t ) @{@}
@flushright
@r{@i{@xref{test.h:26,TextGenerator,TextGenerator test.h:26}.}}
@end flushright
@flushright
@r{@i{@xref{test.h:65,decorated,decorated test.h:65}.}}
@end flushright
@t{69:}
@t{70:} @b{virtual} @b{void} @anchor{test.h:70}startTextGeneration() @b{const}
@t{71:} @{
@t{72:} startDecorate() ;
@t{73:} @b{if} ( decorated )
@flushright
@r{@i{@xref{test.h:65,decorated,decorated test.h:65}.}}
@end flushright
@t{74:} decorated->startTextGeneration() ;
@flushright
@r{@i{@xref{test.h:46,startTextGeneration,startTextGeneration test.h:46}.}}
@end flushright
@flushright
@r{@i{@xref{test.h:65,decorated,decorated test.h:65}.}}
@end flushright
@flushright
@r{@i{@xref{test.h:70,startTextGeneration,startTextGeneration test.h:70}.}}
@end flushright
@t{75:} @}
@t{76:} @b{virtual} @b{void} @anchor{test.h:76}endTextGeneration() @b{const}
@t{77:} @{
@t{78:} @b{if} ( decorated )
@flushright
@r{@i{@xref{test.h:65,decorated,decorated test.h:65}.}}
@end flushright
@t{79:} decorated->endTextGeneration() ;
@flushright
@r{@i{@xref{test.h:47,endTextGeneration,endTextGeneration test.h:47}.}}
@end flushright
@flushright
@r{@i{@xref{test.h:65,decorated,decorated test.h:65}.}}
@end flushright
@flushright
@r{@i{@xref{test.h:76,endTextGeneration,endTextGeneration test.h:76}.}}
@end flushright
@t{80:} endDecorate() ;
@t{81:} mysum;
@flushright
@r{@i{@xref{test.h:20,mysum,mysum test.h:20}.}}
@end flushright
@t{82:} @}
@t{83:}
@t{84:} @r{@i{// pure virtual functions}}
@t{85:} @b{virtual} @b{void} startDecorate() @b{const} = 0 ;
@t{86:} @b{virtual} @b{void} endDecorate() @b{const} = 0 ;
@t{87:} @} ;
@t{88:}
@t{89:} @b{#endif} @r{@i{// _TEXTGEN_H}}
@t{90:}
@end example
|