resonance 1.0.1
Loading...
Searching...
No Matches
seqref.h
Go to the documentation of this file.
1#pragma once
2
3#include "script/cxx/object.h"
4
5namespace Py {
6
7template <typename T>
8class SeqBase;
9
18template <typename T>
19class seqref {
20public:
27 seqref(SeqBase<T> &sequence, int nOffset)
28 : mSequence(sequence), mOffset(nOffset), mItem(sequence.getItem(nOffset)) {
29 }
30
40 seqref &operator=(const Object &value) {
41 mItem = value;
42 mSequence.setItem(mOffset, value);
43 return *this;
44 }
45
51 operator T() const {
52 return mItem;
53 }
54
60 bool isTuple() const {
61 return mItem.isTuple();
62 }
63
64private:
65 SeqBase<T> &mSequence;
66 int mOffset;
67 T mItem;
68};
69
70} // namespace Py
Reference-counted handle on any Python object, and the root of the PyCXX object hierarchy.
Definition object.h:42
Handle on any Python sequence, and the base of Py::List, Py::Tuple, and Py::String.
Definition seqbase.h:38
seqref & operator=(const Object &value)
Store an element through the proxy.
Definition seqref.h:40
seqref(SeqBase< T > &sequence, int nOffset)
Address one element and fetch it.
Definition seqref.h:27
bool isTuple() const
Report whether the fetched element is a tuple.
Definition seqref.h:60
C++ wrappers for the embedded Python interpreter's objects, types, and extension modules.
Definition attributeerror.h:7