]> git.stg.codes - stg.git/commitdiff
Ticket. InToTraffType() function declaration and definition added.
authorElena Mamontova <helenh463@gmail.com>
Sun, 17 Jul 2016 16:48:24 +0000 (19:48 +0300)
committerElena Mamontova <helenh463@gmail.com>
Sun, 17 Jul 2016 16:48:24 +0000 (19:48 +0300)
include/stg/tariff.h

index 1b6413b302f3c56417d32683d530850dcc6eb5f9..5d01cba08886be4087aced98c1305b072e16ef05 100644 (file)
@@ -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<TRAFF_TYPE>(value);
+}
+
 #endif