Alexandria  2.25.0
SDC-CH common library for the Euclid project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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;
119  AsciiWriter& operator=(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
TableWriter implementation for writing ASCII tables to streams.
Definition: AsciiWriter.h:80
AsciiWriter & showColumnInfo(bool show)
Sets if the column information will be written to the stream.
Definition: AsciiWriter.cpp:54
AsciiWriter(std::ostream &stream)
Constructs an AsciiWriter which writes to the given stream.
Definition: AsciiWriter.cpp:35
static AsciiWriter create(Args &&...args)
Constructs an AsciiWriter which contains an object of type StreamType.
void addComment(const std::string &message) override
Adds a comment to the stream.
Definition: AsciiWriter.cpp:63
AsciiWriter & operator=(AsciiWriter &&)=default
STL class.
virtual ~AsciiWriter()=default
Destructor.
void append(const Table &table) override
Represents a table.
Definition: Table.h:49
STL class.
std::vector< size_t > m_column_lengths
Definition: AsciiWriter.h:185
Interface for classes writing tables.
Definition: TableWriter.h:49
void init(const Table &table) override
Definition: AsciiWriter.cpp:78
AsciiWriter & setCommentIndicator(const std::string &indicator)
Set the comment indicator.
Definition: AsciiWriter.cpp:42
STL class.
std::unique_ptr< InstOrRefHolder< std::ostream > > m_stream_holder
Definition: AsciiWriter.h:180