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;
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
Euclid::Table::AsciiReader::AsciiReader
AsciiReader(const AsciiReader &)=delete
Euclid::Table::AsciiReader::~AsciiReader
virtual ~AsciiReader()=default
Destructor.
std::string
STL class.
std::shared_ptr
STL class.
TableReader.h
Euclid::Table::AsciiReader::hasMoreRows
bool hasMoreRows() override
Implements the TableReader::hasMoreRows() contract.
Definition: AsciiReader.cpp:258
std::vector< std::string >
Euclid::Table::AsciiReader::fixColumnNames
AsciiReader & fixColumnNames(std::vector< std::string > column_names)
Overrides the automatically detected column names.
Definition: AsciiReader.cpp:68
Euclid::Table::AsciiReader::setCommentIndicator
AsciiReader & setCommentIndicator(const std::string &indicator)
Set the comment indicator.
Definition: AsciiReader.cpp:56
Euclid::InstOrRefHolder< std::istream >
Euclid::Table::AsciiReader::operator=
AsciiReader & operator=(AsciiReader &&)=default
Euclid::Table::AsciiReader::m_column_types
std::vector< std::type_index > m_column_types
Definition: AsciiReader.h:233
Euclid::Table::AsciiReader::AsciiReader
AsciiReader(std::istream &stream)
Constructs an AsciiReader which reads from the given stream.
Definition: AsciiReader.cpp:46
Euclid::Table::AsciiReader::m_comment
std::string m_comment
Definition: AsciiReader.h:232
Euclid::Table::AsciiReader::create
static AsciiReader create(Args &&... args)
Constructs an AsciiReader which contains an object of type StreamType.
Euclid::Table::AsciiReader::m_stream_holder
std::unique_ptr< InstOrRefHolder< std::istream > > m_stream_holder
Definition: AsciiReader.h:230
Euclid::Table::ColumnInfo
Provides information about the columns of a Table.
Definition: ColumnInfo.h:52
InstOrRefHolder.h
Euclid::Table::AsciiReader::readColumnInfo
void readColumnInfo()
Definition: AsciiReader.cpp:114
Euclid::Table::AsciiReader::m_column_info
std::shared_ptr< ColumnInfo > m_column_info
Definition: AsciiReader.h:235
Euclid::Table::AsciiReader::getComment
std::string getComment() override
Definition: AsciiReader.cpp:184
Euclid::Table::AsciiReader::AsciiReader
AsciiReader(AsciiReader &&)=default
Euclid::Table::AsciiReader::rowsLeft
std::size_t rowsLeft() override
Implements the TableReader::rowsLeft() contract.
Definition: AsciiReader.cpp:262
Euclid::Table::AsciiReader::skip
void skip(long rows) override
Implements the TableReader::skip() contract.
Definition: AsciiReader.cpp:240
Euclid::Table::AsciiReader::getInfo
const ColumnInfo & getInfo() override
Returns the column information of the table.
Definition: AsciiReader.cpp:171
Euclid::Table::AsciiReader
TableReader implementation for reading ASCII tables from streams.
Definition: AsciiReader.h:87
Euclid::Table::AsciiReader::operator=
AsciiReader & operator=(const AsciiReader &)=delete
Euclid::Table::AsciiReader::readImpl
Table readImpl(long rows) override
Reads the next rows into a Table.
Definition: AsciiReader.cpp:202
Euclid::Table::TableReader
Interface for classes reading tables.
Definition: TableReader.h:48
Euclid::Table::Table
Represents a table.
Definition: Table.h:49
std::size_t
Euclid::Table::AsciiReader::m_column_names
std::vector< std::string > m_column_names
Definition: AsciiReader.h:234
std::istream
STL class.
std::unique_ptr
STL class.
Euclid
Definition: InstOrRefHolder.h:29
Euclid::Table::AsciiReader::fixColumnTypes
AsciiReader & fixColumnTypes(std::vector< std::type_index > column_types)
Overrides the automatically detected column types.
Definition: AsciiReader.cpp:98
Euclid::Table::AsciiReader::m_reading_started
bool m_reading_started
Definition: AsciiReader.h:231
AsciiReader.icpp