Skip to content

Commit

Permalink
fix do not write outfiles with head line only
Browse files Browse the repository at this point in the history
  • Loading branch information
ferkulat committed Sep 4, 2019
1 parent fedfa39 commit 0b352bf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
12 changes: 3 additions & 9 deletions csv2xlslib/OutputDoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ Row OutputDoc::RowAfterClearSheet()
self_->clearSheet();
m_column = Column(0);
m_row = Row(0);
if (m_headline.size())
{
for(auto const& column : m_headline )
appendCell(CellContent(column.c_str(), column.size()));
newLine();
}
return m_row;
}

Expand All @@ -25,14 +19,14 @@ int OutputDoc::writeInto(OutputFileName const& out_put_file, FileNumber file_num
return 0;
return self_->writeInto(out_put_file, file_number);
}
void OutputDoc::setHeadLine(HeadLineType const& head_line)
void OutputDoc::set(InputHasHeadLine input_has_head_line)
{
m_headline = head_line;
m_input_has_head_line = input_has_head_line;
}

bool OutputDoc::isEmpty()const
{
return (m_headline.size())
return (m_input_has_head_line.Get())
? (m_row == Row(1))&&(m_column == Column(0))
: (m_row == Row(0))&&(m_column == Column(0));
}
Expand Down
4 changes: 2 additions & 2 deletions csv2xlslib/OutputDoc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class OutputDoc
Row RowAfterClearSheet();

int writeInto(OutputFileName const& out_put_file, FileNumber file_number)const;
void setHeadLine(HeadLineType const& head_line);
void set(InputHasHeadLine input_has_head_line);
Column appendCell(CellContent cell_content);
Row newLine();
bool isEmpty()const;
Expand Down Expand Up @@ -78,7 +78,7 @@ class OutputDoc
Row m_row = Row(0);
Column m_column = Column(0);
std::optional<OutputColumnLimit> output_column_limit;
HeadLineType m_headline;
InputHasHeadLine m_input_has_head_line;
};
}

Expand Down
10 changes: 6 additions & 4 deletions csv2xlslib/parseCsvFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ namespace csv2xls
std::stringstream csv_input(headline);
auto buffer = Buffer(parameter_.input_buffer_size);

return (parameter_.input_has_head_line.Get())
?convertCsv(buffer, parameter_, csv_input, std::move(output_doc))
:std::optional<OutputDoc>(std::move(output_doc));
// return output_doc;
if(parameter_.input_has_head_line.Get())
{
output_doc.set(parameter_.input_has_head_line);
return convertCsv(buffer, parameter_, csv_input, std::move(output_doc));
}
return std::optional<OutputDoc>(std::move(output_doc));
};
}
auto makeOutputDoc=[](auto file_gen ) {
Expand Down

0 comments on commit 0b352bf

Please sign in to comment.