(Advanced) A basic implementation of the Name-Value Pair concept as used in the Serialize / Archive pattern.
NameValue stores a pointer to a const name and a pointer to a mutable value. Both pointers must remain valid throughout the lifetime of an object. NameValue objects are typically short-lived, existing only for a transient moment while an Archive is visiting some Serializable field.
For more information, refer to Drake's YAML Serialization and especially the Implementing Serialize section, or also the Boost Name-Value Pairs documentation for background.
#include <drake/common/name_value.h>
Public Types | |
| typedef T | value_type |
| Type of the referenced value. | |
Public Member Functions | |
| NameValue (const char *name_in, T *value_in) | |
| (Advanced) Constructs a NameValue. | |
Does not allow copy, move, or assignment | |
| NameValue (const NameValue &)=delete | |
| NameValue & | operator= (const NameValue &)=delete |
| NameValue (NameValue &&)=delete | |
| NameValue & | operator= (NameValue &&)=delete |
Accessors to the raw pointers | |
| const char * | name () const |
| T * | value () const |
| typedef T value_type |
Type of the referenced value.
| NameValue | ( | const char * | name_in, |
| T * | value_in ) |
(Advanced) Constructs a NameValue.
Prefer DRAKE_NVP instead of this constructor. Both pointers are aliased and must remain valid for the lifetime of this object. Neither pointer can be nullptr.
| const char * name | ( | ) | const |
| T * value | ( | ) | const |