IODA Bundle
TextReader.h
Go to the documentation of this file.
1
/*
2
* (C) Copyright 1996-2012 ECMWF.
3
*
4
* This software is licensed under the terms of the Apache Licence Version 2.0
5
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6
* In applying this licence, ECMWF does not waive the privileges and immunities
7
* granted to it by virtue of its status as an intergovernmental organisation nor
8
* does it submit to any jurisdiction.
9
*/
10
11
///
12
/// @author Piotr Kuchta
13
/// @author Simon Smart
14
/// @date Oct 2010
15
16
#ifndef odc_TextReader_H
17
#define odc_TextReader_H
18
19
#ifdef SWIGPYTHON
20
#include <Python.h>
21
#endif
22
23
#include "eckit/memory/NonCopyable.h"
24
25
#include "
odc/IteratorProxy.h
"
26
27
namespace
eckit
{
class
PathName; }
28
29
namespace
odc
{
30
31
//----------------------------------------------------------------------------------------------------------------------
32
33
class
TextReaderIterator;
34
35
class
TextReader
:
private
eckit::NonCopyable
36
{
37
public
:
38
typedef
IteratorProxy<TextReaderIterator,TextReader,double>
iterator
;
39
typedef
iterator::Row
row
;
40
41
TextReader
(std::istream &,
const
std::string&
delimiter
);
42
TextReader
(
const
std::string& path,
const
std::string&
delimiter
);
43
44
TextReader
(
TextReader
&&);
45
TextReader
&
operator=
(
TextReader
&&);
46
47
virtual
~TextReader
();
48
49
iterator
begin
();
50
iterator
end
()
const
;
51
52
std::istream&
stream
() {
return
*
in_
; }
53
54
// For C API
55
// TextReaderIterator* createReadIterator(const eckit::PathName&);
56
57
#ifdef SWIGPYTHON
58
iterator
__iter__() {
return
begin
(); }
59
#endif
60
61
const
std::string&
delimiter
() {
return
delimiter_
; }
62
private
:
63
64
std::istream*
in_
;
65
bool
deleteDataHandle_
;
66
std::string
delimiter_
;
67
68
// This is a bit nasty. The TextReader currently assumes that the data will only be
69
// iterated _once_ (hence initiated by an istream). Therefore only create the iterator
70
// once so that the MetaData doesn't get read from the stream multiple times.
71
iterator
iteratorSingleton_
;
72
73
friend
class
odc::IteratorProxy
<
odc
::
TextReaderIterator
,
odc::TextReader
,double>;
74
friend class
odc::TextReaderIterator
;
75
};
76
77
//----------------------------------------------------------------------------------------------------------------------
78
79
}
// namespace odc
80
81
#endif
IteratorProxy.h
odc::IteratorProxy< TextReaderIterator, TextReader, double >
odc::Row_
Definition:
IteratorProxy.h:68
odc::TextReader
Definition:
TextReader.h:36
odc::TextReader::delimiter
const std::string & delimiter()
Definition:
TextReader.h:61
odc::TextReader::delimiter_
std::string delimiter_
Definition:
TextReader.h:66
odc::TextReader::row
iterator::Row row
Definition:
TextReader.h:39
odc::TextReader::operator=
TextReader & operator=(TextReader &&)
Definition:
TextReader.cc:47
odc::TextReader::iteratorSingleton_
iterator iteratorSingleton_
Definition:
TextReader.h:71
odc::TextReader::deleteDataHandle_
bool deleteDataHandle_
Definition:
TextReader.h:65
odc::TextReader::stream
std::istream & stream()
Definition:
TextReader.h:52
odc::TextReader::end
iterator end() const
Definition:
TextReader.cc:77
odc::TextReader::~TextReader
virtual ~TextReader()
Definition:
TextReader.cc:55
odc::TextReader::in_
std::istream * in_
Definition:
TextReader.h:64
odc::TextReader::begin
iterator begin()
Definition:
TextReader.cc:71
odc::TextReader::iterator
IteratorProxy< TextReaderIterator, TextReader, double > iterator
Definition:
TextReader.h:38
odc::TextReader::TextReader
TextReader(std::istream &, const std::string &delimiter)
Definition:
TextReader.cc:24
odc::TextReaderIterator
Definition:
TextReaderIterator.h:33
eckit
Definition:
DistributionUtils.h:15
odc
Definition:
ColumnInfo.h:23
odc
src
odc
csv
TextReader.h
Generated on Fri Aug 20 2021 11:49:12 for IODA Bundle by
1.9.1