From d0e66f072e8a38ff4cef76e840bbb61847903e94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Urs=20F=C3=A4ssler?= Date: Tue, 19 Dec 2023 07:10:45 +0100 Subject: [PATCH] remove boost::multi_array --- include/cucumber-cpp/internal/CukeEngine.hpp | 4 +--- src/CukeEngineImpl.cpp | 14 ++++++-------- src/connectors/wire/WireProtocol.cpp | 6 +++--- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/include/cucumber-cpp/internal/CukeEngine.hpp b/include/cucumber-cpp/internal/CukeEngine.hpp index cc240c11..a896c394 100644 --- a/include/cucumber-cpp/internal/CukeEngine.hpp +++ b/include/cucumber-cpp/internal/CukeEngine.hpp @@ -5,8 +5,6 @@ #include #include -#include - #include namespace cucumber { @@ -65,7 +63,7 @@ class CUCUMBER_CPP_EXPORT PendingStepException : public InvokeException { class CukeEngine { private: typedef std::vector string_array; - typedef boost::multi_array string_2d_array; + typedef std::vector> string_2d_array; public: typedef string_array tags_type; diff --git a/src/CukeEngineImpl.cpp b/src/CukeEngineImpl.cpp index c06a4e6c..292b9f1e 100644 --- a/src/CukeEngineImpl.cpp +++ b/src/CukeEngineImpl.cpp @@ -45,24 +45,22 @@ void CukeEngineImpl::beginScenario(const tags_type& tags) { void CukeEngineImpl::invokeStep( const std::string& id, const invoke_args_type& args, const invoke_table_type& tableArg ) { - typedef invoke_table_type::index table_index; - InvokeArgs commandArgs; try { for (const std::string& a : args) { commandArgs.addArg(a); } - if (tableArg.shape()[0] > 1 && tableArg.shape()[1] > 0) { + if (!tableArg.empty() && !tableArg.front().empty()) { Table& commandTableArg = commandArgs.getVariableTableArg(); - for (table_index j = 0; j < table_index(tableArg.shape()[1]); ++j) { - commandTableArg.addColumn(tableArg[0][j]); + for (const auto& arg : tableArg[0]) { + commandTableArg.addColumn(arg); } - for (table_index i = 1; i < table_index(tableArg.shape()[0]); ++i) { + for (std::size_t i = 1; i < tableArg.size(); ++i) { Table::row_type row; - for (table_index j = 0; j < table_index(tableArg.shape()[1]); ++j) { - row.push_back(tableArg[i][j]); + for (const auto& arg : tableArg[i]) { + row.push_back(arg); } commandTableArg.addRow(row); } diff --git a/src/connectors/wire/WireProtocol.cpp b/src/connectors/wire/WireProtocol.cpp index f13fcc03..d70591ae 100644 --- a/src/connectors/wire/WireProtocol.cpp +++ b/src/connectors/wire/WireProtocol.cpp @@ -112,12 +112,12 @@ void fillTableArg(const mArray& jsonTableArg, CukeEngine::invoke_table_type& tab size_type rows = jsonTableArg.size(); if (rows > 0) { size_type columns = jsonTableArg[0].get_array().size(); - tableArg.resize(boost::extents[rows][columns]); + tableArg.resize(rows); for (size_type i = 0; i < rows; ++i) { const mArray& jsonRow(jsonTableArg[i].get_array()); if (jsonRow.size() == columns) { for (size_type j = 0; j < columns; ++j) { - tableArg[i][j] = jsonRow[j].get_str(); + tableArg[i].push_back(jsonRow[j].get_str()); } } else { // TODO: Invalid row @@ -257,7 +257,7 @@ class WireResponseEncoder : public WireResponseVisitor { for (const StepMatchArg& ma : m.args) { mObject jsonMa; jsonMa["val"] = ma.value; - jsonMa["pos"] = static_cast(ma.position); + jsonMa["pos"] = static_cast(ma.position); jsonArgs.push_back(jsonMa); } jsonM["args"] = jsonArgs;