next up previous contents
Next: String Operations Up: GetPot Version 1.0 Powerful Previous: Unidentified Nominuses   Contents

Dollar Bracket Expressions

Since version 1.0 the GetPot parser provides a sophisticated function to handle several arithmetic and string operations. In some cases this can significantly facilitate the writing of a configuration file. The so called dollar bracket expressions constitute a very simple lisp-like language. Instead of using normal brackets, it uses dollar brackets to embrace an expression. For example

...
      a = ${+ 1 1}
      b = ${<-> Phillip Ph F}
...
will result assign "2" to the variable a and "Fillip" to variable b. Dollar bracket expressions can, of course be nested and they allow conditional assignments. However, iteration, or even recursion is purposely not implemented. This is, in order to avoid possible unwanted infinite iterations/recursions caused by the writer of the configuration file6. An overview over all operators is provided in table 1. Please, note that you do not have to use any of those to write GetPot configuration files. Simply start using them when you need them.


Table 1: Total set of dollar bracket operators.
String operations
${string} variable replacement
${:string} pure string (no parsing inside)
${& string1 string2 string3 ...} concatenation
${<-> string original replacement} string replacement
Arithmetic operations
${+ arg1 arg2 arg3 ...} plus
${* arg1 arg2 arg3 ...} multiplication
${- arg1 arg2 arg3 ...} subtraction
${/ arg1 arg2 arg3 ...} division
${^ arg1 arg2 arg3 ...} power
Comparisons
${== arg0 arg1 arg2 ...} equal
${> arg0 arg1 arg2 ...} greater
${< arg0 arg1 arg2 ...} less
${>= arg0 arg1 arg2 ...} greater or equal
${<= arg0 arg1 arg2 ...} less or equal
Conditions
${? arg0 arg1 arg2} if-then
${?? arg0 arg1 arg2 ...} choice
Vector/String subscriptions
${@: string index0} specific letter in string
${@: string index0 index1} substring in string
${@ variable index0} specific element in vector variable
${@ variable index0 index1} sub-vector in vector variable
Macros
${! string} macro expansion




Subsections
next up previous contents
Next: String Operations Up: GetPot Version 1.0 Powerful Previous: Unidentified Nominuses   Contents
Frank-Rene Schaefer 2002-09-14