Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
AsciiReaderHelper.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_ASCIIREADERHELPER_H
26#define TABLE_ASCIIREADERHELPER_H
27
28#include <istream>
29#include <map>
30#include <string>
31#include <typeindex>
32
34#include "Table/Row.h"
35
36namespace Euclid {
37namespace Table {
38
48public:
49 explicit StreamRewinder(std::istream& stream)
50 : m_stream(stream), m_state(stream.exceptions()), m_position(stream.tellg()) {}
56
57private:
59 std::ios::iostate m_state;
61};
62
77ELEMENTS_API size_t countColumns(std::istream& in, const std::string& comment);
78
96 const std::string& comment);
97
114 size_t columns_number);
115
130
136ELEMENTS_API bool hasNextRow(std::istream& in, const std::string& comment);
137
145
152
159
166
167} // namespace Table
168} // end of namespace Euclid
169
170#endif /* TABLE_ASCIIREADERHELPER_H */
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< int32_t >, NdArray::NdArray< int64_t >, NdArray::NdArray< float >, NdArray::NdArray< double > > cell_type
The possible cell types.
Definition Row.h:64
This class gets a stream as argument during construction and when it is deleted it sets the position ...
StreamRewinder(std::istream &stream)
T clear(T... args)
#define ELEMENTS_API
std::vector< std::string > splitLine(std::string line, const std::string &comment)
bool hasNextRow(std::istream &in, const std::string &comment)
std::map< std::string, ColumnDescription > autoDetectColumnDescriptions(std::istream &in, const std::string &comment)
Reads the column descriptions of the given stream.
size_t countColumns(std::istream &in, const std::string &comment)
Returns the number of whitespace separated tokens of the first non commented line.
std::vector< std::string > autoDetectColumnNames(std::istream &in, const std::string &comment, size_t columns_number)
Reads the column names of the given stream.
std::pair< std::type_index, std::size_t > guessColumnType(const std::string &token)
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.
std::vector< std::string > firstDataLine(std::istream &in, const std::string &comment)
std::size_t countRemainingRows(std::istream &in, const std::string &comment)
T seekg(T... args)
T setstate(T... args)