2 #ifndef AFW_TABLE_SchemaMapper_h_INCLUDED 3 #define AFW_TABLE_SchemaMapper_h_INCLUDED 35 return _impl->_output.
addField(newField, doReplace);
97 template <
typename Predicate>
128 template <
typename T>
132 template <
typename T>
148 template <
typename F>
198 SchemaMapper&
operator=(SchemaMapper
const& other);
199 SchemaMapper&
operator=(SchemaMapper&& other);
217 template <
typename Predicate>
218 struct AddMappingsWhere {
219 template <
typename T>
221 if (predicate(item))
mapper->addMapping(item.
key, doReplace);
224 AddMappingsWhere(SchemaMapper* mapper_, Predicate predicate_,
bool doReplace_)
225 :
mapper(mapper_), predicate(predicate_), doReplace(doReplace_) {}
237 template <
typename Predicate>
239 _impl->_input.forEach(AddMappingsWhere<Predicate>(
this, predicate, doReplace));
245 #endif // !AFW_TABLE_SchemaMapper_h_INCLUDED SchemaMapper & operator=(SchemaMapper const &other)
Assignment (copy-on-write).
Defines the fields and offsets for a table.
A functor-wrapper used in the implementation of SchemaMapper::forEach.
Key< T > getMapping(Key< T > const &inputKey) const
Return the output Key corresponding to the given input Key, or raise NotFoundError.
void forEach(F &&func) const
Call the given functor for each key pair in the mapper.
SchemaMapper()
Construct an empty mapper; useless unless you assign a fully-constructed one to it.
Schema const getInputSchema() const
Return the input schema (copy-on-write).
A mapping between the keys of two Schemas, used to copy data between them.
Key< T > addOutputField(Field< T > const &newField, bool doReplace=false)
Add a new field to the output Schema that is not connected to the input Schema.
Schema const getOutputSchema() const
Return the output schema (copy-on-write).
A private implementation class to hide the messy details of SchemaMapper.
static SchemaMapper removeMinimalSchema(Schema const &input, Schema const &minimal)
Create a mapper by removing fields from the front of a schema.
static std::vector< SchemaMapper > join(std::vector< Schema > const &inputs, std::vector< std::string > const &prefixes=std::vector< std::string >())
Combine a sequence of schemas into one, creating a SchemaMapper for each.
A base class for image defects.
void addMappingsWhere(Predicate predicate, bool doReplace=true)
Add mappings for all fields that match criteria defined by a predicate.
A description of a field in a table.
bool isMapped(Key< T > const &inputKey) const
Return true if the given input Key is mapped to an output Key.
Schema & editOutputSchema()
Return a reference to the output schema that allows it to be modified in place.
A class used as a handle to a particular field in a table.
void addMinimalSchema(Schema const &minimal, bool doMap=true)
Add the given minimal schema to the output schema.
ItemVariant const * other
void invert()
Swap the input and output schemas in-place.
Key< T > addMapping(Key< T > const &inputKey, bool doReplace=false)
Add a new field to the output Schema that is a copy of a field in the input Schema.
Key< T > addField(Field< T > const &field, bool doReplace=false)
Add a new field to the Schema, and return the associated Key.
A simple pair-like struct for mapping a Field (name and description) with a Key (used for actual data...