Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
AsciiReader.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2012-2022 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_ASCIIREADER_H
26#define _TABLE_ASCIIREADER_H
27
29#include "Table/TableReader.h"
30
31namespace Euclid {
32namespace Table {
33
87class AsciiReader : public TableReader {
88
89public:
115 template <typename StreamType, typename... Args>
116 static AsciiReader create(Args&&... args);
117
119 explicit AsciiReader(std::istream& stream);
120
122 explicit AsciiReader(const std::string& filename);
123
126
127 AsciiReader(const AsciiReader&) = delete;
129
133 virtual ~AsciiReader() = default;
134
145
161
173
175
189 const ColumnInfo& getInfo() override;
190
194 std::string getComment() override;
195
197 void skip(long rows) override;
198
200 bool hasMoreRows() override;
201
203 std::size_t rowsLeft() override;
204
205protected:
222 Table readImpl(long rows) override;
223
224private:
226
227 void readColumnInfo();
228
230 bool m_reading_started = false;
235
236}; /* End of AsciiReader class */
237
238} /* namespace Table */
239} /* namespace Euclid */
240
241#include "_impl/AsciiReader.icpp"
242
243#endif
TableReader implementation for reading ASCII tables from streams.
Definition AsciiReader.h:87
AsciiReader(const AsciiReader &)=delete
static AsciiReader create(Args &&... args)
Constructs an AsciiReader which contains an object of type StreamType.
void skip(long rows) override
Implements the TableReader::skip() contract.
virtual ~AsciiReader()=default
Destructor.
AsciiReader & operator=(AsciiReader &&)=default
std::string getComment() override
AsciiReader & fixColumnNames(std::vector< std::string > column_names)
Overrides the automatically detected column names.
std::vector< std::string > m_column_names
AsciiReader & fixColumnTypes(std::vector< std::type_index > column_types)
Overrides the automatically detected column types.
Table readImpl(long rows) override
Reads the next rows into a Table.
std::vector< std::pair< std::type_index, std::size_t > > m_column_types
bool hasMoreRows() override
Implements the TableReader::hasMoreRows() contract.
std::shared_ptr< ColumnInfo > m_column_info
const ColumnInfo & getInfo() override
Returns the column information of the table.
std::size_t rowsLeft() override
Implements the TableReader::rowsLeft() contract.
std::unique_ptr< InstOrRefHolder< std::istream > > m_stream_holder
AsciiReader(AsciiReader &&)=default
AsciiReader & operator=(const AsciiReader &)=delete
AsciiReader & setCommentIndicator(const std::string &indicator)
Set the comment indicator.
Provides information about the columns of a Table.
Definition ColumnInfo.h:52
Interface for classes reading tables.
Definition TableReader.h:48
Represents a table.
Definition Table.h:49