X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/69172e0e3684d849825b90b01e53026852e01a97..980332313bffde590173f76fd006837e0c8f3bed:/include/stg/tariff.h?ds=sidebyside 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