next up previous contents
Next: 3.1.7.3 Type Conversions Up: 3.1.7 Parameters and Values Previous: 3.1.7.1 Global Parameters


3.1.7.2 Literals

The values of built-in parameters can be written according to the following conventions:

int: Signed integer literals are written in decimal form as expected: 0; 123; -123; +123; The valid range for integer values coincidences with the range of signed integer values provided by the C++ compiler used to build the Algorithm Library.
long: Signed long integer values marked by appending ``L'' to the integer representation: 0L; 123L; -123L; +123L
double: Values of the type double have to be written either in scientific notation or by including a ``.'' which is interpreted as decimal point: 0.; .0; 1.; 1.0; 1e2; -1e2; +1e2; +1e-2
MdlBool: Boolean parameters can have two different values: true and false. It is also possible to write boolean values by using integer literals. In this case 0 is interpreted as false while all other values result in true. The Mdl prefix is used to prohibit type conflicts with various different definitions of boolean data types found in existing applications.
MdlString: MdlString literals can be written as any number of characters embedded in double quotes. Special escape sequences can be included according to the ANSI C and C++ standards:


Table 3.3: Escape sequences
Escape sequence Description
$\backslash$a bell
$\backslash$b backspace
$\backslash$f form feed
$\backslash$n newline
$\backslash$r carriage return
$\backslash$t horizontal tab
$\backslash$v vertical tab
$\backslash\backslash$ backslash
$\backslash$" double quote
$\backslash$xnn ASCII code given by a hexadecimal number nn
$\backslash$ooo ASCII code given by an octal number ooo

In Example 3.6 some typical applications of MdlString parameters are presented.

\includegraphics[width=0.6cm]{figures/exaLeft.eps}

Parameter<MdlString> message  = "Hello World! \ensuremath{\mathtt{\backslash}}n";
Parameter<MdlString> mydir    = $HOME + "/mydir";
Parameter<MdlString> ringbell = " \ensuremath{\mathtt{\backslash}}a \ensuremath{\mathtt{\backslash}}a";

Example 3.6: MdlString Parameters and literals

The values of user defined parameter types (Section 2.3.1.1) have to be surrounded by a double pair of '{{' and '}}' braces to protect them from being interpreted by the MDL interpreter. The text within these brace pairs is forwarded to the scan method of the C++ class describing the value of the Parameter.

In Example 3.7 which is an excerpt of a PROMIS-NT model class used for the definition of new quantities, the PromisQuantity {{ B active }} is assigned to the associative list quantity of the type PromisQuantityList. The key is of the type MdlString with the value "B_act". Therefore the C++ class PromisQuantity has to implement a public method scan which parses the string `` B active ''.

\includegraphics[width=0.6cm]{figures/exaLeft.eps}

// definition of a new Quantity
:quantity["B_act"] = {{ B active }};

Example 3.7: Literal notation of user defined Parameter types


next up previous contents
Next: 3.1.7.3 Type Conversions Up: 3.1.7 Parameters and Values Previous: 3.1.7.1 Global Parameters
Robert Mlekus
1999-11-14