Classes | Functions
contrib/mul/mbl/mbl_read_props.h File Reference

Load properties from text files Along with mbl_parse_block, the functions in this file allow you to quickly parse hierarchical property files that look like: More...

#include <vcl_map.h>
#include <vcl_iosfwd.h>
#include <vcl_string.h>

Go to the source code of this file.

Classes

class  mbl_read_props_type
 The type of the property dictionary. More...

Functions

mbl_read_props_type mbl_read_props (vcl_istream &afs)
 Read properties from a text stream.
mbl_read_props_type mbl_read_props_ws (vcl_istream &afs)
 Read properties from a text stream.
void mbl_read_props_print (vcl_ostream &afs, mbl_read_props_type props)
 Print a list of properties for debugging purposes.
void mbl_read_props_print (vcl_ostream &afs, mbl_read_props_type props, unsigned max_chars)
 Print a list of properties for debugging purposes. Limit each property value length to max_chars.
mbl_read_props_type mbl_read_props_merge (const mbl_read_props_type &first, const mbl_read_props_type &second, bool first_overrides=true)
 merge two property sets.
void mbl_read_props_look_for_unused_props (const vcl_string &function_name, const mbl_read_props_type &props, const mbl_read_props_type &ignore)
 Throw error if there are any keys in props that aren't in ignore.
void mbl_read_props_look_for_unused_props (const vcl_string &function_name, const mbl_read_props_type &props)
 Throw error if there are any keys in props.

Detailed Description

Load properties from text files Along with mbl_parse_block, the functions in this file allow you to quickly parse hierarchical property files that look like:

Author:
Ian Scott
Date:
14-Aug-2001
   {
     n_disp_dx: 3
     n_synth_targets: 30
     parameter_displacements:
     {
      0 1 2 3
     }
     rfunc: m32_simple_residual_function
     {
       model:
       {
         apm_filepath: ../hip_cropped_lres.apm
         background_filepath: gen:100x50x80:vxl_int_32:0
         foobar_modifier: foobar_strategy3
       }
       comparator:
       {
         type: comparator_strategy2
         initial_geometry:
         {
           centre_of_source: 0 -1000 0
           centre_of_image_plane: 0 300 0
         }
       }
       comparator:
       {
         type: comparator_strategy2
         initial_geometry:
         {
           centre_of_source: 860.365 -1228.73 0
           centre_of_image_plane: -172.073 245.746 0
         }
       }
     }
   }
   

Definition in file mbl_read_props.h.


Function Documentation

mbl_read_props_type mbl_read_props ( vcl_istream &  afs)

Read properties from a text stream.

The function will terminate on an eof. If one of the opening lines contains an opening brace '{', then the function will also stop reading the stream after finding a line containing a closing brace '}'

There should be one property per line, with a colon ':' after each property label. Each property label should not contain any whitespace. However, property values may contain white space they are assumed to be terminated by an end-of-line.

Differs from mbl_read_props_ws(afs) in that it treats everything after the label up to the end-of-line as the value. Thus it treats the single line "a: a b: b" as containing a single label ("a:") with value "a b: b". If you want such a line treated as two label-values, use mbl_read_props_ws()

The function will terminate on an eof. If one of the opening lines contains an opening brace '{', then the function will also stop reading the stream after finding a line containing a closing brace '}'

There should be one property per line, with a colon ':' after each property label. The remainder of that line is the property value. If the next line begins with a brace, the following text up to matching braces is included in the property value. Each property label should not contain any whitespace.

Definition at line 94 of file mbl_read_props.cxx.

void mbl_read_props_look_for_unused_props ( const vcl_string &  function_name,
const mbl_read_props_type props,
const mbl_read_props_type ignore 
)

Throw error if there are any keys in props that aren't in ignore.

Exceptions:
mbl_exception_unused_props

Definition at line 469 of file mbl_read_props.cxx.

void mbl_read_props_look_for_unused_props ( const vcl_string &  function_name,
const mbl_read_props_type props 
) [inline]

Throw error if there are any keys in props.

Exceptions:
mbl_exception_unused_props

Definition at line 135 of file mbl_read_props.h.

mbl_read_props_type mbl_read_props_merge ( const mbl_read_props_type a,
const mbl_read_props_type b,
bool  first_overrides 
)

merge two property sets.

Parameters:
first_overridesproperties in "first" will override identically named properties in "second"
first_overridesproperties in "a" will override identically named properties in "b"

Definition at line 435 of file mbl_read_props.cxx.

void mbl_read_props_print ( vcl_ostream &  afs,
mbl_read_props_type  props 
)

Print a list of properties for debugging purposes.

Definition at line 48 of file mbl_read_props.cxx.

void mbl_read_props_print ( vcl_ostream &  afs,
mbl_read_props_type  props,
unsigned  max_chars 
)

Print a list of properties for debugging purposes. Limit each property value length to max_chars.

Useful for preventing diagnostic output from being flooded by large properties.

Definition at line 60 of file mbl_read_props.cxx.

mbl_read_props_type mbl_read_props_ws ( vcl_istream &  afs)

Read properties from a text stream.

The function will terminate on an eof. If one of the opening lines contains an opening brace '{', then the function will also stop reading the stream after finding a line containing a closing brace '}'

Every property label ends in ":", and should not contain any whitespace. If there is a brace after the first string following the label, the following text up to matching braces is included in the property value.

Differs from mbl_read_props(afs) in that all whitespace is treated as a separator. Thus it treats the single line "a: a b: b" as containing two separate label-value pairs.

The function will terminate on an eof. If one of the opening lines contains an opening brace '{', then the function will also stop reading the stream after finding a line containing a closing brace '}'

Every property label ends in ":", and should not contain any whitespace. Differs from mbl_read_props(afs) in that all whitespace is treated as a separator. If there is a brace after the first string following the label, the following text up to matching braces is included in the property value. Each property label should not contain any whitespace.

Definition at line 267 of file mbl_read_props.cxx.