2015-03-18 11:31:47 -04:00
|
|
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
2015-03-18 13:32:24 -04:00
|
|
|
<!--
|
2019-02-07 13:23:09 -05:00
|
|
|
Copyright (C) 2014-2019 Ryan Specialty Group, LLC.
|
2015-03-18 13:32:24 -04:00
|
|
|
|
|
|
|
This file is part of tame-core.
|
|
|
|
|
|
|
|
tame-core is free software: you can redistribute it and/or modify it
|
2018-01-26 11:13:33 -05:00
|
|
|
under the terms of the GNU General Public License as
|
2015-03-18 13:32:24 -04:00
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
-->
|
2015-03-18 11:31:47 -04:00
|
|
|
<package xmlns="http://www.lovullo.com/rater"
|
2013-02-13 09:27:33 -05:00
|
|
|
xmlns:c="http://www.lovullo.com/calc"
|
|
|
|
core="true"
|
|
|
|
desc="Generic conditionals">
|
|
|
|
|
2015-03-18 11:31:47 -04:00
|
|
|
<import package="base" />
|
2013-02-13 09:27:33 -05:00
|
|
|
|
|
|
|
|
|
|
|
<!-- TODO: use reduce once we have support for function passing -->
|
2015-03-18 11:31:47 -04:00
|
|
|
<function name="or" desc="Return value A if non-zero, otherwise B">
|
|
|
|
<param name="or_a" type="float" desc="Value to return if non-zero" />
|
|
|
|
<param name="or_b" type="float" desc="Value to return if A is zero" />
|
2013-02-13 09:27:33 -05:00
|
|
|
|
|
|
|
<c:cases>
|
|
|
|
<!-- return B if A is zero -->
|
|
|
|
<c:case>
|
|
|
|
<c:when name="or_a">
|
|
|
|
<c:eq>
|
|
|
|
<c:const value="0" type="integer" desc="Return B if A is 0" />
|
|
|
|
</c:eq>
|
|
|
|
</c:when>
|
|
|
|
|
|
|
|
<c:value-of name="or_b" />
|
|
|
|
</c:case>
|
|
|
|
|
|
|
|
<!-- return A if non-zero -->
|
|
|
|
<c:otherwise>
|
|
|
|
<c:value-of name="or_a" />
|
|
|
|
</c:otherwise>
|
|
|
|
</c:cases>
|
2015-03-18 11:31:47 -04:00
|
|
|
</function>
|
2013-02-13 09:27:33 -05:00
|
|
|
|
|
|
|
|
2015-03-18 11:31:47 -04:00
|
|
|
<template name="_cond_" desc="Conditional shorthand">
|
|
|
|
<param name="@name@" desc="Value to check" />
|
|
|
|
<param name="@index@" desc="Index of boolean value" />
|
|
|
|
<param name="@value@" desc="Constant value" />
|
|
|
|
<param name="@type@" desc="Value type" />
|
2013-02-13 09:27:33 -05:00
|
|
|
|
2015-03-18 11:31:47 -04:00
|
|
|
<param name="@cond@" desc="Value to compare against (default boolean true)">
|
|
|
|
<text>TRUE</text>
|
|
|
|
</param>
|
2013-02-13 09:27:33 -05:00
|
|
|
|
2015-03-18 11:31:47 -04:00
|
|
|
<param name="@desc@" desc="Value description">
|
|
|
|
<text>Value when </text>
|
|
|
|
<param-value name="@name@" />
|
|
|
|
</param>
|
2013-02-13 09:27:33 -05:00
|
|
|
|
|
|
|
<c:const value="@value@" type="@type@" desc="@desc@">
|
|
|
|
<!-- TODO: non-index option -->
|
|
|
|
<c:when name="@name@" index="@index@">
|
|
|
|
<c:eq>
|
|
|
|
<c:value-of name="@cond@" />
|
|
|
|
</c:eq>
|
|
|
|
</c:when>
|
|
|
|
</c:const>
|
2015-03-18 11:31:47 -04:00
|
|
|
</template>
|
2013-02-13 09:27:33 -05:00
|
|
|
|
|
|
|
|
2015-03-18 11:31:47 -04:00
|
|
|
<template name="_yield-unless_" desc="Yield a value unless another value is set">
|
|
|
|
<param name="@name@" desc="Overriding value" />
|
|
|
|
<param name="@index@" desc="Index" />
|
|
|
|
<param name="@values@" desc="Value to use otherwise" />
|
2013-02-13 09:27:33 -05:00
|
|
|
|
|
|
|
<c:cases>
|
|
|
|
<c:case>
|
2015-03-18 11:31:47 -04:00
|
|
|
<if name="@index@">
|
2013-02-13 09:27:33 -05:00
|
|
|
<c:when name="@name@" index="@index@">
|
|
|
|
<c:gt>
|
|
|
|
<c:const value="0" type="integer" desc="Use override if greater than 0" />
|
|
|
|
</c:gt>
|
|
|
|
</c:when>
|
2015-03-18 11:31:47 -04:00
|
|
|
</if>
|
|
|
|
<unless name="@index@">
|
2013-02-13 09:27:33 -05:00
|
|
|
<c:when name="@name@">
|
|
|
|
<c:gt>
|
|
|
|
<c:const value="0" type="integer" desc="Use override if greater than 0" />
|
|
|
|
</c:gt>
|
|
|
|
</c:when>
|
2015-03-18 11:31:47 -04:00
|
|
|
</unless>
|
2013-02-13 09:27:33 -05:00
|
|
|
|
2015-03-18 11:31:47 -04:00
|
|
|
<if name="@index@">
|
2013-02-13 09:27:33 -05:00
|
|
|
<c:value-of name="@name@" index="@index@" />
|
2015-03-18 11:31:47 -04:00
|
|
|
</if>
|
|
|
|
<unless name="@index@">
|
2013-02-13 09:27:33 -05:00
|
|
|
<c:value-of name="@name@" />
|
2015-03-18 11:31:47 -04:00
|
|
|
</unless>
|
2013-02-13 09:27:33 -05:00
|
|
|
</c:case>
|
|
|
|
|
|
|
|
<c:otherwise>
|
2015-03-18 11:31:47 -04:00
|
|
|
<param-copy name="@values@" />
|
2013-02-13 09:27:33 -05:00
|
|
|
</c:otherwise>
|
|
|
|
</c:cases>
|
2015-03-18 11:31:47 -04:00
|
|
|
</template>
|
2013-02-13 09:27:33 -05:00
|
|
|
|
|
|
|
|
2015-03-18 11:31:47 -04:00
|
|
|
<template name="_default_" desc="Set a default value if a value is not set">
|
|
|
|
<param name="@name@" desc="Param name" />
|
|
|
|
<param name="@index@" desc="Index" />
|
|
|
|
<param name="@default@" desc="Default value to use if empty" />
|
2013-02-13 09:27:33 -05:00
|
|
|
|
|
|
|
<c:cases>
|
|
|
|
<c:case>
|
|
|
|
<c:when name="@name@" index="@index@">
|
|
|
|
<c:eq>
|
|
|
|
<c:const value="0" type="integer" desc="No value" />
|
|
|
|
</c:eq>
|
|
|
|
</c:when>
|
|
|
|
|
|
|
|
<c:const value="@default@" type="integer" desc="Default value" />
|
|
|
|
</c:case>
|
|
|
|
|
|
|
|
<c:otherwise>
|
|
|
|
<c:value-of name="@name@" index="@index@" />
|
|
|
|
</c:otherwise>
|
|
|
|
</c:cases>
|
2015-03-18 11:31:47 -04:00
|
|
|
</template>
|
2013-02-13 09:27:33 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
2015-03-18 11:31:47 -04:00
|
|
|
<template name="_cond-value-each_" desc="Conditional value">
|
|
|
|
<param name="@class@" desc="Class match" />
|
|
|
|
<param name="@generates@" desc="Variable to generate into" />
|
|
|
|
<param name="@value@" desc="Value to yield (use either this or const)" />
|
|
|
|
<param name="@const@" desc="Constant to yield (use either this or value)" />
|
|
|
|
<param name="@count@" desc="Optional number of times to apply const/value (as a variable)" />
|
2013-02-13 09:27:33 -05:00
|
|
|
|
2015-03-18 11:31:47 -04:00
|
|
|
<param name="@desc@" desc="Optional constant description">
|
|
|
|
<text>Constant value</text>
|
|
|
|
</param>
|
2013-02-13 09:27:33 -05:00
|
|
|
|
|
|
|
<!-- simply returns a constant value for the class match -->
|
2015-03-18 11:31:47 -04:00
|
|
|
<rate-each class="@class@" accumulate="none" generates="@generates@" index="k">
|
2013-02-13 09:27:33 -05:00
|
|
|
<c:product>
|
2015-03-18 11:31:47 -04:00
|
|
|
<if name="@value@">
|
2013-02-13 09:27:33 -05:00
|
|
|
<c:value-of name="@value@" />
|
2015-03-18 11:31:47 -04:00
|
|
|
</if>
|
|
|
|
<unless name="@value@">
|
2013-02-13 09:27:33 -05:00
|
|
|
<c:const value="@const@" type="float" desc="@desc@" />
|
2015-03-18 11:31:47 -04:00
|
|
|
</unless>
|
2013-02-13 09:27:33 -05:00
|
|
|
|
|
|
|
<!-- if this is not provided, then the c:product will be optimized away -->
|
2015-03-18 11:31:47 -04:00
|
|
|
<if name="@count@">
|
2013-02-13 09:27:33 -05:00
|
|
|
<c:value-of name="@count@" index="k" />
|
2015-03-18 11:31:47 -04:00
|
|
|
</if>
|
2013-02-13 09:27:33 -05:00
|
|
|
</c:product>
|
2015-03-18 11:31:47 -04:00
|
|
|
</rate-each>
|
|
|
|
</template>
|
|
|
|
</package>
|
|
|
|
|