propershark / timetable_cpp

Purveyor of schedule information for transit agencies via GTFS feeds and WAMP procedures.
1 stars 0 forks source link

Support default values in field_mapper #20

Closed elliottwilliams closed 7 years ago

elliottwilliams commented 7 years ago

Defaults are specified with an additional parameter to make_field_mapper, i.e.

make_field_mapper(&stop_time::pickup_type, 0)

specifies an integer field pickup_type with default value 0. The type of the default value must match the field's property type.

This change uses std::optional (approved for c++17, but still std::experimental::optional in latest clang) to pass values into field_mapper. Passing an empty optional causes the field_mapper to attempt to use a default value.

Defaults for optional fields based on the GTFS specification are added to source.h.

Especially since this is my first timetable PR and first c++ code I've hashed out in awhile, feedback welcome!