//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifEclipseDataTableFormatter::outputBuffer()
{
    if (!m_columns.empty() && !isAllHeadersEmpty(m_columns))
    {
        m_out << m_commentPrefix;
        for (size_t i = 0u; i < m_columns.size(); ++i)
        {       
            m_out << formatColumn(m_columns[i].title, i);
        }
        m_out << "\n";
    }

    for (auto line : m_buffer)
    {
        if (line.lineType == COMMENT)
        {
            outputComment(line);
        }
        else if (line.lineType == HORIZONTAL_LINE)
        {
            outputHorizontalLine(line);
        }
        else if (line.lineType == CONTENTS)
        {
            QString lineText = m_tableRowPrependText;
            bool isComment = m_tableRowPrependText.startsWith(m_commentPrefix);
            QString appendText = (line.appendTextSet ? line.appendText : m_tableRowAppendText);

            for (size_t i = 0; i < line.data.size(); ++i)
            {
                QString column = formatColumn(line.data[i], i);
                QString newLineText = lineText + column;
                if (i == line.data.size() - 1)
                {
                    newLineText += appendText;
                }
                if (!isComment && newLineText.length() > maxDataRowWidth())
                {
                    m_out << lineText << "\n";
                    lineText = m_tableRowPrependText;
                }
                lineText += column;
            }

            m_out << lineText << appendText << "\n";
        }
    }
    m_columns.clear();
    m_buffer.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseDataTableFormatter& RifEclipseDataTableFormatter::comment(const QString& comment)
{
    RifEclipseOutputTableLine line;
    line.data.push_back(comment);
    line.lineType = COMMENT;
    line.appendTextSet = false;
    if (m_columns.empty())
    {
        outputComment(line);
    }
    else
    {
        m_buffer.push_back(line);
    }
    return *this;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseDataTableFormatter& RifEclipseDataTableFormatter::addHorizontalLine(const QChar& character)
{
    RifEclipseOutputTableLine line;
    QString data;
    data += character;
    line.data.push_back(data);
    line.lineType = HORIZONTAL_LINE;
    line.appendTextSet = false;
    if (m_columns.empty())
    {
        outputComment(line);
    }
    else
    {
        m_buffer.push_back(line);
    }
    return *this;
}
예제 #4
0
/* Output a function label as target (prepend "yo_" to avoid conflicts) */
void placeFunLabel(char *funname)
{
    outputComment("================================");
    fprintf(OUTPUT, "\nyo_%s:", funname);
}