blob: 270fe7baa1e9087e662d9c90e67ca4fe49e9ea62 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/********************* */
/*! \file java_iterator_adapter.h
** \verbatim
** Top contributors (to current version):
** Morgan Deters
** This file is part of the CVC4 project.
** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS
** in the top-level source directory) and their institutional affiliations.
** All rights reserved. See the file COPYING in the top-level source
** directory for licensing information.\endverbatim
**
** \brief An iterator adapter for the Java bindings, giving Java iterators
** the ability to access elements from STL iterators.
**
** An iterator adapter for the Java bindings, giving Java iterators the
** ability to access elements from STL iterators. This class is mapped
** into Java by SWIG, where it implements Iterator (some additional
** Java-side functions are added by the SWIG layer to implement the full
** interface).
**
** The functionality requires significant assistance from the ".i" SWIG
** interface files, applying a variety of typemaps.
**/
// private to the bindings layer
#ifndef SWIGJAVA
# error This should only be included from the Java bindings layer.
#endif /* SWIGJAVA */
#ifndef CVC4__BINDINGS__JAVA_ITERATOR_ADAPTER_H
#define CVC4__BINDINGS__JAVA_ITERATOR_ADAPTER_H
#include <type_traits>
namespace CVC4 {
template <class T, class value_type>
class JavaIteratorAdapter
{
public:
JavaIteratorAdapter(const T& t) : d_t(t), d_it(d_t.begin())
{
static_assert(
std::is_convertible<typename T::const_iterator::value_type,
value_type>(),
"value_type must be convertible from T::const_iterator::value_type");
}
bool hasNext() { return d_it != d_t.end(); }
value_type getNext()
{
value_type ret = *d_it;
++d_it;
return ret;
}
private:
const T& d_t;
typename T::const_iterator d_it;
}; /* class JavaIteratorAdapter<T, value_type> */
} // namespace CVC4
#endif /* CVC4__BINDINGS__JAVA_ITERATOR_ADAPTER_H */
|