4 Copyright (c) 2002-2003 The Trustees of Indiana University.
6 Copyright (c) 2000-2001 University of Notre Dame. All rights reserved.
8 Distributed under the Boost Software License, Version 1.0.
9 (See accompanying file LICENSE_1_0.txt or copy at
10 http://www.boost.org/LICENSE_1_0.txt)
13 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
14 <xsl:strip-space elements="* xsl:*"/>
16 <xsl:include href="unparser.xsl"/>
18 <xsl:key name="concepts" match="concept" use="@name"/>
20 <!-- The layout type to use for concept descriptions. Can be one of:
21 sgi: simulate the SGI STL documentation
22 austern: simulate the documentation in Generic Programming and the STL,
24 caramel: simulate the formatting from Caramel
26 <xsl:param name="boost.concept.layout" select="'austern'"/>
28 <xsl:template match="concept">
30 <xsl:attribute name="id">
31 <xsl:call-template name="generate.id"/>
35 <refentrytitle>Concept <xsl:value-of select="@name"/></refentrytitle>
36 <manvolnum>7</manvolnum>
40 <refname><xsl:value-of select="@name"/></refname>
41 <xsl:if test="purpose">
43 <xsl:apply-templates select="purpose/*|purpose/text()"/>
50 <xsl:for-each select="copyright | copyright-include | legalnotice">
52 <xsl:when test="name(.)='copyright'">
53 <copyright><xsl:copy-of select="./node()"/></copyright>
55 <xsl:when test="name(.)='legalnotice'">
56 <legalnotice><xsl:copy-of select="./node()"/></legalnotice>
58 <xsl:when test="name(.)='copyright-include'">
59 <copyright><xsl:copy-of select="document(concat('../concepts/', @file))/copyright/node()"/></copyright>
66 <xsl:if test="description">
67 <xsl:if test="description">
69 <title>Description</title>
70 <xsl:for-each select="description">
71 <xsl:apply-templates/>
77 <xsl:if test="refines | refines-when-mutable">
79 <title>Refinement of</title>
81 <xsl:if test="refines">
82 <xsl:for-each select="refines">
85 <xsl:call-template name="concept.link">
86 <xsl:with-param name="name" select="@concept"/>
92 <xsl:if test="refines-when-mutable">
93 <xsl:for-each select="refines-when-mutable">
96 <xsl:text>When mutable: </xsl:text>
97 <xsl:call-template name="concept.link">
98 <xsl:with-param name="name" select="@concept"/>
108 <!-- This part must be run even if there are no associated types to print out, so the hidden type definitions can be found -->
109 <xsl:variable name="definition_list">
110 <xsl:call-template name="make-definition-list">
111 <xsl:with-param name="typedefs" select="define-type | associated-type"/>
112 <xsl:with-param name="definition_list">
113 <xsl:for-each select="param/@name">
114 @(@<xsl:value-of select="."/>=<xsl:value-of select="."/>@)@
120 <!-- <xsl:message>Definition list: <xsl:value-of select="$definition_list"/></xsl:message> -->
122 <xsl:call-template name="print-associated-types">
123 <xsl:with-param name="typedefs" select="associated-type"/>
124 <xsl:with-param name="definition_list" select="$definition_list"/>
127 <xsl:call-template name="concept.notation">
128 <xsl:with-param name="definition_list" select="$definition_list"/>
131 <xsl:variable name="notations">
132 <xsl:for-each select="notation">
133 @@(@@<xsl:call-template name="unparse-cpp">
134 <xsl:with-param name="typeref" select="*[1]"/>
135 <xsl:with-param name="definition_list" select="$definition_list"/>
136 <xsl:with-param name="ignore-cv" select="true()"/>
137 <xsl:with-param name="ignore-references" select="true()"/>
138 </xsl:call-template>@@=@@<xsl:value-of select="normalize-space(@variables)"/>@@)@@
142 <!-- <xsl:message>Notations: <xsl:value-of select="normalize-space($notations)"/> End notations</xsl:message> -->
144 <xsl:if test="definition">
146 <title>Definitions</title>
147 <xsl:for-each select="definition">
148 <p><xsl:apply-templates/></p>
153 <xsl:if test="valid-type-expression | models | models-when-mutable">
155 <title>Type expressions</title>
157 <xsl:for-each select="models">
162 <xsl:call-template name="unparse-operator-definition">
163 <xsl:with-param name="typeref" select="."/>
164 <xsl:with-param name="operator_nodeset" select="key('concepts', @concept)/models-sentence/node()"/>
165 <xsl:with-param name="definition_list" select="$definition_list"/>
166 <xsl:with-param name="notations" select="$notations"/>
167 <xsl:with-param name="ignore-cv" select="false()"/>
168 <xsl:with-param name="self" select="@concept"/>
169 <xsl:with-param name="use-code-block" select="true()"/>
175 <xsl:for-each select="models-when-mutable">
177 <term>Only when mutable</term>
180 <xsl:call-template name="unparse-operator-definition">
181 <xsl:with-param name="typeref" select="."/>
182 <xsl:with-param name="operator_nodeset" select="key('concepts', @concept)/models-sentence/node()"/>
183 <xsl:with-param name="definition_list" select="$definition_list"/>
184 <xsl:with-param name="notations" select="$notations"/>
185 <xsl:with-param name="ignore-cv" select="false()"/>
186 <xsl:with-param name="self" select="@concept"/>
187 <xsl:with-param name="use-code-block" select="true()"/>
193 <xsl:for-each select="valid-type-expression">
195 <term><xsl:value-of select="@name"/></term>
199 <xsl:call-template name="unparse-cpp">
200 <xsl:with-param name="typeref" select="*[2]"/>
201 <xsl:with-param name="definition_list" select="$definition_list"/>
202 <xsl:with-param name="notations" select="normalize-space($notations)"/>
206 <xsl:comment/> must be
207 <xsl:for-each select="return-type/*">
208 <xsl:if test="position()!=1 and last()!=2">, </xsl:if>
209 <xsl:if test="position()=last() and last()!=1"> and </xsl:if>
210 <xsl:call-template name="unparse-constraint">
211 <xsl:with-param name="constraint" select="."/>
212 <xsl:with-param name="definition_list" select="$definition_list"/>
213 <xsl:with-param name="type-expr-mode" select="true()"/>
215 </xsl:for-each><xsl:comment/>.
218 <xsl:if test="description">
219 <xsl:for-each select="description">
220 <xsl:apply-templates/>
230 <xsl:if test="valid-expression">
232 <title>Valid expressions</title>
234 <xsl:variable name="columns">
235 <xsl:if test="valid-expression/return-type">
236 <xsl:text>T</xsl:text>
238 <xsl:if test="valid-expression/precondition">
239 <xsl:text>P</xsl:text>
241 <xsl:if test="valid-expression/semantics">
242 <xsl:text>S</xsl:text>
244 <xsl:if test="valid-expression/postcondition">
245 <xsl:text>O</xsl:text>
251 <xsl:attribute name="cols">
252 <xsl:value-of select="string-length($columns) + 2"/>
257 <entry>Expression</entry>
258 <xsl:if test="contains($columns, 'T')">
261 <xsl:if test="contains($columns, 'P')">
262 <entry>Precondition</entry>
264 <xsl:if test="contains($columns, 'S')">
265 <entry>Semantics</entry>
267 <xsl:if test="contains($columns, 'O')">
268 <entry>Postcondition</entry>
273 <xsl:apply-templates select="valid-expression">
274 <xsl:with-param name="definition_list"
275 select="$definition_list"/>
276 <xsl:with-param name="notations"
277 select="normalize-space($notations)"/>
278 <xsl:with-param name="columns" select="$columns"/>
279 </xsl:apply-templates>
283 <!-- Doug prefers the table
285 <xsl:for-each select="valid-expression">
286 <xsl:variable name="as-cxx-value">
287 <xsl:call-template name="unparse-cpp">
288 <xsl:with-param name="typeref" select="*[1]"/>
289 <xsl:with-param name="definition_list" select="$definition_list"/>
290 <xsl:with-param name="notations" select="normalize-space($notations)"/>
294 <term><xsl:value-of select="@name"/>: <literal><xsl:value-of select="$as-cxx-value"/></literal></term>
295 <listitem><variablelist>
296 <xsl:if test="return-type/*">
297 <varlistentry><term>Return value</term><listitem><para>
298 <xsl:for-each select="return-type/*">
299 <xsl:if test="position()!=1 and last()!=2">, </xsl:if>
300 <xsl:if test="position()=last() and last()!=1"> and </xsl:if>
301 <xsl:call-template name="unparse-constraint">
302 <xsl:with-param name="constraint" select="."/>
303 <xsl:with-param name="definition_list" select="$definition_list"/>
304 <xsl:with-param name="capitalize" select="position()=1"/>
307 </para></listitem></varlistentry>
310 <xsl:for-each select="precondition">
311 <varlistentry><term>Precondition</term><listitem><para>
312 <xsl:apply-templates/>
313 </para></listitem></varlistentry>
316 <xsl:for-each select="semantics">
317 <varlistentry><term>Semantics</term><listitem><para>
318 <xsl:apply-templates/>
319 </para></listitem></varlistentry>
322 <xsl:for-each select="postcondition">
323 <varlistentry><term>Postcondition</term><listitem><para>
324 <xsl:apply-templates/>
325 </para></listitem></varlistentry>
328 </variablelist></listitem>
337 <xsl:if test="complexity">
339 <title>Complexity</title>
340 <xsl:for-each select="complexity">
341 <para><xsl:apply-templates/></para>
346 <xsl:if test="invariant">
348 <title>Invariants</title>
350 <xsl:for-each select="invariant">
352 <term><xsl:value-of select="@name"/></term>
354 <para><xsl:apply-templates/></para>
362 <xsl:if test="example-model">
364 <title>Models</title>
366 <xsl:for-each select="example-model">
368 <simplelist type="inline">
369 <xsl:for-each select="*">
370 <xsl:variable name="example-value">
371 <xsl:call-template name="unparse-cpp">
372 <xsl:with-param name="typeref" select="."/>
373 <xsl:with-param name="definition_list" select="$definition_list"/>
376 <member><type><xsl:value-of select="$example-value"/></type></member>
385 <xsl:variable name="see-also-list-0" select="concept-ref | see-also | refines | refines-when-mutable | models-as-first-arg | models | models-when-mutable"/>
386 <xsl:variable name="see-also-list-1" select="$see-also-list-0[string(@name | @concept) != string(../@name)]"/>
387 <xsl:variable name="see-also-list" select="$see-also-list-1[not(string(@name|@concept) = (preceding::*/@name | preceding::*/@concept | ancestor::*/@name | ancestor::*/@concept))]"/>
388 <xsl:if test="$see-also-list">
390 <title>See also</title>
392 <xsl:for-each select="$see-also-list">
393 <xsl:sort select="string(@name|@concept)" data-type="text"/>
396 <xsl:call-template name="concept.link">
397 <xsl:with-param name="name" select="@name|@concept"/>
409 <xsl:template name="unparse-constraint">
410 <xsl:param name="constraint"/>
411 <xsl:param name="definition_list"/>
412 <xsl:param name="type-expr-mode" select="false()"/>
413 <xsl:param name="capitalize" select="true()"/>
417 <xsl:when test="name($constraint)='require-same-type'">
418 <xsl:if test="$type-expr-mode">identical to </xsl:if>
420 <xsl:call-template name="unparse-cpp">
421 <xsl:with-param name="typeref" select="$constraint/*[1]"/>
422 <xsl:with-param name="definition_list" select="definition_list"/>
427 <xsl:when test="name($constraint)='convertible-to'">
429 <xsl:when test="$type-expr-mode">convertible to </xsl:when>
430 <xsl:when test="not($type-expr-mode) and $capitalize">Convertible to </xsl:when>
431 <xsl:when test="not($type-expr-mode) and not($capitalize)">convertible to </xsl:when>
434 <xsl:call-template name="unparse-cpp">
435 <xsl:with-param name="typeref" select="$constraint/*[1]"/>
436 <xsl:with-param name="definition_list" select="definition_list"/>
441 <xsl:when test="name($constraint)='derived-from'">
443 <xsl:when test="$type-expr-mode">derived from </xsl:when>
444 <xsl:when test="not($type-expr-mode) and $capitalize">Derived from </xsl:when>
445 <xsl:when test="not($type-expr-mode) and not($capitalize)">derived from </xsl:when>
448 <xsl:call-template name="unparse-cpp">
449 <xsl:with-param name="typeref" select="$constraint/*[1]"/>
450 <xsl:with-param name="definition_list" select="definition_list"/>
455 <xsl:when test="name($constraint)='assignable-to'">
457 <xsl:when test="$type-expr-mode">assignable to </xsl:when>
458 <xsl:when test="not($type-expr-mode) and $capitalize">Assignable to </xsl:when>
459 <xsl:when test="not($type-expr-mode) and not($capitalize)">assignable to </xsl:when>
462 <xsl:call-template name="unparse-cpp">
463 <xsl:with-param name="typeref" select="$constraint/*[1]"/>
464 <xsl:with-param name="definition_list" select="definition_list"/>
469 <xsl:when test="name($constraint)='models-as-first-arg'">
471 <xsl:when test="$type-expr-mode"> a model </xsl:when>
472 <xsl:when test="not($type-expr-mode) and $capitalize"> Models </xsl:when>
473 <xsl:when test="not($type-expr-mode) and not($capitalize)"> models </xsl:when>
475 <xsl:if test="$constraint/*"><xsl:comment/>
476 (along with <xsl:for-each select="$constraint/*"><type>
477 <xsl:call-template name="unparse-cpp">
478 <xsl:with-param name="typeref" select="."/>
479 <xsl:with-param name="definition_list" select="definition_list"/>
483 <xsl:when test="position()=last()"/>
484 <xsl:when test="position()=last()-1 and last()=2"> and </xsl:when>
485 <xsl:when test="position()=last()-1 and last()!=2">, and </xsl:when>
486 <xsl:otherwise>, </xsl:otherwise>
487 </xsl:choose><xsl:comment/>
488 </xsl:for-each><xsl:comment/>) <xsl:comment/>
489 </xsl:if><xsl:comment/>
490 <xsl:if test="$type-expr-mode"> of </xsl:if>
491 <xsl:call-template name="concept.link">
492 <xsl:with-param name="name" select="$constraint/@concept"/>
499 <xsl:template name="make-definition-list">
500 <xsl:param name="typedefs"/>
501 <xsl:param name="definition_list"/>
504 <xsl:when test="$typedefs">
505 <xsl:variable name="type_definition">
506 <xsl:if test="name($typedefs[1]/*[1])!='description'">
507 <xsl:call-template name="unparse-cpp">
508 <xsl:with-param name="typeref" select="$typedefs[1]/*[1]"/>
509 <xsl:with-param name="definition_list" select="$definition_list"/>
514 <xsl:variable name="new_type_definition">
516 <xsl:when test="name($typedefs[1])='associated-type'">
517 <xsl:value-of select="$typedefs[1]/@name"/>
520 <xsl:value-of select="$type_definition"/>
525 <xsl:call-template name="make-definition-list">
526 <xsl:with-param name="typedefs" select="$typedefs[position()!=1]"/>
527 <xsl:with-param name="definition_list" select="concat($definition_list, ' @(@', $typedefs[1]/@name, '=', $new_type_definition, '@)@')"/>
532 <xsl:otherwise> <!-- End of expression list, emit the results that have accumulated -->
533 <xsl:value-of select="$definition_list"/>
538 <xsl:template name="print-associated-types">
539 <xsl:param name="typedefs"/>
540 <xsl:param name="definition_list"/>
542 <xsl:if test="$typedefs">
544 <title>Associated types</title>
547 <xsl:when test="$boost.concept.layout='sgi'">
551 <xsl:apply-templates select="associated-type" mode="sgi">
552 <xsl:with-param name="definition_list"
553 select="$definition_list"/>
554 </xsl:apply-templates>
559 <xsl:when test="$boost.concept.layout='austern'">
561 <xsl:apply-templates select="associated-type" mode="austern">
562 <xsl:with-param name="definition_list"
563 select="$definition_list"/>
564 </xsl:apply-templates>
567 <xsl:when test="$boost.concept.layout='caramel'">
569 <segtitle>Name</segtitle>
570 <segtitle>Code</segtitle>
571 <segtitle>Description</segtitle>
572 <xsl:for-each select="$typedefs">
573 <xsl:variable name="type_definition">
574 <xsl:call-template name="unparse-cpp">
575 <xsl:with-param name="typeref" select="*[1]"/>
576 <xsl:with-param name="definition_list" select="$definition_list"/>
580 <seg><xsl:value-of select="@name"/></seg>
581 <seg><xsl:value-of select="$type_definition"/></seg>
583 <xsl:for-each select="description">
584 <xsl:call-template name="description"/>
596 <xsl:template name="comma-list">
597 <xsl:param name="list"/>
599 <xsl:if test="$list!=''">
601 <xsl:if test="substring-before($list,' ')=''"><xsl:value-of select="$list"/></xsl:if>
602 <xsl:value-of select="substring-before($list,' ')"/>
604 <xsl:call-template name="comma-list">
605 <xsl:with-param name="list" select="substring-after($list,' ')"/>
610 <xsl:template match="associated-type" mode="sgi">
612 <entry><simpara><xsl:value-of select="@name"/></simpara></entry>
616 <xsl:for-each select="description">
617 <xsl:apply-templates/>
624 <xsl:template match="associated-type" mode="austern">
625 <xsl:param name="definition_list" select="''"/>
629 <emphasis role="bold"><xsl:value-of select="@name"/></emphasis>
631 <xsl:call-template name="preformatted">
632 <xsl:with-param name="text">
633 <xsl:call-template name="unparse-cpp">
634 <xsl:with-param name="typeref" select="*[1]"/>
635 <xsl:with-param name="definition_list" select="$definition_list"/>
640 <xsl:for-each select="description">
641 <xsl:apply-templates/>
647 <xsl:template match="valid-expression">
648 <xsl:param name="definition_list"/>
649 <xsl:param name="notations"/>
650 <xsl:param name="columns"/>
653 <entry><simpara><xsl:value-of select="@name"/></simpara></entry>
657 <xsl:call-template name="unparse-cpp">
658 <xsl:with-param name="typeref" select="*[1]"/>
659 <xsl:with-param name="definition_list" select="$definition_list"/>
660 <xsl:with-param name="notations" select="$notations"/>
665 <xsl:if test="contains($columns, 'T')">
668 <xsl:for-each select="return-type/*">
669 <xsl:if test="position()!=1 and last()!=2">, </xsl:if>
670 <xsl:if test="position()=last() and last()!=1"> and </xsl:if>
671 <xsl:call-template name="unparse-constraint">
672 <xsl:with-param name="constraint" select="."/>
673 <xsl:with-param name="definition_list"
674 select="$definition_list"/>
675 <xsl:with-param name="capitalize" select="position()=1"/>
682 <xsl:if test="contains($columns, 'P')">
684 <xsl:for-each select="precondition">
685 <simpara><xsl:apply-templates/></simpara>
690 <xsl:if test="contains($columns, 'S')">
692 <xsl:for-each select="semantics">
693 <simpara><xsl:apply-templates/></simpara>
698 <xsl:if test="contains($columns, 'O')">
700 <xsl:for-each select="postcondition">
701 <simpara><xsl:apply-templates/></simpara>
708 <xsl:template name="concept.notation">
709 <xsl:param name="definition_list"/>
712 <title>Notation</title>
714 <xsl:for-each select="param">
716 <term><xsl:value-of select="@name"/></term>
719 <xsl:text>A type playing the role of </xsl:text>
720 <xsl:value-of select="@role"/>
721 <xsl:text> in the </xsl:text>
722 <xsl:call-template name="concept.link">
723 <xsl:with-param name="name" select="../@name"/>
725 <xsl:text> concept.</xsl:text>
730 <xsl:for-each select="notation">
731 <xsl:variable name="notation_name">
732 <xsl:call-template name="comma-list">
733 <xsl:with-param name="list"
734 select="normalize-space(@variables)"/>
739 <xsl:copy-of select="$notation_name"/>
742 <xsl:variable name="output-plural" select="substring-before(normalize-space(@variables),' ')!=''"/>
743 <xsl:if test="name(*[1])='sample-value'">Object<xsl:if test="$output-plural">s</xsl:if> of type </xsl:if>
744 <xsl:variable name="typeref-to-print" select="*[name()!='sample-value'] | sample-value/*[name()!='sample-value']"/>
745 <xsl:call-template name="unparse-cpp">
746 <xsl:with-param name="typeref" select="$typeref-to-print"/>
747 <xsl:with-param name="definition_list" select="$definition_list"/>
748 <xsl:with-param name="ignore-cv" select="true()"/>
749 <xsl:with-param name="ignore-references" select="true()"/>
759 <xsl:template name="concept.link">
760 <xsl:param name="name" select="text()"/>
761 <xsl:param name="warn" select="true()"/>
762 <xsl:param name="text" select="$name"/>
763 <xsl:variable name="node" select="key('concepts', $name)"/>
766 <xsl:when test="count($node)=0">
767 <xsl:if test="$warn">
769 <xsl:text>warning: cannot find concept '</xsl:text>
770 <xsl:value-of select="$name"/>
771 <xsl:text>'</xsl:text>
774 <xsl:value-of select="$text"/>
777 <xsl:call-template name="internal-link">
778 <xsl:with-param name="to">
779 <xsl:call-template name="generate.id">
780 <xsl:with-param name="node" select="$node"/>
783 <xsl:with-param name="text" select="$text"/>
789 <xsl:template name="remove-whitespace">
790 <xsl:param name="text" select="text()"/>
792 <xsl:variable name="normalized" select="normalize-space($text)"/>
794 <xsl:when test="contains($normalized, ' ')">
795 <xsl:value-of select="substring-before($normalized, ' ')"/>
796 <xsl:call-template name="remove-whitespace">
797 <xsl:with-param name="text"
798 select="substring-after($normalized, ' ')"/>
802 <xsl:value-of select="$normalized"/>
807 <xsl:template match="concept" mode="generate.id">
808 <xsl:call-template name="remove-whitespace">
809 <xsl:with-param name="text" select="@name"/>