Aldebaran documentation
|
C++ Libraries
|
index
libqi-api
2.8.7.4
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
qi
type
detail
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
10
#include <
qi/type/typeinterface.hpp
>
11
12
namespace
qi {
13
14
inline
AnyReference
AnyIterator::operator*
()
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>
23
AnyIterator::AnyIterator
(
const
T& ref)
24
:
AnyValue
(
AnyReference
::from(ref))
25
{}
26
27
inline
AnyIterator::AnyIterator
()
28
{}
29
30
inline
AnyIterator::AnyIterator
(
const
AnyReference
& p)
31
:
AnyValue
(p)
32
{}
33
34
inline
AnyIterator::AnyIterator
(
const
AnyValue
& v)
35
:
AnyValue
(v)
36
{}
37
38
inline
AnyIterator
&
AnyIterator::operator++
()
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
46
inline
AnyIterator
AnyIterator::operator++
(
int
)
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_
qi::AnyIterator
Definition:
anyiterator.hpp:16
qi::AnyValue
Definition:
anyvalue.hpp:19
qi::IteratorTypeInterface
Definition:
typeinterface.hpp:164
qi::AnyIterator::AnyIterator
AnyIterator()
Definition:
anyiterator.hxx:27
qi::AnyReference
Definition:
anyreference.hpp:360
qi::detail::AnyReferenceBase::_value
void * _value
Definition:
anyreference.hpp:355
qi::AnyIterator::operator++
AnyIterator & operator++()
Iterator pre-increment.
Definition:
anyiterator.hxx:38
qi::AnyIterator::operator*
AnyReference operator*()
Dereference.
Definition:
anyiterator.hxx:14
qi::operator==
bool operator==(const Signature &lhs, const Signature &rhs)
qi::detail::AnyReferenceBase::kind
TypeKind kind() const
Definition:
anyreference.hxx:71
qi::AnyValue::asReference
AnyReference asReference() const
Definition:
anyvalue.hpp:87
qi::detail::AnyReferenceBase::_type
TypeInterface * _type
Definition:
anyreference.hpp:354
typeinterface.hpp
qi::operator!=
bool operator!=(const Signature &lhs, const Signature &rhs)
Definition:
signature.hpp:157
qi::TypeKind_Iterator
Definition:
fwd.hpp:68
Copyright Aldebaran Robotics