2019-06-23 11:05:51 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2019- Equinor ASA
|
|
|
|
//
|
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-10-15 04:30:06 -05:00
|
|
|
#include "RifTextDataTableFormatter.h"
|
2019-06-23 11:05:51 -05:00
|
|
|
|
|
|
|
//==================================================================================================
|
|
|
|
//
|
|
|
|
// CSV text formatter using the same pattern as RifEclipseDataTableFormatter so it will be easy to switch formatters
|
|
|
|
//
|
|
|
|
//==================================================================================================
|
|
|
|
class RifCsvDataTableFormatter
|
|
|
|
{
|
|
|
|
public:
|
2019-09-06 03:40:57 -05:00
|
|
|
RifCsvDataTableFormatter( QTextStream& out, const QString fieldSeparator = "," );
|
2019-06-23 11:05:51 -05:00
|
|
|
|
2023-10-11 01:54:52 -05:00
|
|
|
void setUseQuotes( bool useQuotes );
|
|
|
|
|
2019-10-15 04:30:06 -05:00
|
|
|
RifCsvDataTableFormatter& header( const std::vector<RifTextDataTableColumn>& tableHeader );
|
2019-09-06 03:40:57 -05:00
|
|
|
RifCsvDataTableFormatter& add( const QString& str );
|
|
|
|
RifCsvDataTableFormatter& add( double num );
|
|
|
|
RifCsvDataTableFormatter& add( int num );
|
|
|
|
RifCsvDataTableFormatter& add( size_t num );
|
2019-06-23 11:05:51 -05:00
|
|
|
void rowCompleted();
|
|
|
|
void tableCompleted();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void outputBuffer();
|
2024-03-04 00:28:04 -06:00
|
|
|
bool isAnyTextInHeader() const;
|
2019-06-23 11:05:51 -05:00
|
|
|
|
|
|
|
private:
|
2019-10-15 04:30:06 -05:00
|
|
|
QTextStream& m_out;
|
|
|
|
std::vector<RifTextDataTableColumn> m_columnHeaders;
|
|
|
|
std::vector<RifTextDataTableLine> m_buffer;
|
|
|
|
std::vector<QString> m_lineBuffer;
|
|
|
|
QString m_fieldSeparator;
|
2023-10-11 01:54:52 -05:00
|
|
|
bool m_useQuotes;
|
2019-06-23 11:05:51 -05:00
|
|
|
};
|