X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/feb15e71130a86dbf9740dcb693a0f949d258df6..92c80f9accb9816105923994b7091edc9198f9b6:/include/stg/tariff.h diff --git a/include/stg/tariff.h b/include/stg/tariff.h index 1b6413b3..5d01cba0 100644 --- a/include/stg/tariff.h +++ b/include/stg/tariff.h @@ -41,6 +41,7 @@ public: static std::string TraffTypeToString(TRAFF_TYPE type); static TRAFF_TYPE StringToTraffType(const std::string& value); + static TRAFF_TYPE IntToTraffType(int value); virtual ~TARIFF() {} virtual double GetPriceWithTraffType(uint64_t up, @@ -117,4 +118,12 @@ std::istream & operator>>(std::istream & stream, TARIFF::TRAFF_TYPE & traffType) return stream; } +inline +TARIFF::TRAFF_TYPE TARIFF::IntToTraffType(int value) +{ + if (value < 0 || value > TRAFF_MAX) + return TRAFF_UP_DOWN; + return static_cast(value); +} + #endif