42
42
#ifndef LIBLAS_ITERATOR_HPP_INCLUDED
43
43
#define LIBLAS_ITERATOR_HPP_INCLUDED
45
#include <liblas/lasreader.hpp>
46
#include <liblas/laswriter.hpp>
45
#include <liblas/reader.hpp>
46
#include <liblas/writer.hpp>
47
#include <liblas/index.hpp>
48
#include <liblas/export.hpp>
47
49
#include <iterator>
164
171
/// Initialize iterator with given writer.
165
172
/// The writer position is not changed.
166
173
/// No ownership transfer of writer object occurs.
167
writer_iterator(liblas::LASWriter& writer)
174
writer_iterator(liblas::Writer& writer)
168
175
: m_writer(&writer)
170
177
assert(0 != m_writer);
208
liblas::LASWriter* m_writer;
216
liblas::Writer* m_writer;
219
template <typename T>
220
class index_filter_iterator
224
typedef std::input_iterator_tag iterator_category;
225
typedef T value_type;
226
typedef T const* pointer;
227
typedef T const& reference;
228
typedef ptrdiff_t difference_type;
230
/// Initializes iterator pointing to pass-the-end.
231
index_filter_iterator()
235
/// Initializes iterator pointing to beginning of Index's filtered points sequence.
236
/// No ownership transfer of index object occurs.
237
index_filter_iterator(liblas::Index& index)
240
assert(0 != m_index);
244
/// Dereference operator.
245
/// It is implemented in terms of Index::GetNextID function.
246
reference operator*() const
248
assert(0 != m_index);
251
// return m_index->GetNextID();
254
throw std::runtime_error("index is null and iterator not dereferencable");
257
/// Pointer-to-member operator.
258
/// It is implemented in terms of Index::GetPoint function.
259
pointer operator->() const
261
return &(operator*());
264
/// Pre-increment operator.
265
/// Moves iterator to next record by calling Index::GetNextID.
266
index_filter_iterator& operator++()
268
assert(0 != m_index);
273
/// Post-increment operator.
274
/// Moves iterator to next record by calling Index::FindNextID.
275
index_filter_iterator operator++(int)
277
index_filter_iterator tmp(*this);
282
/// Compare passed iterator to this.
283
/// Determine if both iterators apply to the same instance of liblas::Index class.
284
bool equal(index_filter_iterator const& rhs) const
286
return m_index == rhs.m_index;
293
// if (0 != m_index && !(m_index->FindNextID()))
299
liblas::Index* m_index;
211
302
// Declare specializations for user's convenience
213
304
/// Public specialization of LASReader input iterator for liblas::LASPoint type.
214
typedef reader_iterator<LASPoint> lasreader_iterator;
305
typedef reader_iterator<Point> lasreader_iterator;
216
307
/// Public specialization of LASWriter output iterator for liblas::LASPoint type.
217
typedef writer_iterator<LASPoint> laswriter_iterator;
308
typedef writer_iterator<Point> laswriter_iterator;
310
// Needed for C++ DLL exports
312
template class LAS_DLL reader_iterator<Point>;
313
template class LAS_DLL writer_iterator<Point>;
219
316
} // namespace liblas