Newer
Older
#include <fmt/core.h>
std::size_t Config::getIndexOfLine(int lineIndex) const
return lineIndex * getNbColumns() * (nbHypothesesMax+1);
std::size_t Config::getIndexOfCol(int colIndex) const
return colIndex * (nbHypothesesMax+1);
void Config::addLines(unsigned int nbLines)
lines.resize(lines.size() + nbLines*getNbColumns()*(nbHypothesesMax+1));
void Config::resizeLines(unsigned int nbLines)
lines.resize(nbLines*getNbColumns()*(nbHypothesesMax+1));
Config::String & Config::get(const std::string & colName, int lineIndex, int hypothesisIndex)
return get(getColIndex(colName), lineIndex, hypothesisIndex);
const Config::String & Config::getConst(const std::string & colName, int lineIndex, int hypothesisIndex) const
{
return getConst(getColIndex(colName), lineIndex, hypothesisIndex);
}
Config::String & Config::get(int colIndex, int lineIndex, int hypothesisIndex)
{
return *getIterator(colIndex, lineIndex, hypothesisIndex);
}
const Config::String & Config::getConst(int colIndex, int lineIndex, int hypothesisIndex) const
{
return *getConstIterator(colIndex, lineIndex, hypothesisIndex);
}
std::size_t Config::getNbLines() const
{
return lines.size() / getIndexOfCol(getNbColumns());
}
{
for (unsigned int line = 0; line < getNbLines(); line++)
{
for (unsigned int i = 0; i < getNbColumns()-1; i++)
fmt::print(dest, "{}{}", getLastNotEmptyConst(i, getFirstLineIndex()+line), i < getNbColumns()-2 ? "\t" : "\n");
if (getLastNotEmptyConst(EOSColName, getFirstLineIndex()+line) == EOSSymbol1)
fmt::print(dest, "\n");
}
}
Config::String & Config::getLastNotEmpty(int colIndex, int lineIndex)
{
int baseIndex = getIndexOfLine(lineIndex-getFirstLineIndex()) + getIndexOfCol(colIndex);
for (int i = nbHypothesesMax; i > 0; --i)
if (!util::isEmpty(lines[baseIndex+i]))
return lines[baseIndex+i];
return lines[baseIndex];
}
const Config::String & Config::getLastNotEmptyConst(int colIndex, int lineIndex) const
{
int baseIndex = getIndexOfLine(lineIndex-getFirstLineIndex()) + getIndexOfCol(colIndex);
for (int i = nbHypothesesMax; i > 0; --i)
if (!util::isEmpty(lines[baseIndex+i]))
return lines[baseIndex+i];
return lines[baseIndex];
}
Config::String & Config::getLastNotEmpty(const std::string & colName, int lineIndex)
{
return getLastNotEmpty(getColIndex(colName), lineIndex);
}
const Config::String & Config::getLastNotEmptyConst(const std::string & colName, int lineIndex) const
{
return getLastNotEmptyConst(getColIndex(colName), lineIndex);
}
Config::ValueIterator Config::getIterator(int colIndex, int lineIndex, int hypothesisIndex)
{
return lines.begin() + getIndexOfLine(lineIndex-getFirstLineIndex()) + getIndexOfCol(colIndex) + hypothesisIndex;
}
Config::ConstValueIterator Config::getConstIterator(int colIndex, int lineIndex, int hypothesisIndex) const
return lines.begin() + getIndexOfLine(lineIndex-getFirstLineIndex()) + getIndexOfCol(colIndex) + hypothesisIndex;
void Config::addToHistory(const Config::String & transition)
{
history.push_back(transition);
}