|
| template<typename T > |
| SchemaItem< T > | find (std::string const &name) const |
| | Find a nested SchemaItem by name. More...
|
| |
| SubSchema | operator[] (std::string const &name) const |
| | Return a nested proxy. More...
|
| |
| std::string const & | getPrefix () const |
| | Return the prefix that defines this SubSchema relative to its parent Schema. More...
|
| |
| std::set< std::string > | getNames (bool topOnly=false) const |
| | Return a set of nested names that start with the SubSchema's prefix. More...
|
| |
| template<typename T > |
| | operator Key< T > () const |
| | Implicit conversion to the appropriate Key type. More...
|
| |
| template<typename T > |
| | operator Field< T > () const |
| | Implicit conversion to the appropriate Key type. More...
|
| |
A proxy type for name lookups in a Schema.
Elements of schema names are assumed to be separated by periods ("a.b.c.d"); an incomplete lookup is one that does not resolve to a field. Not that even complete lookups can have nested names; a Point field, for instance, has "x" and "y" nested names.
This proxy object is implicitly convertible to both the appropriate Key type and the appropriate Field type, if the name is a complete one, and supports additional find() operations for nested names.
SubSchema is implemented as a proxy that essentially calls Schema::find after concatenating strings. It does not provide any performance advantage over using Schema::find directly. It is also lazy, so looking up a name prefix that does not exist within the schema is not considered an error until the proxy is used.
Some examples:
* Key<int> a_i =
schema.addField<
int>(
"a.i",
"integer field");
* Key< Point<double> > a_p =
schema.addField< Point<double> >(
"a.p",
"point field");
*
* assert(
schema[
"a.i"] == a_i);
* assert(a["i"] == a_i);
* Field<int> f_a_i =
schema[
"a.i"];
* assert(f_a_i.getDoc() == "integer field");
* assert(
schema[
"a.i"] ==
"a.i");
* assert(
schema.find(
"a.p.x") == a_p.getX());
*
Definition at line 372 of file Schema.h.