File: for.html

package info (click to toggle)
boost 1.27.0-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 19,908 kB
  • ctags: 26,546
  • sloc: cpp: 122,225; ansic: 10,956; python: 4,412; sh: 855; yacc: 803; makefile: 257; perl: 165; lex: 90; csh: 6
file content (75 lines) | stat: -rw-r--r-- 4,600 bytes parent folder | download
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<HTML>
<HEAD>
<TITLE>for - m4 FOR Macro</TITLE>
<LINK HREF="../pool.css" REL="stylesheet" TYPE="text/css">
</HEAD>
<BODY>

<IMG SRC="../../../../c++boost.gif" WIDTH=276 HEIGHT=86 ALT="C++ Boost">

<H1 ALIGN=CENTER>for - m4 FOR Macro</H1>

<P>
<H2>Introduction</H2>

<P>
detail/for.m4 provides <SPAN CLASS="code">BOOST_M4_FOR</SPAN>, an <STRONG>m4</STRONG> macro that provides the equivalent of a <SPAN CLASS="code">#for</SPAN> preprocessor instruction.

<P>
<H2>Usage</H2>

<P>
This macro must be used by an <STRONG>m4</STRONG> file.  This file assumes that the option <SPAN CLASS="code">-P</SPAN> is used, to force an <SPAN CLASS="code">m4_</SPAN> prefix on all builtin symbols.

<P>
<H2>Arguments</H2>

<OL>
<LI>The name of a variable to hold the current value.</LI>
<LI>The starting value of the variable.</LI>
<LI>The ending value of the variable.</LI>
<LI>The text to repeat.  This text may contain references to the variable, which will be replaced with the variable's current value.</LI>
<LI>The delimeter text (optional).</LI>
</OL>

<P>
If called with the wrong number of arguments (less than 4 or more than 5), <SPAN CLASS="code">BOOST_M4_FOR</SPAN> will exit with an error.  If the starting value (<SPAN CLASS="code">$2</SPAN>) is greater than or equal to the ending  value (<SPAN CLASS="code">$3</SPAN>), <SPAN CLASS="code">BOOST_M4_FOR</SPAN> will do nothing.  Otherwise, it will repeat the text (<SPAN CLASS="code">$4</SPAN>), binding the variable (<SPAN CLASS="code">$1</SPAN>) to the values in the range [starting value (<SPAN CLASS="code">$2</SPAN>), ending value (<SPAN CLASS="code">$3</SPAN>)), and repeat the delimeter text (<SPAN CLASS="code">$5</SPAN>) in-between each occurrence of the repeat text (<SPAN CLASS="code">$4</SPAN>).

<P>
<H2>Examples</H2>

<P>
Note of the quotation marks (<SPAN CLASS="m4">&quot;</SPAN>) used in the table below are in the input or output; they are shown to delimit whitespace.  All code within a pair of quotation marks is intended to be on one line.

<P>
<TABLE BORDER ALIGN="center">
<TR><TH>Input<TH>Output</TR>
<TR><TD CLASS="m4">&quot;BOOST_M4_FOR(i, 1, 3)&quot;<TD>Boost m4 script: BOOST_M4_FOR: Wrong number of arguments (3)</TR>
<TR><TD CLASS="m4">&quot;BOOST_M4_FOR(i, 1, 3, i, ` ', 13)&quot;<TD>Boost m4 script: BOOST_M4_FOR: Wrong number of arguments (6)</TR>
<TR><TD CLASS="m4">&quot;BOOST_M4_FOR(i, 7, 0, i )&quot;<TD>(nothing)</TR>
<TR><TD CLASS="m4">&quot;BOOST_M4_FOR(i, 0, 0, i )&quot;<TD>(nothing)</TR>
<TR><TD CLASS="m4">&quot;BOOST_M4_FOR(i, 0, 7, i )&quot;<TD CLASS="m4">&quot;0 1 2 3 4 5 6 &quot;</TR>
<TR><TD CLASS="m4">&quot;BOOST_M4_FOR(i, -13, -10, i )&quot;<TD CLASS="m4">&quot;-13 -12 -11 &quot;</TR>
<TR><TD CLASS="m4">&quot;BOOST_M4_FOR(i, 0, 8, BOOST_M4_FOR(j, 0, 4, (i, j) )&quot;<BR>&quot;)&quot;<TD CLASS="m4">&quot;(0, 0) (0, 1) (0, 2) (0, 3) &quot;<BR>&quot;(1, 0) (1, 1) (1, 2) (1, 3) &quot;<BR>&quot;(2, 0) (2, 1) (2, 2) (2, 3) &quot;<BR>&quot;(3, 0) (3, 1) (3, 2) (3, 3) &quot;<BR>&quot;(4, 0) (4, 1) (4, 2) (4, 3) &quot;<BR>&quot;(5, 0) (5, 1) (5, 2) (5, 3) &quot;<BR>&quot;(6, 0) (6, 1) (6, 2) (6, 3) &quot;<BR>&quot;(7, 0) (7, 1) (7, 2) (7, 3) &quot;<BR>&quot;&quot;</TR>
<TR><TD CLASS="m4">&quot;BOOST_M4_FOR(i, 7, 0, i, |)&quot;<TD>(nothing)</TR>
<TR><TD CLASS="m4">&quot;BOOST_M4_FOR(i, 0, 0, i, |)&quot;<TD>(nothing)</TR>
<TR><TD CLASS="m4">&quot;BOOST_M4_FOR(i, 0, 7, i, |)&quot;<TD CLASS="m4">&quot;0|1|2|3|4|5|6&quot;</TR>
<TR><TD CLASS="m4">&quot;BOOST_M4_FOR(i, -13, -10, i, `, ')&quot;<TD CLASS="m4">&quot;-13, -12, -11&quot;</TR>
<TR><TD CLASS="m4">&quot;BOOST_M4_FOR(i, 0, 8, `[BOOST_M4_FOR(j, 0, 4, (i, j), `, ')]', `,&quot;<BR>&quot;')&quot;<TD CLASS="m4">&quot;[(0, 0), (0, 1), (0, 2), (0, 3)],&quot;<BR>&quot;[(1, 0), (1, 1), (1, 2), (1, 3)],&quot;<BR>&quot;[(2, 0), (2, 1), (2, 2), (2, 3)],&quot;<BR>&quot;[(3, 0), (3, 1), (3, 2), (3, 3)],&quot;<BR>&quot;[(4, 0), (4, 1), (4, 2), (4, 3)],&quot;<BR>&quot;[(5, 0), (5, 1), (5, 2), (5, 3)],&quot;<BR>&quot;[(6, 0), (6, 1), (6, 2), (6, 3)],&quot;<BR>&quot;[(7, 0), (7, 1), (7, 2), (7, 3)]&quot;</TR>
</TABLE>

<P>
<HR>

<P>
Copyright &copy; 2000, 2001 Stephen Cleary (<A HREF="mailto:shammah@voyager.net">shammah@voyager.net</A>)

<P>
This file can be redistributed and/or modified under the terms found in <A HREF="../copyright.html">copyright.html</A>

<P>
This software and its documentation is provided &quot;as is&quot; without express or implied warranty, and with no claim as to its suitability for any purpose.

</BODY>
</HTML>