From 8ae4c5e8f4f88c52eb2947f9c9195f132785b46a Mon Sep 17 00:00:00 2001 From: Elena Mamontova Date: Sun, 17 Jul 2016 19:48:24 +0300 Subject: [PATCH] Ticket. InToTraffType() function declaration and definition added. --- include/stg/tariff.h | 9 +++++++++ 1 file changed, 9 insertions(+) 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 -- 2.43.2