Alexandria  2.16
Please provide a description of the project.
AsciiReader.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_ASCIIREADER_H
26 #define _TABLE_ASCIIREADER_H
27 
29 #include "Table/TableReader.h"
30 
31 namespace Euclid {
32 namespace Table {
33 
87 class AsciiReader : public TableReader {
88 
89 public:
90 
116  template <typename StreamType, typename... Args>
117  static AsciiReader create(Args&&... args);
118 
120  explicit AsciiReader(std::istream& stream);
121 
123  explicit AsciiReader(const std::string& filename);
124 
125  AsciiReader(AsciiReader&&) = default;
126  AsciiReader& operator=(AsciiReader&&) = default;
127 
128  AsciiReader(const AsciiReader&) = delete;
129  AsciiReader& operator=(const AsciiReader&) = delete;
130 
134  virtual ~AsciiReader() = default;
135 
145  AsciiReader& setCommentIndicator(const std::string& indicator);
146 
162 
174 
188  const ColumnInfo& getInfo() override;
189 
193  std::string getComment() override;
194 
196  void skip(long rows) override;
197 
199  bool hasMoreRows() override;
200 
202  std::size_t rowsLeft() override;
203 
204 protected:
205 
222  Table readImpl(long rows) override;
223 
224 private:
225 
227 
228  void readColumnInfo();
229 
231  bool m_reading_started = false;
236 
237 }; /* End of AsciiReader class */
238 
239 } /* namespace Table */
240 } /* namespace Euclid */
241 
242 #include "_impl/AsciiReader.icpp"
243 
244 #endif
std::vector< std::type_index > m_column_types
Definition: AsciiReader.h:233
Interface for classes reading tables.
Definition: TableReader.h:48
AsciiReader & setCommentIndicator(const std::string &indicator)
Set the comment indicator.
Definition: AsciiReader.cpp:56
static AsciiReader create(Args &&... args)
Constructs an AsciiReader which contains an object of type StreamType.
std::shared_ptr< ColumnInfo > m_column_info
Definition: AsciiReader.h:235
STL class.
AsciiReader & operator=(AsciiReader &&)=default
const ColumnInfo & getInfo() override
Returns the column information of the table.
STL class.
std::size_t rowsLeft() override
Implements the TableReader::rowsLeft() contract.
std::unique_ptr< InstOrRefHolder< std::istream > > m_stream_holder
Definition: AsciiReader.h:230
Table readImpl(long rows) override
Reads the next rows into a Table.
AsciiReader(std::istream &stream)
Constructs an AsciiReader which reads from the given stream.
Definition: AsciiReader.cpp:46
TableReader implementation for reading ASCII tables from streams.
Definition: AsciiReader.h:87
Represents a table.
Definition: Table.h:49
void skip(long rows) override
Implements the TableReader::skip() contract.
Provides information about the columns of a Table.
Definition: ColumnInfo.h:52
STL class.
AsciiReader & fixColumnTypes(std::vector< std::type_index > column_types)
Overrides the automatically detected column types.
Definition: AsciiReader.cpp:98
std::vector< std::string > m_column_names
Definition: AsciiReader.h:234
std::string getComment() override
bool hasMoreRows() override
Implements the TableReader::hasMoreRows() contract.
virtual ~AsciiReader()=default
Destructor.
AsciiReader & fixColumnNames(std::vector< std::string > column_names)
Overrides the automatically detected column names.
Definition: AsciiReader.cpp:68