From: Elena Mamontova Date: Sun, 17 Jul 2016 16:48:24 +0000 (+0300) Subject: Ticket. InToTraffType() function declaration and definition added. X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/8ae4c5e8f4f88c52eb2947f9c9195f132785b46a?hp=e56069384c48405383537f7248682fd7f00944a1 Ticket. InToTraffType() function declaration and definition added. --- 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