Alexandria  2.14.1
Please provide a description of the project.
AsciiReaderHelper.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_ASCIIREADERHELPER_H
26 #define TABLE_ASCIIREADERHELPER_H
27 
28 #include <istream>
29 #include <string>
30 #include <typeindex>
31 #include <map>
32 
33 
34 #include "ElementsKernel/Export.h"
35 #include "Table/Row.h"
36 
37 namespace Euclid {
38 namespace Table {
39 
49 public:
50  StreamRewinder(std::istream& stream) : m_stream(stream), m_state(stream.exceptions()), m_position(stream.tellg()) { }
52  m_stream.clear();
55  }
56 private:
58  std::ios::iostate m_state;
60 };
61 
76 ELEMENTS_API size_t countColumns(std::istream& in, const std::string& comment);
77 
95  std::istream& in, const std::string& comment);
96 
113  const std::string& comment,
114  size_t columns_number);
115 
130 
131 ELEMENTS_API bool hasNextRow(std::istream& in, const std::string& comment);
132 
134 
135 }
136 } // end of namespace Euclid
137 
138 #endif /* TABLE_ASCIIREADERHELPER_H */
std::istream::setstate
T setstate(T... args)
Euclid::Table::StreamRewinder::~StreamRewinder
~StreamRewinder()
Definition: AsciiReaderHelper.h:51
Euclid::Table::convertToCellType
Row::cell_type convertToCellType(const std::string &value, std::type_index type)
Converts the given value to a Row::cell_type of the given type.
Definition: AsciiReaderHelper.cpp:292
std::string
STL class.
Euclid::Table::countRemainingRows
std::size_t countRemainingRows(std::istream &in, const std::string &comment)
Definition: AsciiReaderHelper.cpp:355
Export.h
Euclid::Table::StreamRewinder::m_position
int m_position
Definition: AsciiReaderHelper.h:59
Euclid::Table::autoDetectColumnDescriptions
std::map< std::string, ColumnDescription > autoDetectColumnDescriptions(std::istream &in, const std::string &comment)
Reads the column descriptions of the given stream.
Definition: AsciiReaderHelper.cpp:111
std::vector< std::string >
std::type_index
Row.h
std::istream::clear
T clear(T... args)
Euclid::Table::hasNextRow
bool hasNextRow(std::istream &in, const std::string &comment)
Definition: AsciiReaderHelper.cpp:338
ELEMENTS_API
#define ELEMENTS_API
Euclid::Table::StreamRewinder::m_stream
std::istream & m_stream
Definition: AsciiReaderHelper.h:57
Euclid::Table::autoDetectColumnNames
std::vector< std::string > autoDetectColumnNames(std::istream &in, const std::string &comment, size_t columns_number)
Reads the column names of the given stream.
Definition: AsciiReaderHelper.cpp:178
std::map
STL class.
Euclid::Table::Row::cell_type
boost::variant< bool, int32_t, int64_t, float, double, std::string, std::vector< bool >, std::vector< int32_t >, std::vector< int64_t >, std::vector< float >, std::vector< double >, NdArray::NdArray< bool >, NdArray::NdArray< int32_t >, NdArray::NdArray< int64_t >, NdArray::NdArray< float >, NdArray::NdArray< double > > cell_type
The possible cell types.
Definition: Row.h:84
Euclid::Table::StreamRewinder
This class gets a stream as argument during construction and when it is deleted it sets the position ...
Definition: AsciiReaderHelper.h:48
Euclid::Table::StreamRewinder::m_state
std::ios::iostate m_state
Definition: AsciiReaderHelper.h:58
std::size_t
Euclid::Table::countColumns
size_t countColumns(std::istream &in, const std::string &comment)
Returns the number of whitespace separated tokens of the first non commented line.
Definition: AsciiReaderHelper.cpp:45
std::istream::seekg
T seekg(T... args)
std::istream
STL class.
Euclid
Definition: InstOrRefHolder.h:29
Euclid::Table::StreamRewinder::StreamRewinder
StreamRewinder(std::istream &stream)
Definition: AsciiReaderHelper.h:50