Commit 8aeb5f17 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

type conversion...

parent d8d1cdf7
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -805,7 +805,7 @@ TEST_CASE(QueryTest, TestSimpleDrawQuery, [] () {

  query.execute();
  auto chart = query.getChart(0);
  chart->renderSVG();
  //chart->renderSVG();
});

TEST_CASE(QueryTest, TestDerivedSeriesDrawQuery, [] () {
@@ -869,7 +869,7 @@ TEST_CASE(QueryTest, TestSimpleAggregateFromCSV, [] () {

  query.execute();
  auto results = query.getResultList(0);
  EXPECT(results->getNumRows() == 123);
  EXPECT(std::stof(results->getRow(0)[0]) == 74209240);
});


+10 −14
Original line number Diff line number Diff line
@@ -137,11 +137,20 @@ int64_t SValue::getInteger() const {

double SValue::getFloat() const {
  switch (data_.type) {

    case T_INTEGER:
      return data_.u.t_integer;

    case T_FLOAT:
      return data_.u.t_float;

    case T_STRING:
      try {
        return std::stod(getString());
      } catch (std::exception e) {
        /* FALLTHROUGH */
      }

    default:
      RAISE(
          TypeError,
@@ -150,13 +159,8 @@ double SValue::getFloat() const {
          toString().c_str());

  }
  if (data_.type == T_INTEGER) {
  }

  if (data_.type == T_INTEGER) {
  }

  return data_.u.t_float;
  return 0;
}

bool SValue::getBool() const {
@@ -281,13 +285,5 @@ template<> std::string SValue::getValue<std::string>() const {
  return toString();
}

template<> bool SValue::testType<double>() const {
  return true; // FIXPAUL
}

template<> bool SValue::testType<std::string>() const {
  return true;
}

}
}
+11 −0
Original line number Diff line number Diff line
@@ -73,6 +73,17 @@ protected:
  } data_;
};

template <typename T>
bool SValue::testType() const {
  try {
    getValue<T>();
  } catch (TypeError e) {
    return false;
  }

  return true;
}

}
}
#endif