lordgamez commented on a change in pull request #1073:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1073#discussion_r670367872



##########
File path: extensions/sql/data/SociConnectors.cpp
##########
@@ -0,0 +1,181 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "SociConnectors.h"
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace sql {
+
+void SociRow::setIterator(const soci::rowset<soci::row>::iterator& iter) {
+  current_ = iter;
+}
+
+soci::rowset<soci::row>::iterator SociRow::getIterator() const {
+  return current_;
+}
+
+void SociRow::next() {
+  ++current_;
+}
+
+std::size_t SociRow::size() const {
+  return current_->size();
+}
+
+std::string SociRow::getColumnName(std::size_t index) const {
+  return current_->get_properties(index).get_name();
+}
+
+bool SociRow::isNull(std::size_t index) const {
+  return current_->get_indicator(index) == soci::i_null;
+}
+
+DataType SociRow::getDataType(std::size_t index) const {
+  switch (const auto dataType = 
current_->get_properties(index).get_data_type()) {
+    case soci::data_type::dt_string: {
+      return DataType::STRING;
+    }
+    case soci::data_type::dt_double: {
+      return DataType::DOUBLE;
+    }
+    case soci::data_type::dt_integer: {
+      return DataType::INTEGER;
+    }
+    case soci::data_type::dt_long_long: {
+      return DataType::LONG_LONG;
+    }
+    case soci::data_type::dt_unsigned_long_long: {
+      return DataType::UNSIGNED_LONG_LONG;
+    }
+    case soci::data_type::dt_date: {
+      return DataType::DATE;
+    }
+    default: {
+      throw minifi::Exception(PROCESSOR_EXCEPTION, "SQLRowsetProcessor: 
Unsupported data type " + std::to_string(dataType));
+    }
+  }
+}
+
+std::string SociRow::getString(std::size_t index) const {
+  return current_->get<std::string>(index);
+}
+
+double SociRow::getDouble(std::size_t index) const {
+  return current_->get<double>(index);
+}
+
+int SociRow::getInteger(std::size_t index) const {
+  return current_->get<int>(index);
+}
+
+long long SociRow::getLongLong(std::size_t index) const {
+  return current_->get<long long>(index);
+}
+
+unsigned long long SociRow::getUnsignedLongLong(std::size_t index) const {
+  return current_->get<unsigned long long>(index);
+}
+
+std::tm SociRow::getDate(std::size_t index) const {
+  return current_->get<std::tm>(index);
+}

Review comment:
       I considered it, but as these functions needed to be generalized in a 
common base class (to be later implemented in the mock and the soci 
implementation) I went with the pure virtual functions for each getter in the 
base `Row` class.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to