Skip to content
Snippets Groups Projects
Commit a1fc02b9 authored by Franck Dary's avatar Franck Dary
Browse files

Added some error messages in Config::get

parent a4af59b6
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment