Alexandria  2.18
Please provide a description of the project.
AsciiWriter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2021 Euclid Science Ground Segment
3  *
4  * This library is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU Lesser General Public License as published by the Free
6  * Software Foundation; either version 3.0 of the License, or (at your option)
7  * any later version.
8  *
9  * This library is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
25 #ifndef _TABLE_ASCIIWRITER_H
26 #define _TABLE_ASCIIWRITER_H
27 
29 #include "Table/TableWriter.h"
30 
31 namespace Euclid {
32 namespace Table {
33 
80 class AsciiWriter : public TableWriter {
81 
82 public:
108  template <typename StreamType, typename... Args>
109  static AsciiWriter create(Args&&... args);
110 
112  explicit AsciiWriter(std::ostream& stream);
113 
116  explicit AsciiWriter(const std::string& filename);
117 
118  AsciiWriter(AsciiWriter&&) = default;
120 
121  AsciiWriter(const AsciiWriter&) = delete;
122  AsciiWriter& operator=(const AsciiWriter&) = delete;
123 
127  virtual ~AsciiWriter() = default;
128 
142  AsciiWriter& setCommentIndicator(const std::string& indicator);
143 
153  AsciiWriter& showColumnInfo(bool show);
154 
166  void addComment(const std::string& message) override;
167 
168 protected:
171  void init(const Table& table) override;
172 
175  void append(const Table& table) override;
176 
177 private:
179 
181  bool m_writing_started = false;
182  bool m_initialized = false;
184  bool m_show_column_info = true;
186 
187 }; // End of AsciiWriter class
188 
189 } // namespace Table
190 } // namespace Euclid
191 
193 
194 #endif
Euclid::Table::AsciiWriter::setCommentIndicator
AsciiWriter & setCommentIndicator(const std::string &indicator)
Set the comment indicator.
Definition: AsciiWriter.cpp:42
Euclid::Table::AsciiWriter
TableWriter implementation for writing ASCII tables to streams.
Definition: AsciiWriter.h:80
std::string
STL class.
Euclid::Table::AsciiWriter::m_writing_started
bool m_writing_started
Definition: AsciiWriter.h:181
Euclid::Table::AsciiWriter::m_stream_holder
std::unique_ptr< InstOrRefHolder< std::ostream > > m_stream_holder
Definition: AsciiWriter.h:180
std::vector< size_t >
Euclid::InstOrRefHolder< std::ostream >
Euclid::Table::AsciiWriter::showColumnInfo
AsciiWriter & showColumnInfo(bool show)
Sets if the column information will be written to the stream.
Definition: AsciiWriter.cpp:54
AsciiWriter.icpp
Euclid::Table::AsciiWriter::AsciiWriter
AsciiWriter(const AsciiWriter &)=delete
Euclid::Table::AsciiWriter::~AsciiWriter
virtual ~AsciiWriter()=default
Destructor.
InstOrRefHolder.h
Euclid::Table::AsciiWriter::addComment
void addComment(const std::string &message) override
Adds a comment to the stream.
Definition: AsciiWriter.cpp:63
std::ostream
STL class.
Euclid::Table::AsciiWriter::operator=
AsciiWriter & operator=(const AsciiWriter &)=delete
Euclid::Table::AsciiWriter::m_initialized
bool m_initialized
Definition: AsciiWriter.h:182
Euclid::Table::AsciiWriter::operator=
AsciiWriter & operator=(AsciiWriter &&)=default
Euclid::Table::AsciiWriter::create
static AsciiWriter create(Args &&... args)
Constructs an AsciiWriter which contains an object of type StreamType.
TableWriter.h
Euclid::Table::AsciiWriter::m_comment
std::string m_comment
Definition: AsciiWriter.h:183
Euclid::Table::AsciiWriter::init
void init(const Table &table) override
Definition: AsciiWriter.cpp:78
Euclid::Table::TableWriter
Interface for classes writing tables.
Definition: TableWriter.h:49
Euclid::Table::AsciiWriter::AsciiWriter
AsciiWriter(AsciiWriter &&)=default
Euclid::Table::AsciiWriter::append
void append(const Table &table) override
Definition: AsciiWriter.cpp:115
Euclid::Table::Table
Represents a table.
Definition: Table.h:49
std::unique_ptr
STL class.
Euclid
Definition: InstOrRefHolder.h:29
Euclid::Table::AsciiWriter::m_column_lengths
std::vector< size_t > m_column_lengths
Definition: AsciiWriter.h:185
Euclid::Table::AsciiWriter::AsciiWriter
AsciiWriter(std::ostream &stream)
Constructs an AsciiWriter which writes to the given stream.
Definition: AsciiWriter.cpp:35
Euclid::Table::AsciiWriter::m_show_column_info
bool m_show_column_info
Definition: AsciiWriter.h:184