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:
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 
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_;
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.
72 
75 };
76 
77 //----------------------------------------------------------------------------------------------------------------------
78 
79 } // namespace odc
80 
81 #endif
const std::string & delimiter()
Definition: TextReader.h:61
std::string delimiter_
Definition: TextReader.h:66
iterator::Row row
Definition: TextReader.h:39
TextReader & operator=(TextReader &&)
Definition: TextReader.cc:47
iterator iteratorSingleton_
Definition: TextReader.h:71
bool deleteDataHandle_
Definition: TextReader.h:65
std::istream & stream()
Definition: TextReader.h:52
iterator end() const
Definition: TextReader.cc:77
virtual ~TextReader()
Definition: TextReader.cc:55
std::istream * in_
Definition: TextReader.h:64
iterator begin()
Definition: TextReader.cc:71
IteratorProxy< TextReaderIterator, TextReader, double > iterator
Definition: TextReader.h:38
TextReader(std::istream &, const std::string &delimiter)
Definition: TextReader.cc:24
Definition: ColumnInfo.h:23