libqi-api  2.8.7.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
anyiterator.hxx
Go to the documentation of this file.
1 #pragma once
2 /*
3 ** Copyright (C) 2013 Aldebaran Robotics
4 ** See COPYING for the license
5 */
6 
7 #ifndef _QITYPE_DETAIL_ANYITERATOR_HXX_
8 #define _QITYPE_DETAIL_ANYITERATOR_HXX_
9 
11 
12 namespace qi {
13 
15 {
16  if (kind() == TypeKind_Iterator)
17  return static_cast<IteratorTypeInterface*>(_type)->dereference(_value);
18  else
19  throw std::runtime_error("Expected iterator");
20 }
21 
22 template<typename T>
24  : AnyValue(AnyReference::from(ref))
25 {}
26 
28 {}
29 
31  : AnyValue(p)
32 {}
33 
35  : AnyValue(v)
36 {}
37 
39 {
40  if (kind() != TypeKind_Iterator)
41  throw std::runtime_error("Expected an iterator");
42  static_cast<IteratorTypeInterface*>(_type)->next(&_value);
43  return *this;
44 }
45 
47 {
48  if (kind() != TypeKind_Iterator)
49  throw std::runtime_error("Expected an iterator");
50  AnyIterator it2 = *this;
51  static_cast<IteratorTypeInterface*>(_type)->next(&_value);
52  return it2;
53 }
54 
55 inline bool operator==(const AnyIterator& a, const AnyIterator& b)
56 {
57  return a.asReference() == b.asReference();
58 }
59 
60 inline bool operator!=(const AnyIterator& a, const AnyIterator& b)
61 {
62  return !(a==b);
63 }
64 
65 }
66 
67 
68 #endif // _QITYPE_DETAIL_ANYITERATOR_HXX_
AnyIterator & operator++()
Iterator pre-increment.
Definition: anyiterator.hxx:38
AnyReference operator*()
Dereference.
Definition: anyiterator.hxx:14
bool operator==(const Signature &lhs, const Signature &rhs)
AnyReference asReference() const
Definition: anyvalue.hpp:87
bool operator!=(const Signature &lhs, const Signature &rhs)
Definition: signature.hpp:157