Savarese Software Research Corporation
BindProperties Class Reference

BindProperties is used to create temporary function objects for use with wisp_struct visit() in order to copy wisp_struct member variables to comparably named Properties values. More...

#include <BindProperties.h>

List of all members.

Public Member Functions

 BindProperties (Properties &properties)
 Creates a BindProperties instance that will bind values to the specified Properties argument.
template<typename V >
const BindPropertiesoperator() (const char *const key, const V &value) const
 Adds a key-value pair to the associated Properties.

Detailed Description

BindProperties is used to create temporary function objects for use with wisp_struct visit() in order to copy wisp_struct member variables to comparably named Properties values.

For example:

 WISP_STRUCT(IntPair, ((int, first))((int, second)));
 WISP_STRUCT(NestedPair, ((IntPair, first))((IntPair, second)));
Properties props;
 NestedPair pair(IntPair(1, 2), IntPair(3, 4));
 const string expected("{first={first=1,second=2},second={first=3,second=4}}");
pair.visit(BindProperties(props));
 assert(expected == to_string(props));
 

As demonstrated in the example, nested wisp_struct members will be recursively bound.

Definition at line 69 of file BindProperties.h.


Constructor & Destructor Documentation

BindProperties::BindProperties ( Properties properties) [inline, explicit]

Creates a BindProperties instance that will bind values to the specified Properties argument.

Parameters:
propertiesA reference to the Properties instance to which values will be bound.

Definition at line 169 of file BindProperties.h.


Member Function Documentation

template<typename V >
const BindProperties& BindProperties::operator() ( const char *const  key,
const V &  value 
) const [inline]

Adds a key-value pair to the associated Properties.

Parameters:
keyThe name of the variable to bind.
valueThe value of the variable to bind.

Definition at line 179 of file BindProperties.h.


The documentation for this class was generated from the following file:

Savarese Software Research Corporation
Copyright © 2006-2011 Savarese Software Research Corporation. All rights reserved.