LSSTApplications
18.0.0+106,18.0.0+50,19.0.0,19.0.0+1,19.0.0+10,19.0.0+11,19.0.0+13,19.0.0+17,19.0.0+2,19.0.0-1-g20d9b18+6,19.0.0-1-g425ff20,19.0.0-1-g5549ca4,19.0.0-1-g580fafe+6,19.0.0-1-g6fe20d0+1,19.0.0-1-g7011481+9,19.0.0-1-g8c57eb9+6,19.0.0-1-gb5175dc+11,19.0.0-1-gdc0e4a7+9,19.0.0-1-ge272bc4+6,19.0.0-1-ge3aa853,19.0.0-10-g448f008b,19.0.0-12-g6990b2c,19.0.0-2-g0d9f9cd+11,19.0.0-2-g3d9e4fb2+11,19.0.0-2-g5037de4,19.0.0-2-gb96a1c4+3,19.0.0-2-gd955cfd+15,19.0.0-3-g2d13df8,19.0.0-3-g6f3c7dc,19.0.0-4-g725f80e+11,19.0.0-4-ga671dab3b+1,19.0.0-4-gad373c5+3,19.0.0-5-ga2acb9c+2,19.0.0-5-gfe96e6c+2,w.2020.01
LSSTDataManagementBasePackage
|
A proxy type for name lookups in a Schema. More...
#include <Schema.h>
Public Member Functions | |
template<typename T > | |
SchemaItem< T > | find (std::string const &name) const |
Find a nested SchemaItem by name. More... | |
template<typename F > | |
void | findAndApply (std::string const &name, F &&func) const |
Find a nested SchemaItem by name and run a functor on it. More... | |
template<typename F > | |
void | apply (F &&func) const |
Run functor on the SchemaItem represented by this SubSchema. 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... | |
std::string | join (std::string const &a, std::string const &b) const |
Join strings using the field delimiter appropriate for this Schema. More... | |
std::string | join (std::string const &a, std::string const &b, std::string const &c) const |
Join strings using the field delimiter appropriate for this Schema. More... | |
std::string | join (std::string const &a, std::string const &b, std::string const &c, std::string const &d) const |
Join strings using the field delimiter appropriate for this Schema. More... | |
Friends | |
class | Schema |
A proxy type for name lookups in a Schema.
Elements of schema names are assumed to be separated by underscores ("a_b_c"); 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:
Schema schema(false); 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); SubSchema a = schema["a"]; 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());
|
inline |
Run functor on the SchemaItem represented by this SubSchema.
The given functor must have an overloaded function call operator that accepts any SchemaItem type (the same as a functor provided to apply or Schema::forEach).
Throws | pex::exceptions::NotFoundError if the SubSchemas prefix does not correspond to the full name of a regular field (not a named subfield). |
SchemaItem< T > lsst::afw::table::SubSchema::find | ( | std::string const & | name | ) | const |
Find a nested SchemaItem by name.
Definition at line 773 of file Schema.cc.
|
inline |
Find a nested SchemaItem by name and run a functor on it.
Names corresponding to named subfields are not accepted. The given functor must have an overloaded function call operator that accepts any SchemaItem type (the same as a functor provided to apply or Schema::forEach).
Definition at line 386 of file Schema.h.
std::set< std::string > lsst::afw::table::SubSchema::getNames | ( | bool | topOnly = false | ) | const |
Return a set of nested names that start with the SubSchema's prefix.
Returns an instance of Python's builtin set in Python.
|
inline |
std::string lsst::afw::table::SubSchema::join | ( | std::string const & | a, |
std::string const & | b | ||
) | const |
|
inline |
Join strings using the field delimiter appropriate for this Schema.
Definition at line 364 of file Schema.h.
|
inline |
Join strings using the field delimiter appropriate for this Schema.
Definition at line 367 of file Schema.h.
|
inline |
|
inline |
SubSchema lsst::afw::table::SubSchema::operator[] | ( | std::string const & | name | ) | const |
Return a nested proxy.
Definition at line 777 of file Schema.cc.