1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
---|
2 | "http://www.w3.org/TR/html4/loose.dtd"> |
---|
3 | |
---|
4 | <html> |
---|
5 | <head> |
---|
6 | <meta http-equiv="Content-Language" content="en-us"> |
---|
7 | <meta http-equiv="Content-Type" content="text/html; charset=us-ascii"> |
---|
8 | <link href="../pool.css" rel="stylesheet" type="text/css"> |
---|
9 | |
---|
10 | <title>for - m4 FOR Macro</title> |
---|
11 | </head> |
---|
12 | |
---|
13 | <body> |
---|
14 | <img src="../../../../boost.png" width="276" height="86" alt="C++ Boost"> |
---|
15 | |
---|
16 | <h1 align="center">for - m4 FOR Macro</h1> |
---|
17 | |
---|
18 | <h2>Introduction</h2> |
---|
19 | |
---|
20 | <p>detail/for.m4 provides <span class="code">BOOST_M4_FOR</span>, an |
---|
21 | <strong>m4</strong> macro that provides the equivalent of a <span class= |
---|
22 | "code">#for</span> preprocessor instruction.</p> |
---|
23 | |
---|
24 | <h2>Usage</h2> |
---|
25 | |
---|
26 | <p>This macro must be used by an <strong>m4</strong> file. This file |
---|
27 | assumes that the option <span class="code">-P</span> is used, to force an |
---|
28 | <span class="code">m4_</span> prefix on all builtin symbols.</p> |
---|
29 | |
---|
30 | <h2>Arguments</h2> |
---|
31 | |
---|
32 | <ol> |
---|
33 | <li>The name of a variable to hold the current value.</li> |
---|
34 | |
---|
35 | <li>The starting value of the variable.</li> |
---|
36 | |
---|
37 | <li>The ending value of the variable.</li> |
---|
38 | |
---|
39 | <li>The text to repeat. This text may contain references to the variable, |
---|
40 | which will be replaced with the variable's current value.</li> |
---|
41 | |
---|
42 | <li>The delimeter text (optional).</li> |
---|
43 | </ol> |
---|
44 | |
---|
45 | <p>If called with the wrong number of arguments (less than 4 or more than |
---|
46 | 5), <span class="code">BOOST_M4_FOR</span> will exit with an error. If the |
---|
47 | starting value (<span class="code">$2</span>) is greater than or equal to |
---|
48 | the ending value (<span class="code">$3</span>), <span class= |
---|
49 | "code">BOOST_M4_FOR</span> will do nothing. Otherwise, it will repeat the |
---|
50 | text (<span class="code">$4</span>), binding the variable (<span class= |
---|
51 | "code">$1</span>) to the values in the range [starting value (<span class= |
---|
52 | "code">$2</span>), ending value (<span class="code">$3</span>)), and repeat |
---|
53 | the delimeter text (<span class="code">$5</span>) in-between each |
---|
54 | occurrence of the repeat text (<span class="code">$4</span>).</p> |
---|
55 | |
---|
56 | <h2>Examples</h2> |
---|
57 | |
---|
58 | <p>Note of the quotation marks (<span class="m4">"</span>) used in the |
---|
59 | table below are in the input or output; they are shown to delimit |
---|
60 | whitespace. All code within a pair of quotation marks is intended to be on |
---|
61 | one line.</p> |
---|
62 | |
---|
63 | <table border align="center" summary=""> |
---|
64 | <tr> |
---|
65 | <th>Input</th> |
---|
66 | |
---|
67 | <th>Output</th> |
---|
68 | </tr> |
---|
69 | |
---|
70 | <tr> |
---|
71 | <td class="m4">"BOOST_M4_FOR(i, 1, 3)"</td> |
---|
72 | |
---|
73 | <td>Boost m4 script: BOOST_M4_FOR: Wrong number of arguments (3)</td> |
---|
74 | </tr> |
---|
75 | |
---|
76 | <tr> |
---|
77 | <td class="m4">"BOOST_M4_FOR(i, 1, 3, i, ` ', 13)"</td> |
---|
78 | |
---|
79 | <td>Boost m4 script: BOOST_M4_FOR: Wrong number of arguments (6)</td> |
---|
80 | </tr> |
---|
81 | |
---|
82 | <tr> |
---|
83 | <td class="m4">"BOOST_M4_FOR(i, 7, 0, i )"</td> |
---|
84 | |
---|
85 | <td>(nothing)</td> |
---|
86 | </tr> |
---|
87 | |
---|
88 | <tr> |
---|
89 | <td class="m4">"BOOST_M4_FOR(i, 0, 0, i )"</td> |
---|
90 | |
---|
91 | <td>(nothing)</td> |
---|
92 | </tr> |
---|
93 | |
---|
94 | <tr> |
---|
95 | <td class="m4">"BOOST_M4_FOR(i, 0, 7, i )"</td> |
---|
96 | |
---|
97 | <td class="m4">"0 1 2 3 4 5 6 "</td> |
---|
98 | </tr> |
---|
99 | |
---|
100 | <tr> |
---|
101 | <td class="m4">"BOOST_M4_FOR(i, -13, -10, i )"</td> |
---|
102 | |
---|
103 | <td class="m4">"-13 -12 -11 "</td> |
---|
104 | </tr> |
---|
105 | |
---|
106 | <tr> |
---|
107 | <td class="m4">"BOOST_M4_FOR(i, 0, 8, BOOST_M4_FOR(j, 0, 4, (i, j) |
---|
108 | )"<br> |
---|
109 | ")"</td> |
---|
110 | |
---|
111 | <td class="m4">"(0, 0) (0, 1) (0, 2) (0, 3) "<br> |
---|
112 | "(1, 0) (1, 1) (1, 2) (1, 3) "<br> |
---|
113 | "(2, 0) (2, 1) (2, 2) (2, 3) "<br> |
---|
114 | "(3, 0) (3, 1) (3, 2) (3, 3) "<br> |
---|
115 | "(4, 0) (4, 1) (4, 2) (4, 3) "<br> |
---|
116 | "(5, 0) (5, 1) (5, 2) (5, 3) "<br> |
---|
117 | "(6, 0) (6, 1) (6, 2) (6, 3) "<br> |
---|
118 | "(7, 0) (7, 1) (7, 2) (7, 3) "<br> |
---|
119 | ""</td> |
---|
120 | </tr> |
---|
121 | |
---|
122 | <tr> |
---|
123 | <td class="m4">"BOOST_M4_FOR(i, 7, 0, i, |)"</td> |
---|
124 | |
---|
125 | <td>(nothing)</td> |
---|
126 | </tr> |
---|
127 | |
---|
128 | <tr> |
---|
129 | <td class="m4">"BOOST_M4_FOR(i, 0, 0, i, |)"</td> |
---|
130 | |
---|
131 | <td>(nothing)</td> |
---|
132 | </tr> |
---|
133 | |
---|
134 | <tr> |
---|
135 | <td class="m4">"BOOST_M4_FOR(i, 0, 7, i, |)"</td> |
---|
136 | |
---|
137 | <td class="m4">"0|1|2|3|4|5|6"</td> |
---|
138 | </tr> |
---|
139 | |
---|
140 | <tr> |
---|
141 | <td class="m4">"BOOST_M4_FOR(i, -13, -10, i, `, ')"</td> |
---|
142 | |
---|
143 | <td class="m4">"-13, -12, -11"</td> |
---|
144 | </tr> |
---|
145 | |
---|
146 | <tr> |
---|
147 | <td class="m4">"BOOST_M4_FOR(i, 0, 8, `[BOOST_M4_FOR(j, 0, 4, (i, j), |
---|
148 | `, ')]', `,"<br> |
---|
149 | "')"</td> |
---|
150 | |
---|
151 | <td class="m4">"[(0, 0), (0, 1), (0, 2), (0, 3)],"<br> |
---|
152 | "[(1, 0), (1, 1), (1, 2), (1, 3)],"<br> |
---|
153 | "[(2, 0), (2, 1), (2, 2), (2, 3)],"<br> |
---|
154 | "[(3, 0), (3, 1), (3, 2), (3, 3)],"<br> |
---|
155 | "[(4, 0), (4, 1), (4, 2), (4, 3)],"<br> |
---|
156 | "[(5, 0), (5, 1), (5, 2), (5, 3)],"<br> |
---|
157 | "[(6, 0), (6, 1), (6, 2), (6, 3)],"<br> |
---|
158 | "[(7, 0), (7, 1), (7, 2), (7, 3)]"</td> |
---|
159 | </tr> |
---|
160 | </table> |
---|
161 | <hr> |
---|
162 | |
---|
163 | <p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src= |
---|
164 | "http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" |
---|
165 | height="31" width="88"></a></p> |
---|
166 | |
---|
167 | <p>Revised |
---|
168 | <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->05 |
---|
169 | December, 2006<!--webbot bot="Timestamp" endspan i-checksum="38516" --></p> |
---|
170 | |
---|
171 | <p><i>Copyright © 2000, 2001 Stephen Cleary (scleary AT jerviswebb DOT |
---|
172 | com)</i></p> |
---|
173 | |
---|
174 | <p><i>Distributed under the Boost Software License, Version 1.0. (See |
---|
175 | accompanying file <a href="../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> |
---|
176 | or copy at <a href= |
---|
177 | "http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)</i></p> |
---|
178 | </body> |
---|
179 | </html> |
---|