Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Log refactor - Output PVT #3149

Open
wants to merge 172 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
172 commits
Select commit Hold shift + click to select a range
751a919
Table function creation
arng40 Feb 9, 2024
c84a06e
add title off case
arng40 Feb 9, 2024
57bc055
setMargin function added
arng40 Feb 12, 2024
6255f9b
add comments + test for tiny table
arng40 Feb 12, 2024
601a2c5
value default optionnal variable changed
arng40 Feb 13, 2024
59a9bc8
Merge remote-tracking branch 'origin/develop' into feature/dudes/tabl…
arng40 Feb 13, 2024
677fdb6
add log to wellGeneratorBase
arng40 Feb 13, 2024
623b6ad
uncrustify + missing doc
arng40 Feb 13, 2024
37dc5dd
first review with correction
arng40 Feb 14, 2024
8678fc0
constness modification, doc/test updated
arng40 Feb 15, 2024
9475286
const declaration updated
arng40 Feb 15, 2024
1320651
doc + minor restructuring
arng40 Feb 19, 2024
f78bd83
doc + method for row from vector
arng40 Feb 20, 2024
294f075
clean code + doc + add test for rows from vector
arng40 Feb 21, 2024
36dd7a4
doc updated
arng40 Feb 22, 2024
8f74cfa
Merge commit 'c11ad8ecd2d0d0aba5cd0661eb6e72951252409d' into feature/…
arng40 Feb 22, 2024
ebb9fc0
Revert "Merge commit 'c11ad8ecd2d0d0aba5cd0661eb6e72951252409d' into …
arng40 Feb 22, 2024
cb41359
revert last merge and Merge remote-tracking branch 'origin/develop' i…
arng40 Feb 22, 2024
22659ec
Merge remote-tracking branch 'origin/feature/dudes/table-layout' into…
arng40 Feb 22, 2024
ff37ac9
begin pvt tables logs - add write in log bool
arng40 Feb 22, 2024
628f56b
duplication log & csv fixed
arng40 Feb 22, 2024
e11a2bf
CI correction ( uncrustify, missing doc )
arng40 Feb 23, 2024
a8f9271
optionnal added to datatype
arng40 Feb 23, 2024
9ff17b9
update doxygen for ci
arng40 Feb 27, 2024
d90c8b5
more logs added
arng40 Feb 27, 2024
958d542
remove static_assert + constness
arng40 Feb 28, 2024
550ca26
Merge remote-tracking branch 'origin/develop' into feature/dudes/tabl…
arng40 Feb 28, 2024
f67e3d9
remove unused code
arng40 Feb 29, 2024
5b8689a
factorisation log pvt
arng40 Mar 4, 2024
0fa76e3
doxygen added
arng40 Mar 4, 2024
bb1ee01
remove test parent name with constitutive
arng40 Mar 4, 2024
aa2f789
remove unused code + add drawtostring method
arng40 Mar 5, 2024
8ff95c2
uncrustify
arng40 Mar 5, 2024
957c7d7
refacto Table first part
arng40 Mar 8, 2024
70d0a01
refortor still going up (missing doc and some minor refacto)
arng40 Mar 11, 2024
f5251f5
uncrustify + perfo example addded
arng40 Mar 11, 2024
1bec18e
update test + margin correction
arng40 Mar 11, 2024
1e45501
Merge remote-tracking branch 'origin/develop' into feature/dudes/tabl…
arng40 Mar 11, 2024
288f79e
Merge remote-tracking branch 'origin/feature/dudes/table-layout' into…
arng40 Mar 12, 2024
2054bd4
added Formatter function, correction on TableData
arng40 Mar 12, 2024
37e18b4
Delete table..cpp/hpp
arng40 Mar 12, 2024
5ff7c68
small correction
arng40 Mar 12, 2024
b360a16
doc updated
arng40 Mar 13, 2024
dd5f42f
TableData2D small refacto + opti
arng40 Mar 13, 2024
16b4ded
first update for log in table function
arng40 Mar 13, 2024
e8e89c2
Merge remote-tracking branch 'origin/feature/dudes/table-layout' into…
arng40 Mar 13, 2024
769beab
uncrustify + small correction
arng40 Mar 13, 2024
5fa478c
csv format / function correction
arng40 Mar 13, 2024
85494c7
remove dataToString with 2D table parameter
arng40 Mar 13, 2024
46e8d23
code opti
arng40 Mar 13, 2024
c1ba824
add 2D table test
arng40 Mar 13, 2024
14ea4f5
uncrustify
arng40 Mar 13, 2024
1271875
Alignment::middle by center and compile time verifcation added
arng40 Mar 14, 2024
d39fa00
PR review
arng40 Mar 14, 2024
c58be1e
2nd wave of pr review
arng40 Mar 14, 2024
1d4bdb4
update compile time verification for table value
arng40 Mar 15, 2024
0bff847
some update
arng40 Mar 15, 2024
8553441
pvt_log updated
arng40 Mar 15, 2024
7005d57
Merge remote-tracking branch 'origin/feature/dudes/table-layout' into…
arng40 Mar 15, 2024
22b16e9
update pvt log
arng40 Mar 15, 2024
429920c
add missing doc + uncrustify
arng40 Mar 15, 2024
965a972
constness update + refacto on text formatter
arng40 Mar 18, 2024
6e49ebc
PR correction
arng40 Mar 18, 2024
c1fb3dd
move has_formatter to format.hpp, doc correction
arng40 Mar 19, 2024
e0c6ca2
log level correction
arng40 Mar 19, 2024
7221c0f
perfo log correctly displayed
arng40 Mar 20, 2024
82098d8
remove ; to scope bracket
arng40 Mar 21, 2024
75ed072
doc correction format.hpp
arng40 Mar 21, 2024
3469920
format.hpp doc
arng40 Mar 21, 2024
052f1fa
last correction
arng40 Mar 21, 2024
fae723e
Merge remote-tracking branch 'origin/develop' into feature/dudes/tabl…
arng40 Mar 21, 2024
838f36e
cmake fix
arng40 Mar 25, 2024
1139117
test return string
arng40 Mar 25, 2024
13a6d09
fix hpp
arng40 Mar 25, 2024
cfeec17
fix error with string_view
arng40 Mar 25, 2024
f735cd1
uncrustify
arng40 Mar 25, 2024
755805a
Correction melvin PR
arng40 Mar 26, 2024
6264d87
correction review PR
arng40 Mar 27, 2024
21021c7
setMargin private
arng40 Mar 27, 2024
3a34e27
uncrustify
arng40 Mar 27, 2024
76789ba
remove constructor vector string
arng40 Mar 28, 2024
2d1cded
Table Data logs
arng40 Mar 28, 2024
8fedfd8
move table to common + pr correction
arng40 Mar 29, 2024
e5d2d3a
Merge remote-tracking branch 'origin/feature/dudes/table-layout' into…
arng40 Mar 29, 2024
13f975a
correction from merging
arng40 Mar 29, 2024
f7dbdcf
minor correction
arng40 Mar 29, 2024
4f34fc2
gracefully breaking your code :)
MelReyCG Apr 2, 2024
1cb2cc0
improving proposal + added TODOs
MelReyCG Apr 2, 2024
615a16d
Refactor conversion TableData2 => TableData1D
arng40 Apr 3, 2024
0100b33
Merge remote-tracking branch 'origin/feature/rey/transmissibilityOutp…
arng40 Apr 4, 2024
e66074e
Merge remote-tracking branch 'origin/develop' into pvt-logs-cp
arng40 Apr 4, 2024
7375665
refactor method to convert 2Dtable => 1D table
arng40 Apr 4, 2024
d590513
CI correction
arng40 Apr 4, 2024
7f6b79b
move table to fileIO
arng40 Apr 4, 2024
73f8374
update some doc
arng40 Apr 4, 2024
ae4968b
first part test 2D table crash
arng40 Apr 4, 2024
92a1644
add test/warning for table conversion 2D => 1D and warning for fillin…
arng40 Apr 5, 2024
e6b2e6d
ci correction
arng40 Apr 8, 2024
18db533
test ci correction for c++ < 17
arng40 Apr 9, 2024
31126e1
test ci table2D example 1
arng40 Apr 9, 2024
d481454
test ci Table2D test 1 & 2
arng40 Apr 9, 2024
6a7bfe8
test ci Table2D test 1 & 2 & 3
arng40 Apr 9, 2024
e01523b
add virtual destructor TableFormatter + minor variable refacto
arng40 Apr 10, 2024
978674e
bug correction + missing doc + test small refacto
arng40 Apr 10, 2024
da95c91
missig doc ...
arng40 Apr 10, 2024
79acc00
start management logError in table + todo refacto functions in TableF…
arng40 Apr 11, 2024
24f92d9
TableFormatter refacto + clean up
arng40 Apr 12, 2024
5a70c33
uncrustify
arng40 Apr 12, 2024
95f3a9d
small doc update
arng40 Apr 15, 2024
77351b9
some error management update
arng40 Apr 15, 2024
da67c05
renaming & simplifying
arng40 Apr 17, 2024
a9612bb
add case for fill all column in case of table 2D
arng40 Apr 17, 2024
0f1bbe2
Merge remote-tracking branch 'origin/develop' into feature/dudes/tabl…
arng40 Apr 17, 2024
89f859a
simplification
arng40 Apr 17, 2024
ef5085c
code optimization
arng40 Apr 18, 2024
294db78
remove useless std::move
arng40 Apr 18, 2024
9f23f62
refacto build separator + reviews
arng40 Apr 19, 2024
9809699
final review correction
arng40 Apr 19, 2024
66895d6
Merge remote-tracking branch 'origin/feature/dudes/table-layout' into…
arng40 Apr 22, 2024
46a6abe
method display layout added
arng40 Apr 22, 2024
9de9d63
small correction after merge
arng40 Apr 22, 2024
fe80c59
review correction #1
arng40 May 13, 2024
abb994e
variables renamed
arng40 May 17, 2024
c851b38
uncrustify + doc
arng40 May 23, 2024
0ae0c74
doc
arng40 May 23, 2024
86c0130
Merge remote-tracking branch 'origin/develop' into feature/dudes/tabl…
arng40 May 23, 2024
e9639ea
remove unused code
arng40 May 24, 2024
a48feb3
Merge remote-tracking branch 'origin/feature/dudes/table-layout' into…
arng40 May 27, 2024
924d955
syntax correction
arng40 May 27, 2024
5b530f0
Merge branch 'pvt-logs-cp' of https://github.com/GEOS-DEV/GEOS into p…
arng40 May 27, 2024
ac0cec8
variable correction
arng40 May 27, 2024
d6415a7
doc + code clarification
arng40 May 30, 2024
eaa8919
more code simplification
arng40 May 31, 2024
138541b
remove addErrorMsg function
arng40 Jun 3, 2024
3f74746
merge
arng40 Jun 3, 2024
d360dcf
Merge branch 'develop' into feature/dudes/table-layout
arng40 Jun 3, 2024
7aaf7b6
Merge remote-tracking branch 'origin/feature/dudes/table-layout' into…
arng40 Jun 3, 2024
1f24247
uncrustify
arng40 Jun 3, 2024
709c037
Merge remote-tracking branch 'origin/develop' into feature/dudes/pvt-…
arng40 Jun 5, 2024
fb795ba
Merge branch 'feature/dudes/pvt-output' of https://github.com/GEOS-DE…
arng40 Jun 5, 2024
b1ec0d0
begin refacto in table function for more clarity
arng40 Jun 5, 2024
b62161a
continue refato
arng40 Jun 5, 2024
98764af
refacto continuing ( commit works )
arng40 Jun 7, 2024
8091945
missing doxygen
arng40 Jun 7, 2024
1c8d7a9
correction fun name
arng40 Jun 7, 2024
2c17324
missing doc
arng40 Jun 10, 2024
0dddcf5
uncrustify + doc
arng40 Jun 10, 2024
7ee093b
Doxygen check
arng40 Jun 10, 2024
86fe90b
review correction + add pvtOptions struct
arng40 Jun 14, 2024
28b68f0
missing test correction
arng40 Jun 14, 2024
7f1b8ab
pvtOpt struct renaming + fct move to FlashModel
arng40 Jun 14, 2024
3da5e82
xsd/rst generation
arng40 Jun 14, 2024
fd605f7
review pavel
arng40 Jun 17, 2024
5cbaeec
renaming
arng40 Jun 18, 2024
684a405
review update
arng40 Jun 19, 2024
ae86942
revert a modif
arng40 Jun 19, 2024
c69fbee
uncrustify
arng40 Jun 19, 2024
49b52f3
Merge remote-tracking branch 'origin/develop' into feature/dudes/pvt-…
arng40 Jun 19, 2024
fa3218c
melvin review
arng40 Jun 26, 2024
5c808f8
fix
arng40 Jun 26, 2024
b39a84a
Merge remote-tracking branch 'origin/develop' into feature/dudes/pvt-…
arng40 Jun 27, 2024
76ee4dd
Merge remote-tracking branch 'origin/develop' into feature/dudes/pvt-…
arng40 Jul 2, 2024
57c23b2
pr pavel correction
arng40 Jul 4, 2024
4c4a3b8
Merge remote-tracking branch 'origin/develop' into feature/dudes/pvt-…
arng40 Jul 4, 2024
83c80b2
missing doxygen
arng40 Jul 4, 2024
5e8d0af
remove unused code
arng40 Jul 4, 2024
547bf9e
review melvin
arng40 Jul 8, 2024
37482aa
doxygen + uncrustify
arng40 Jul 8, 2024
7e7492d
revert space applied
arng40 Jul 8, 2024
d6c3a8a
uncrustify
arng40 Jul 8, 2024
c0c1d6b
nb character lines fix
arng40 Jul 12, 2024
ace4ce9
Merge remote-tracking branch 'origin/develop' into feature/dudes/pvt-…
arng40 Jul 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
TableFormatter refacto + clean up
  • Loading branch information
arng40 committed Apr 12, 2024
commit 24f92d99ac196a1186f1348df825b2efc2fcf6b6
18 changes: 3 additions & 15 deletions src/coreComponents/fileIO/Table/TableData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,14 @@ std::vector< std::vector< string > > const & TableData::getTableDataRows() const
return m_rows;
}

string const & TableData::getErrorMsgConversion() const
std::vector< string > const & TableData::getErrorMsgConversion() const
{
return errorMsgConversion;
}

void TableData::setErrorMsgConversion( string const & msg )
{
if( msg.empty() )
{
errorMsgConversion =+"\n" + msg;
return;
}
errorMsgConversion = msg;
errorMsgConversion.push_back( msg );
}

TableData2D::Conversion1D TableData2D::buildTableData( string_view targetUnit,
Expand Down Expand Up @@ -96,14 +91,7 @@ TableData2D::Conversion1D TableData2D::buildTableData( string_view targetUnit,

if( std::adjacent_find( rowsLength.begin(), rowsLength.end(), std::not_equal_to<>() ) != rowsLength.end() )
{
if( !flag )
{
tableData1D.tableData.setErrorMsgConversion( "Cell(s) are missing in row" );
}
else
{
tableData1D.tableData.setErrorMsgConversion( "Cell(s) are missing in row" );
}
tableData1D.tableData.setErrorMsgConversion( "Cell(s) are missing in row" );
}
return tableData1D;
}
Expand Down
6 changes: 3 additions & 3 deletions src/coreComponents/fileIO/Table/TableData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class TableData
* @brief Get the Error Msg Conversion string
* @return The error msg conversion
*/
string const & getErrorMsgConversion() const;
std::vector< string > const & getErrorMsgConversion() const;

/**
* @brief Set the Error Msg Conversion object
Expand All @@ -72,8 +72,8 @@ class TableData
/// vector containing all rows with cell values
std::vector< std::vector< string > > m_rows;

/// store error if there are any inconsistencies when we convert TableData2D => TableData
string errorMsgConversion;
/// store error if there are any inconsistencies related to the table, i e : when we convert TableData2D => TableData
std::vector< string > errorMsgConversion;

};

Expand Down
168 changes: 84 additions & 84 deletions src/coreComponents/fileIO/Table/TableFormatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* @file TableFormatter.cpp
*/

#include <numeric>
#include "TableFormatter.hpp"
namespace geos
{
Expand All @@ -26,7 +27,7 @@ TableFormatter::TableFormatter( TableLayout const & tableLayout ):

void TableFormatter::fillTableColumnsFromRows( std::vector< TableLayout::Column > & columns,
std::vector< std::vector< string > > const & rows,
string & msgTableError ) const
std::vector< string > & msgTableError ) const
{
bool isConsistent = true;
for( size_t idxRow = 0; idxRow < rows.size(); idxRow++ )
Expand All @@ -48,13 +49,9 @@ void TableFormatter::fillTableColumnsFromRows( std::vector< TableLayout::Column

if( !isConsistent )
{
if( msgTableError.empty())
if( msgTableError.size() == 0 )
{
msgTableError = "The number of columns displayed on the table does not match to the columns that have been initialized in TableLayout";
}
else
{
msgTableError += "\nThe number of columns displayed on the table does not match to the columns that have been initialized in TableLayout";
msgTableError.push_back( "The number of columns displayed on the table does not match to the columns that have been initialized in TableLayout" );
}
}
}
Expand Down Expand Up @@ -165,12 +162,14 @@ string TableTextFormatter::toString( TableData const & tableData ) const
string sectionSeparator;
std::vector< TableLayout::Column > columns = m_tableLayout.getColumns();
std::vector< std::vector< string > > tableDataRows = tableData.getTableDataRows();
string msgTableError = tableData.getErrorMsgConversion();
std::vector< string > msgTableError = tableData.getErrorMsgConversion();
integer const nbRows = tableDataRows.size();

formatColumnsFromLayout( columns, tableDataRows );
fillTableColumnsFromRows( columns, tableDataRows, msgTableError );
layoutToString( tableOutput, columns, nbRows, sectionSeparator, msgTableError );

tableOutput << '\n';
layoutToString( tableOutput, columns, msgTableError, sectionSeparator );
buildSectionRows( columns, sectionSeparator, tableOutput, nbRows, TableLayout::Section::values );
tableOutput << '\n';

Expand All @@ -179,35 +178,23 @@ string TableTextFormatter::toString( TableData const & tableData ) const

void TableTextFormatter::layoutToString( std::ostringstream & tableOutput,
std::vector< TableLayout::Column > & columns,
integer const nbRow,
string & sectionSeparator,
string & msgTableError ) const
std::vector< string > & msgTableError,
string & sectionSeparator ) const
{
string topRow = "";
string topSeparator;
size_t largestHeaderVectorSize = 0;
std::vector< std::vector< string > > splitHeader;
string tableTitle = string( m_tableLayout.getTitle());
string const tableTitle = string( m_tableLayout.getTitle());

parseAndStoreHeaderSections( columns, largestHeaderVectorSize, splitHeader );
adjustHeaderSizesAndStore( columns, largestHeaderVectorSize, splitHeader );

findAndSetMaxStringSize( columns, nbRow );
computeAndBuildSeparator( columns, topSeparator, sectionSeparator, msgTableError );
findAndSetMaxStringSize( columns );
computeTableMaxLineLength( columns, msgTableError );
buildTableSeparators( columns, topSeparator, sectionSeparator );

if( !msgTableError.empty())
{
buildTopRow( topRow, msgTableError, topSeparator, sectionSeparator );
tableOutput << topRow;
topRow.clear();
}

if( !tableTitle.empty())
{
buildTopRow( topRow, tableTitle, topSeparator, sectionSeparator );
tableOutput << topRow;
topRow.clear();
}
addTopRow( tableOutput, msgTableError, topSeparator, sectionSeparator );
addTopRow( tableOutput, tableTitle, topSeparator, sectionSeparator );

tableOutput << sectionSeparator + '\n';
buildSectionRows( columns, sectionSeparator, tableOutput, largestHeaderVectorSize, TableLayout::Section::header );
Expand Down Expand Up @@ -250,20 +237,19 @@ void TableTextFormatter::adjustHeaderSizesAndStore( std::vector< TableLayout::Co
}
}

void TableTextFormatter::findAndSetMaxStringSize( std::vector< TableLayout::Column > & columns,
size_t const & nbRows ) const
void TableTextFormatter::findAndSetMaxStringSize( std::vector< TableLayout::Column > & columns ) const
{
string maxStringSize = "";
string maxStringSize;
for( auto & column : columns )
{
auto it = std::max_element( column.m_parameter.splitColumnName.begin(),
column.m_parameter.splitColumnName.end(),
[]( const auto & a, const auto & b ) {
return a.size() < b.size();
} );

maxStringSize = *it;
for( size_t idxRow = 0; idxRow < nbRows; ++idxRow )

for( size_t idxRow = 0; idxRow < column.m_columnValues.size(); ++idxRow )
{
string cell = column.m_columnValues[idxRow];

Expand All @@ -277,20 +263,14 @@ void TableTextFormatter::findAndSetMaxStringSize( std::vector< TableLayout::Colu
}
}

void TableTextFormatter::computeAndSetMaxStringSize( std::vector< TableLayout::Column > & columns,
string::size_type const sectionlineLength,
string::size_type const titleLineLength ) const
void TableTextFormatter::recalculateMaxStringSize( std::vector< TableLayout::Column > & columns,
integer const extraLines ) const
{
integer extraLinesPerColumn;
integer extraLines;
integer newStringSize;

extraLines = titleLineLength - sectionlineLength;
extraLinesPerColumn = std::ceil( extraLines / columns.size() );
integer const extraLinesPerColumn = std::ceil( extraLines / columns.size() );

for( std::size_t idxColumn = 0; idxColumn < columns.size(); ++idxColumn )
{
newStringSize = extraLinesPerColumn + columns[idxColumn].m_maxStringSize.size();
integer newStringSize = extraLinesPerColumn + columns[idxColumn].m_maxStringSize.size();
if( idxColumn == columns.size() - 1 || columns.size() == 1 )
{
columns[idxColumn].m_maxStringSize = GEOS_FMT( "{:>{}}",
Expand All @@ -306,47 +286,28 @@ void TableTextFormatter::computeAndSetMaxStringSize( std::vector< TableLayout::C
}
}

void TableTextFormatter::computeAndBuildSeparator( std::vector< TableLayout::Column > & columns,
string & topSeparator,
string & sectionSeparator,
string & msgTableError ) const
void TableTextFormatter::computeTableMaxLineLength( std::vector< TableLayout::Column > & columns,
std::vector< string > & msgTableError ) const
{
integer const columnMargin = m_tableLayout.getColumnMargin();
integer const borderMargin = m_tableLayout.getBorderMargin();
integer const marginTitle = m_tableLayout.getMarginTitle();
string tableTitle = string( m_tableLayout.getTitle() );
string maxTopString = tableTitle;
string const tableTitle = string( m_tableLayout.getTitle() );

string::size_type sectionlineLength = 0;
string::size_type const titleLineLength = tableTitle.length() + ( marginTitle * 2 );
string::size_type maxTopLineLength = tableTitle.length() + ( marginTitle * 2 );
string::size_type msgTableErrorLength = marginTitle * 2;
string::size_type maxTopLineLength = titleLineLength;

integer const nbSpaceBetweenColumn = ( ( columns.size() - 1 ) * columnMargin ) + (borderMargin * 2);

if( !tableTitle.empty())
{
tableTitle = GEOS_FMT( "{:^{}}", tableTitle, titleLineLength );
}

if( !msgTableError.empty() )
if( msgTableError.size() != 0 )
{
std::vector< string > errorMsgs;
std::istringstream ss( msgTableError );
string msg;

while( getline( ss, msg, '\n' ))
{
errorMsgs.push_back( msg );
}

auto it = std::max_element( errorMsgs.begin(), errorMsgs.end(),
auto it = std::max_element( msgTableError.begin(), msgTableError.end(),
[]( const auto & a, const auto & b ) {
return a.size() < b.size();
} );
string maxStringSize = *it;

msgTableErrorLength += maxStringSize.size();
msgTableErrorLength += maxStringSize.size() + 1; // for \n set later

if( maxTopLineLength < msgTableErrorLength )
{
Expand All @@ -362,8 +323,17 @@ void TableTextFormatter::computeAndBuildSeparator( std::vector< TableLayout::Col

if( sectionlineLength < maxTopLineLength )
{
computeAndSetMaxStringSize( columns, sectionlineLength, maxTopLineLength );
integer const extraLines = maxTopLineLength - sectionlineLength;
recalculateMaxStringSize( columns, extraLines );
}
}

void TableTextFormatter::buildTableSeparators( std::vector< TableLayout::Column > & columns,
string & topSeparator,
string & sectionSeparator ) const
{
integer const columnMargin = m_tableLayout.getColumnMargin();
integer const borderMargin = m_tableLayout.getBorderMargin();

if( columns.size() == 1 )
{
Expand Down Expand Up @@ -393,16 +363,47 @@ void TableTextFormatter::computeAndBuildSeparator( std::vector< TableLayout::Col
}
}
topSeparator = GEOS_FMT( "+{:-<{}}+", "", sectionSeparator.size() - 2 ); // -2 for ++

}

void TableTextFormatter::addTopRow( std::ostringstream & tableOutput,
string const & msg,
string_view topSeparator,
string_view sectionSeparator ) const
{
if( !msg.empty())
{
buildTopRow( tableOutput, msg, topSeparator, sectionSeparator );
}
}

void TableTextFormatter::addTopRow( std::ostringstream & tableOutput,
std::vector< string > const & msg,
string_view topSeparator,
string_view sectionSeparator ) const
{
if( msg.size() != 0 )
{
string strConcat;
for( const std::string & str : msg )
{
if( !strConcat.empty())
{
strConcat += '\n';
}
strConcat += str;
}
buildTopRow( tableOutput, strConcat, topSeparator, sectionSeparator );
}
}

void TableTextFormatter::buildTopRow( string & topRow,
string & msg,

void TableTextFormatter::buildTopRow( std::ostringstream & tableOutput,
string const & msg,
string_view topSeparator,
string_view sectionSeparator ) const
{
std::cout << msg << std::endl;
size_t nbLine = std::count_if( msg.begin(), msg.end(), []( char c ){return c =='\n';} ) + 1;
std::cout << "nbLine " << nbLine << std::endl;
std::vector< string > messages;
std::istringstream ss( msg );
string subMsg;
Expand All @@ -412,17 +413,16 @@ void TableTextFormatter::buildTopRow( string & topRow,
messages.push_back( subMsg );
}

topRow += GEOS_FMT( "{}\n", topSeparator );
tableOutput << GEOS_FMT( "{}\n", topSeparator );
for( size_t idxLine = 0; idxLine< nbLine; ++idxLine )
{
topRow += GEOS_FMT( "{}", "|" );
topRow += buildCell( TableLayout::Alignment::center,
messages[idxLine],
(sectionSeparator.length() - 2) // -2 for ||
);
topRow += GEOS_FMT( "{}\n", "|" );
{
tableOutput << GEOS_FMT( "{}", "|" );
tableOutput << buildCell( TableLayout::Alignment::center,
messages[idxLine],
(sectionSeparator.length() - 2) // -2 for ||
);
tableOutput << GEOS_FMT( "{}\n", "|" );
}

}

void TableTextFormatter::buildSectionRows( std::vector< TableLayout::Column > const & columns,
Expand Down
Loading
Loading