Alexandria  2.18
Please provide a description of the project.
AsciiReader.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_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:
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 
124  AsciiReader(AsciiReader&&) = default;
126 
127  AsciiReader(const AsciiReader&) = delete;
128  AsciiReader& operator=(const AsciiReader&) = delete;
129 
133  virtual ~AsciiReader() = default;
134 
144  AsciiReader& setCommentIndicator(const std::string& indicator);
145 
161 
173 
187  const ColumnInfo& getInfo() override;
188 
192  std::string getComment() override;
193 
195  void skip(long rows) override;
196 
198  bool hasMoreRows() override;
199 
201  std::size_t rowsLeft() override;
202 
203 protected:
220  Table readImpl(long rows) override;
221 
222 private:
224 
225  void readColumnInfo();
226 
228  bool m_reading_started = false;
233 
234 }; /* End of AsciiReader class */
235 
236 } /* namespace Table */
237 } /* namespace Euclid */
238 
239 #include "_impl/AsciiReader.icpp"
240 
241 #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:254
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:70
Euclid::Table::AsciiReader::setCommentIndicator
AsciiReader & setCommentIndicator(const std::string &indicator)
Set the comment indicator.
Definition: AsciiReader.cpp:58
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:230
Euclid::Table::AsciiReader::AsciiReader
AsciiReader(std::istream &stream)
Constructs an AsciiReader which reads from the given stream.
Definition: AsciiReader.cpp:51
Euclid::Table::AsciiReader::m_comment
std::string m_comment
Definition: AsciiReader.h:229
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:227
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:232
Euclid::Table::AsciiReader::getComment
std::string getComment() override
Definition: AsciiReader.cpp:180
Euclid::Table::AsciiReader::AsciiReader
AsciiReader(AsciiReader &&)=default
Euclid::Table::AsciiReader::rowsLeft
std::size_t rowsLeft() override
Implements the TableReader::rowsLeft() contract.
Definition: AsciiReader.cpp:258
Euclid::Table::AsciiReader::skip
void skip(long rows) override
Implements the TableReader::skip() contract.
Definition: AsciiReader.cpp:236
Euclid::Table::AsciiReader::getInfo
const ColumnInfo & getInfo() override
Returns the column information of the table.
Definition: AsciiReader.cpp:167
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:198
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:231
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:99
Euclid::Table::AsciiReader::m_reading_started
bool m_reading_started
Definition: AsciiReader.h:228
AsciiReader.icpp