-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython.h
More file actions
88 lines (64 loc) · 2.04 KB
/
python.h
File metadata and controls
88 lines (64 loc) · 2.04 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#pragma once
#include <generator>
#include <memory>
#include <string>
#include <vector>
namespace python
{
class object
{
public:
virtual ~object() = default;
};
class context final
{
public:
context() noexcept;
context(const context &) = delete;
context(context &&) = delete;
context &operator=(const context &) = delete;
context &operator=(context &&) = delete;
[[nodiscard]] std::unique_ptr<object> unpickle(const std::string &pickled_string) const;
[[nodiscard]] int64_t as_int64(const object &value) const;
[[nodiscard]] std::string as_bytes(const object &value) const;
~context();
};
class container
{
public:
explicit container(const context &context, std::unique_ptr<object> object) : object_(std::move(object))
{
}
[[nodiscard]] virtual int64_t size() const = 0;
virtual ~container() = default;
protected:
std::unique_ptr<object> object_;
};
class tuple final : public container
{
public:
explicit tuple(const context &context, std::unique_ptr<object> object) : container(context, std::move(object))
{
}
[[nodiscard]] int64_t size() const override;
[[nodiscard]] std::unique_ptr<object> get_item(int64_t index) const;
};
class list final : public container
{
public:
explicit list(const context &context, std::unique_ptr<object> object) : container(context, std::move(object))
{
}
[[nodiscard]] int64_t size() const override;
[[nodiscard]] std::unique_ptr<object> get_item(int64_t index) const;
};
class dict final : public container
{
public:
explicit dict(const context &context, std::unique_ptr<object> object) : container(context, std::move(object))
{
}
[[nodiscard]] int64_t size() const override;
[[nodiscard]] std::generator<std::pair<std::string_view, std::unique_ptr<object> > > iterate() const;
};
}