IODA Bundle
TextReaderIterator.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 /// \file TextReaderIterator.h
13 ///
14 /// @author Piotr Kuchta, Oct 2010
15 
16 #ifndef TextReaderIterator_H
17 #define TextReaderIterator_H
18 
19 #include "odc/IteratorProxy.h"
20 #include "odc/core/MetaData.h"
21 
22 namespace eckit { class PathName; }
23 namespace eckit { class DataHandle; }
24 namespace odc { namespace sql { class ODATableIterator; } }
25 
26 namespace odc {
27 
28 //----------------------------------------------------------------------------------------------------------------------
29 
30 class TextReader;
31 
32 class TextReaderIterator : private eckit::NonCopyable
33 {
34 public:
36  TextReaderIterator (TextReader& owner, const eckit::PathName&);
38 
39  bool isNewDataset();
40  const double* data () const { return lastValues_; }
41  double* data () { return lastValues_; }
42  double& data(size_t);
43  //long integer(int i);
44 
45  bool operator!=(const TextReaderIterator& other);
46 
48 
49  static eckit::sql::BitfieldDef parseBitfields(const std::string&);
50 //protected:
51 
52  int close();
53 
54 // next() is public cause it needs to be used by the C API functions - normally client code should not use it
55  bool next();
56 
57  /// The offset of a given column in the doubles[] data array
58  size_t dataOffset(size_t i) const { ASSERT(columnOffsets_); return columnOffsets_[i]; }
59 
60  // Get the number of doubles per row.
61  size_t rowDataSizeDoubles() const { return rowDataSizeDoubles_; }
62 
63 private:
64 // No copy allowed.
67 
68  void initRowBuffer();
69  void parseHeader();
70 
72  double* lastValues_;
73  size_t* columnOffsets_;
75  unsigned long long nrows_;
76  std::string delimiter_;
77 
78  std::istream* in_;
79  //eckit::DataHandle *f;
80  //Properties properties_;
81 
83 public:
84  bool noMore_;
85 
86  bool ownsF_;
87  int refCount_;
88 
89 protected:
90  // FIXME:
92 
93  friend class odc::TextReader;
94  friend class odc::IteratorProxy<odc::TextReaderIterator, odc::TextReader, const double>;
95 };
96 
97 //----------------------------------------------------------------------------------------------------------------------
98 
99 } // namespace odc
100 
101 #endif
TextReaderIterator & operator=(const TextReaderIterator &)
core::MetaData & columns()
static eckit::sql::BitfieldDef parseBitfields(const std::string &)
bool operator!=(const TextReaderIterator &other)
size_t dataOffset(size_t i) const
The offset of a given column in the doubles[] data array.
unsigned long long nrows_
size_t rowDataSizeDoubles() const
TextReaderIterator(TextReader &owner, const eckit::PathName &)
TextReaderIterator(const TextReaderIterator &)
const double * data() const
Definition: ColumnInfo.h:23