From 574da01e12b073577ea3ee639f0f912db59db2dc Mon Sep 17 00:00:00 2001 From: Victor Date: Fri, 5 Feb 2021 18:34:46 +0100 Subject: [PATCH 1/3] Changed underlying types of enum classes --- include/just_gtfs/just_gtfs.h | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/include/just_gtfs/just_gtfs.h b/include/just_gtfs/just_gtfs.h index 9fc160c..d8635a6 100644 --- a/include/just_gtfs/just_gtfs.h +++ b/include/just_gtfs/just_gtfs.h @@ -644,7 +644,7 @@ using CurrencyCode = std::string; using LanguageCode = std::string; // Helper enums for some GTFS fields --------------------------------------------------------------- -enum class StopLocationType +enum class StopLocationType : int8_t { StopOrPlatform = 0, Station = 1, @@ -654,7 +654,7 @@ enum class StopLocationType }; // The type of transportation used on a route. -enum class RouteType +enum class RouteType : int16_t { // GTFS route types Tram = 0, // Tram, Streetcar, Light rail @@ -752,20 +752,20 @@ enum class RouteType HorseDrawnCarriage = 1702 }; -enum class TripDirectionId +enum class TripDirectionId : bool { DefaultDirection = 0, // e.g. outbound OppositeDirection = 1 // e.g. inbound }; -enum class TripAccess +enum class TripAccess : int8_t { NoInfo = 0, Yes = 1, No = 2 }; -enum class StopTimeBoarding +enum class StopTimeBoarding : int8_t { RegularlyScheduled = 0, No = 1, // Not available @@ -773,31 +773,31 @@ enum class StopTimeBoarding CoordinateWithDriver = 3 // Must coordinate with driver to arrange }; -enum class StopTimePoint +enum class StopTimePoint : bool { Approximate = 0, Exact = 1 }; -enum class CalendarAvailability +enum class CalendarAvailability : bool { NotAvailable = 0, Available = 1 }; -enum class CalendarDateException +enum class CalendarDateException : int8_t { Added = 1, // Service has been added for the specified date Removed = 2 }; -enum class FarePayment +enum class FarePayment : bool { OnBoard = 0, BeforeBoarding = 1 // Fare must be paid before boarding }; -enum class FareTransfers +enum class FareTransfers : int8_t { No = 0, // No transfers permitted on this fare Once = 1, @@ -805,13 +805,13 @@ enum class FareTransfers Unlimited = 3 }; -enum class FrequencyTripService +enum class FrequencyTripService : bool { FrequencyBased = 0, // Frequency-based trips ScheduleBased = 1 // Schedule-based trips with the exact same headway throughout the day }; -enum class TransferType +enum class TransferType : int8_t { Recommended = 0, Timed = 1, @@ -819,7 +819,7 @@ enum class TransferType NotPossible = 3 }; -enum class PathwayMode +enum class PathwayMode : int8_t { Walkway = 1, Stairs = 2, @@ -830,13 +830,13 @@ enum class PathwayMode ExitGate = 7 }; -enum class PathwayDirection +enum class PathwayDirection : bool { Unidirectional = 0, Bidirectional = 1 }; -enum class AttributionRole +enum class AttributionRole : bool { No = 0, // Organization doesn’t have this role Yes = 1 // Organization does have this role From c43b6032d849ae274f0e1a96707bb16bbb15842b Mon Sep 17 00:00:00 2001 From: Victor Date: Fri, 5 Feb 2021 18:37:00 +0100 Subject: [PATCH 2/3] Made attributes of Feed protected in order to be able to use inheritance --- include/just_gtfs/just_gtfs.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/just_gtfs/just_gtfs.h b/include/just_gtfs/just_gtfs.h index d8635a6..0470928 100644 --- a/include/just_gtfs/just_gtfs.h +++ b/include/just_gtfs/just_gtfs.h @@ -1348,6 +1348,7 @@ private: inline void write_translations(std::ofstream & out) const; inline void write_attributions(std::ofstream & out) const; +protected: std::string gtfs_directory; Agencies agencies; From ef0c8946b12a45e299fcab52b0301867da13c1f6 Mon Sep 17 00:00:00 2001 From: Victor Date: Fri, 5 Feb 2021 18:38:51 +0100 Subject: [PATCH 3/3] Added constructor for Time --- include/just_gtfs/just_gtfs.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/just_gtfs/just_gtfs.h b/include/just_gtfs/just_gtfs.h index 0470928..2fe89b1 100644 --- a/include/just_gtfs/just_gtfs.h +++ b/include/just_gtfs/just_gtfs.h @@ -455,6 +455,7 @@ public: inline Time() = default; inline explicit Time(const std::string & raw_time_str); inline Time(uint16_t hours, uint16_t minutes, uint16_t seconds); + inline Time(size_t seconds); inline bool is_provided() const; inline size_t get_total_seconds() const; inline std::tuple get_hh_mm_ss() const; @@ -543,6 +544,13 @@ inline Time::Time(uint16_t hours, uint16_t minutes, uint16_t seconds) time_is_provided = true; } +inline Time::Time(size_t seconds) + : time_is_provided(true), total_seconds(seconds), + hh(seconds / 3600), mm((seconds % 3600) / 60), ss(seconds % 3600) +{ + set_raw_time(); +} + inline bool Time::is_provided() const { return time_is_provided; } inline size_t Time::get_total_seconds() const { return total_seconds; }