next up previous contents
Next: UFOs - Unidentified Flying Up: GetPot Version 1.0 Powerful Previous: Input files   Contents

Prefixes

When reading out variables, options and flags in a large section tree, it can be very messy if one has to write the full variable name such as

"vehicle/tires/front/right/B"
Here, the prefix feature comes convinient. It allows to narrow the search space for arguments, variables, options and flags. Only such objects are considered that start with the given prefix. The prefix itself is then cut of the object before investigation. In specific this prefix can be a section name, so that a code fragment like

...
    front_tire.B = ifile("vehicle/tires/front/right/B", 0.);
    front_tire.C = ifile("vehicle/tires/front/right/C", 0.);
    front_tire.D = ifile("vehicle/tires/front/right/D", 0.);
    front_tire.E = ifile("vehicle/tires/front/right/E", 0.);
...
can be rewritten as
...
    ifile.set_prefix("vehicle/tires/front/right/")
    front_tire.B = ifile("B", 0.);
    front_tire.C = ifile("C", 0.);
    front_tire.D = ifile("D", 0.);
    front_tire.E = ifile("E", 0.);
...
which is, of course, much more readable. However, one should not forget to set or reset the prefix to the correspondent section (such as "" for the root section).



Frank-Rene Schaefer 2002-09-14