Alexandria  2.19
Please provide a description of the project.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AsciiReaderHelper.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_ASCIIREADERHELPER_H
26 #define TABLE_ASCIIREADERHELPER_H
27 
28 #include <istream>
29 #include <map>
30 #include <string>
31 #include <typeindex>
32 
33 #include "ElementsKernel/Export.h"
34 #include "Table/Row.h"
35 
36 namespace Euclid {
37 namespace Table {
38 
48 public:
49  explicit StreamRewinder(std::istream& stream) : m_stream(stream), m_state(stream.exceptions()), m_position(stream.tellg()) {}
51  m_stream.clear();
54  }
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 
111 ELEMENTS_API std::vector<std::string> autoDetectColumnNames(std::istream& in, const std::string& comment, size_t columns_number);
112 
127 
128 ELEMENTS_API bool hasNextRow(std::istream& in, const std::string& comment);
129 
131 
132 } // namespace Table
133 } // end of namespace Euclid
134 
135 #endif /* TABLE_ASCIIREADERHELPER_H */
std::size_t countRemainingRows(std::istream &in, const std::string &comment)
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.
STL class.
STL class.
T seekg(T...args)
STL class.
#define ELEMENTS_API
T clear(T...args)
std::map< std::string, ColumnDescription > autoDetectColumnDescriptions(std::istream &in, const std::string &comment)
Reads the column descriptions of the given stream.
This class gets a stream as argument during construction and when it is deleted it sets the position ...
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:71
bool hasNextRow(std::istream &in, const std::string &comment)
T setstate(T...args)
StreamRewinder(std::istream &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.