| 49 | } |
| 50 | |
| 51 | void SQLRowsetProcessor::addRow(const soci::row& row, size_t rowCount) { |
| 52 | for (const auto& pRowSubscriber : rowSubscribers_) { |
| 53 | pRowSubscriber->beginProcessRow(); |
| 54 | } |
| 55 | |
| 56 | if (rowCount == 0) { |
| 57 | for (std::size_t i = 0; i != row.size(); ++i) { |
| 58 | for (const auto& pRowSubscriber : rowSubscribers_) { |
| 59 | pRowSubscriber->processColumnName(utils::toLower(row.get_properties(i).get_name())); |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | for (std::size_t i = 0; i != row.size(); ++i) { |
| 65 | const soci::column_properties& props = row.get_properties(i); |
| 66 | |
| 67 | const auto& name = utils::toLower(props.get_name()); |
| 68 | |
| 69 | if (row.get_indicator(i) == soci::i_null) { |
| 70 | processColumn(name, "NULL"); |
| 71 | } else { |
| 72 | switch (const auto dataType = props.get_data_type()) { |
| 73 | case soci::data_type::dt_string: { |
| 74 | processColumn(name, row.get<std::string>(i)); |
| 75 | } |
| 76 | break; |
| 77 | case soci::data_type::dt_double: { |
| 78 | processColumn(name, row.get<double>(i)); |
| 79 | } |
| 80 | break; |
| 81 | case soci::data_type::dt_integer: { |
| 82 | processColumn(name, row.get<int>(i)); |
| 83 | } |
| 84 | break; |
| 85 | case soci::data_type::dt_long_long: { |
| 86 | processColumn(name, row.get<long long>(i)); |
| 87 | } |
| 88 | break; |
| 89 | case soci::data_type::dt_unsigned_long_long: { |
| 90 | processColumn(name, row.get<unsigned long long>(i)); |
| 91 | } |
| 92 | break; |
| 93 | case soci::data_type::dt_date: { |
| 94 | const std::tm when = row.get<std::tm>(i); |
| 95 | |
| 96 | char value[128]; |
| 97 | if (!std::strftime(value, sizeof(value), "%Y-%m-%d %H:%M:%S", &when)) |
| 98 | throw minifi::Exception(PROCESSOR_EXCEPTION, "SQLRowsetProcessor: !strftime."); |
| 99 | |
| 100 | processColumn(name, std::string(value)); |
| 101 | } |
| 102 | break; |
| 103 | default: { |
| 104 | throw minifi::Exception(PROCESSOR_EXCEPTION, "SQLRowsetProcessor: Unsupported data type " + std::to_string(dataType)); |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | } |
nothing calls this directly
no test coverage detected