Variant like python object. More...
#include <cvb/py_script/object.hpp>
Public Member Functions | |
ObjectPtr | Attribute (const Cvb::String &attributeName) |
Gets an attribute of the object as object. | |
ObjectPtr | Run (const Object &args) |
Runs the object as callable. | |
ObjectPtr | Run () |
Runs the object as callable. | |
size_t | ElementCount () const |
Number of elements in this object. | |
void | Set (size_t index, const Object &obj) |
Set an element in this object. | |
ObjectPtr | Get (size_t index) const |
Get an element from this object. | |
template<class T> | |
T | As () const |
Get an type from this object. | |
void * | Handle () const noexcept |
Classic API buffer handle. | |
Static Public Member Functions | |
template<class T> | |
static std::shared_ptr< Object > | Create (const T &value) |
Creates a object form any supported type. | |
static ObjectPtr | MakeVoidTuple (size_t size) |
Creates tuple with a specified size. | |
template<typename... T> | |
static ObjectPtr | MakeTuple (T &&...args) |
Creates tuple with the given types. | |
static std::shared_ptr< Object > | MakeVoidList (size_t size) |
Creates list with a specified size. | |
Variant like python object.
Like variants this type can hold any python object. Note that in python also function, methods, types and even "None" is an object. There are convenience to create Objects from CVB types and extract CVB types from Object. All primitive types can also be converted to and from an Object.
Furthermore list and tuples can be created to hold other objects. Be aware that all arguments to e.g. functions or methods must delivered in a tuple.
|
inline |
Get an type from this object.
Any | exception derived from std::exception including CvbException. |
See module description on details how types are received.
|
inline |
Gets an attribute of the object as object.
[in] | attributeName | Name of the attribute. |
Any | exception derived from std::exception including CvbException. |
Attributes are meant in the python sense, e.g. type objects, methods, callables, globals etc.
|
inlinestatic |
Creates a object form any supported type.
[in] | value | The type to put into the object. |
Any | exception derived from std::exception including CvbException. |
See module description on details how types are created.
|
inline |
Number of elements in this object.
Any | exception derived from std::exception including CvbException. |
Only valid for list or tuple, fails otherwise.
|
inline |
Get an element from this object.
[in] | index | Position to access. |
Any | exception derived from std::exception including CvbException. |
Only valid for list or tuple, fails otherwise.
|
inlinenoexcept |
Classic API buffer handle.
It is normally not necessary to work with this handle.
|
inlinestatic |
Creates tuple with the given types.
[in] | args | Variadic list of types. |
Any | exception derived from std::exception including CvbException. |
The tuple will be with the types provided. All types must be supported. See Set, Get and ElementCount for handling the items in the tuple.
|
inlinestatic |
Creates list with a specified size.
[in] | size | The size of the list. |
Any | exception derived from std::exception including CvbException. |
The list will be filled with "None". See Set, Get and ElementCount for handling the items in the list.
|
inlinestatic |
Creates tuple with a specified size.
[in] | size | The size of the tuple. |
Any | exception derived from std::exception including CvbException. |
The tuple will be filled with "None". See Set, Get and ElementCount for handling the items in the tuple.
|
inline |
Runs the object as callable.
Any | exception derived from std::exception including CvbException. |
Runs the object as callable.
[in] | args | Arguments for the call, must be a tuple. |
Any | exception derived from std::exception including CvbException. |
|
inline |
Set an element in this object.
[in] | index | Position to access. |
[in] | obj | Object to set at the given index. |
Any | exception derived from std::exception including CvbException. |
Only valid for list or tuple, fails otherwise.