]> git.stg.codes - stg.git/commitdiff
Added in-to-traff-type conversion.
authorMaxim Mamontov <faust.madf@gmail.com>
Sun, 25 Jan 2015 18:03:33 +0000 (20:03 +0200)
committerMaxim Mamontov <faust.madf@gmail.com>
Sun, 25 Jan 2015 18:03:33 +0000 (20:03 +0200)
include/stg/tariff.h
projects/stargazer/plugins/store/firebird/firebird_store_tariffs.cpp

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
index f757d0553896865ebcbda52ea69d484e64c0316b..f7aef9663a7269a6e358a42309acf9e0dd830450 100644 (file)
@@ -275,13 +275,10 @@ try
     st->Get(3, td->tariffConf.fee);
     st->Get(4, td->tariffConf.free);
     st->Get(5, td->tariffConf.passiveCost);
-    st->Get(6, td->tariffConf.traffType);
+    //st->Get(6, td->tariffConf.traffType);
+    td->tariffConf.traffType = TARIFF::IntToTraffType(Get<int>(st, 6));
     if (schemaVersion > 0)
-        {
-        std::string period;
-        st->Get(7, period);
-        td->tariffConf.period = TARIFF::StringToPeriod(period);
-        }
+        td->tariffConf.period = TARIFF::StringToPeriod(Get<std::string>(st, 7));
     st->Close();
     st->Prepare("select * from tb_tariffs_params where fk_tariff = ?");
     st->Set(1, id);