diff --git a/reading_machine/src/Config.cpp b/reading_machine/src/Config.cpp index 24612ff72521e73689f00f81fa189e485eb339dc..902b1cd84f48d3c62f74f819201770ce09c6bfb9 100644 --- a/reading_machine/src/Config.cpp +++ b/reading_machine/src/Config.cpp @@ -216,6 +216,8 @@ void Config::printForDebug(FILE * dest) const Config::String & Config::getLastNotEmpty(int colIndex, int lineIndex) { + if (!has(colIndex, lineIndex, 0)) + util::myThrow(fmt::format("asked for line {} but nbLines = {}", lineIndex, getNbLines())); int baseIndex = getIndexOfLine(lineIndex-getFirstLineIndex()) + getIndexOfCol(colIndex); for (int i = nbHypothesesMax; i > 0; --i) @@ -227,6 +229,8 @@ Config::String & Config::getLastNotEmpty(int colIndex, int lineIndex) Config::String & Config::getLastNotEmptyHyp(int colIndex, int lineIndex) { + if (!has(colIndex, lineIndex, 0)) + util::myThrow(fmt::format("asked for line {} but nbLines = {}", lineIndex, getNbLines())); int baseIndex = getIndexOfLine(lineIndex-getFirstLineIndex()) + getIndexOfCol(colIndex); for (int i = nbHypothesesMax; i > 0; --i) @@ -238,6 +242,8 @@ Config::String & Config::getLastNotEmptyHyp(int colIndex, int lineIndex) Config::String & Config::getFirstEmpty(int colIndex, int lineIndex) { + if (!has(colIndex, lineIndex, 0)) + util::myThrow(fmt::format("asked for line {} but nbLines = {}", lineIndex, getNbLines())); int baseIndex = getIndexOfLine(lineIndex-getFirstLineIndex()) + getIndexOfCol(colIndex); for (int i = 1; i < nbHypothesesMax; ++i) @@ -254,6 +260,8 @@ Config::String & Config::getFirstEmpty(const std::string & colName, int lineInde const Config::String & Config::getLastNotEmptyConst(int colIndex, int lineIndex) const { + if (!has(colIndex, lineIndex, 0)) + util::myThrow(fmt::format("asked for line {} but nbLines = {}", lineIndex, getNbLines())); int baseIndex = getIndexOfLine(lineIndex-getFirstLineIndex()) + getIndexOfCol(colIndex); for (int i = nbHypothesesMax; i > 0; --i) @@ -265,6 +273,8 @@ const Config::String & Config::getLastNotEmptyConst(int colIndex, int lineIndex) const Config::String & Config::getLastNotEmptyHypConst(int colIndex, int lineIndex) const { + if (!has(colIndex, lineIndex, 0)) + util::myThrow(fmt::format("asked for line {} but nbLines = {}", lineIndex, getNbLines())); int baseIndex = getIndexOfLine(lineIndex-getFirstLineIndex()) + getIndexOfCol(colIndex); for (int i = nbHypothesesMax; i > 0; --i) @@ -309,11 +319,15 @@ const Config::String & Config::getLastNotEmptyHypConst(const std::string & colNa Config::ValueIterator Config::getIterator(int colIndex, int lineIndex, int hypothesisIndex) { + if (!has(colIndex, lineIndex, 0)) + util::myThrow(fmt::format("asked for line {} but nbLines = {}", lineIndex, getNbLines())); return lines.begin() + getIndexOfLine(lineIndex-getFirstLineIndex()) + getIndexOfCol(colIndex) + hypothesisIndex; } Config::ConstValueIterator Config::getConstIterator(int colIndex, int lineIndex, int hypothesisIndex) const { + if (!has(colIndex, lineIndex, 0)) + util::myThrow(fmt::format("asked for line {} but nbLines = {}", lineIndex, getNbLines())); return lines.begin() + getIndexOfLine(lineIndex-getFirstLineIndex()) + getIndexOfCol(colIndex) + hypothesisIndex; }