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>
Public Member Functions | |
BindProperties (Properties &properties) | |
Creates a BindProperties instance that will bind values to the specified Properties argument. | |
template<typename V > | |
const BindProperties & | operator() (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:
-
properties A reference to the Properties instance to which values will be bound.
Definition at line 169 of file BindProperties.h.
Member Function Documentation
const BindProperties& BindProperties::operator() | ( | const char *const | key, |
const V & | value | ||
) | const [inline] |
Adds a key-value pair to the associated Properties.
- Parameters:
-
key The name of the variable to bind. value The 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: