casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ParamFieldIterator.h
Go to the documentation of this file.
1 /* -*- mode: c++ -*- */
2 //# ParamFieldIterator.h: Single field parameter iterator over Records
3 //# Copyright (C) 1997,1998,1999,2000,2001,2002,2003
4 //# Associated Universities, Inc. Washington DC, USA.
5 //#
6 //# This library is free software; you can redistribute it and/or modify it
7 //# under the terms of the GNU Library General Public License as published by
8 //# the Free Software Foundation; either version 2 of the License, or (at your
9 //# option) any later version.
10 //#
11 //# This library is distributed in the hope that it will be useful, but WITHOUT
12 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14 //# License for more details.
15 //#
16 //# You should have received a copy of the GNU Library General Public License
17 //# along with this library; if not, write to the Free Software Foundation,
18 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
19 //#
20 //# Correspondence concerning AIPS++ should be addressed as follows:
21 //# Internet email: aips2-request@nrao.edu.
22 //# Postal address: AIPS++ Project Office
23 //# National Radio Astronomy Observatory
24 //# 520 Edgemont Road
25 //# Charlottesville, VA 22903-2475 USA
26 //#
27 #ifndef PARAM_FIELD_ITERATOR_H_
28 #define PARAM_FIELD_ITERATOR_H_
29 
30 #include <casa/Containers/Record.h>
31 #include <iterator>
32 
33 namespace casa {
34 
36  : public std::iterator<std::forward_iterator_tag, casacore::Record *, int> {
40 
41 public:
43  : record(nullptr)
44  , prefix("")
45  , field_index(0) {};
46 
47  ParamFieldIterator(casacore::Record *rec, const string &prefix = "")
48  : record(rec)
50  , field_index(0) {};
51 
53  : record(fit.record)
54  , prefix(fit.prefix)
55  , field_index(fit.field_index) {};
56 
58  ++field_index;
59  return *this;
60  };
61 
63  ParamFieldIterator tmp(*this);
64  operator++();
65  return tmp;
66  };
67 
68  bool operator==(const ParamFieldIterator &rhs) {
69  return record == rhs.record
70  && field_index == rhs.field_index
71  && prefix == rhs.prefix;
72  };
73 
74  bool operator!=(const ParamFieldIterator &rhs) {
75  return !operator==(rhs);
76  };
77 
80  };
81 
82  static ParamFieldIterator begin(casacore::Record *rec, const string &prefix = "") {
83  return ParamFieldIterator(rec, prefix);
84  };
85 
86  static ParamFieldIterator end(casacore::Record *rec, const string &prefix = "") {
87  ParamFieldIterator result(rec, prefix);
88  result.field_index = rec->nfields();
89  return result;
90  };
91 };
92 
93 }
94 
95 #endif // FIELD_ITERATOR_H_
Record & rwSubRecord(const RecordFieldId &)
ParamFieldIterator(const ParamFieldIterator &fit)
casacore::Record * record
bool operator==(const ParamFieldIterator &rhs)
virtual uInt nfields() const
How many fields does this structure have? A convenient synonym for description().nfields().
static ParamFieldIterator end(casacore::Record *rec, const string &prefix="")
casacore::Record & operator*()
static ParamFieldIterator begin(casacore::Record *rec, const string &prefix="")
ParamFieldIterator operator++(int)
bool operator!=(const ParamFieldIterator &rhs)
A hierarchical collection of named fields of various types.
Definition: Record.h:180
ParamFieldIterator(casacore::Record *rec, const string &prefix="")
ParamFieldIterator & operator++()
String: the storage and methods of handling collections of characters.
Definition: String.h:223
unsigned int uInt
Definition: aipstype.h:51
static String toString(const T &value)
Convert a value to a String.
Definition: String.h:614
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42