Alexandria  2.16
Please provide a description of the project.
AsciiWriter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2020 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:
83 
109  template <typename StreamType, typename... Args>
110  static AsciiWriter create(Args&&... args);
111 
113  explicit AsciiWriter(std::ostream& stream);
114 
117  explicit AsciiWriter(const std::string& filename);
118 
119  AsciiWriter(AsciiWriter&&) = default;
121 
122  AsciiWriter(const AsciiWriter&) = delete;
123  AsciiWriter& operator=(const AsciiWriter&) = delete;
124 
128  virtual ~AsciiWriter() = default;
129 
143  AsciiWriter& setCommentIndicator(const std::string& indicator);
144 
154  AsciiWriter& showColumnInfo(bool show);
155 
167  void addComment(const std::string& message) override;
168 
169 protected:
170 
173  void init(const Table& table) override;
174 
177  void append(const Table& table) override;
178 
179 private:
180 
182 
184  bool m_writing_started = false;
185  bool m_initialized = false;
187  bool m_show_column_info = true;
189 
190 }; // End of AsciiWriter class
191 
192 } // namespace Table
193 } // namespace Euclid
194 
196 
197 #endif
Euclid::Table::AsciiWriter::setCommentIndicator
AsciiWriter & setCommentIndicator(const std::string &indicator)
Set the comment indicator.
Definition: AsciiWriter.cpp:45
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:184
Euclid::Table::AsciiWriter::m_stream_holder
std::unique_ptr< InstOrRefHolder< std::ostream > > m_stream_holder
Definition: AsciiWriter.h:183
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:57
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:66
std::ostream
STL class.
Euclid::Table::AsciiWriter::operator=
AsciiWriter & operator=(const AsciiWriter &)=delete
Euclid::Table::AsciiWriter::m_initialized
bool m_initialized
Definition: AsciiWriter.h:185
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:186
Euclid::Table::AsciiWriter::init
void init(const Table &table) override
Definition: AsciiWriter.cpp:81
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:118
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:188
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:187