forked from duckdb/duckdb-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpytype.hpp
More file actions
56 lines (44 loc) · 1.81 KB
/
Copy pathpytype.hpp
File metadata and controls
56 lines (44 loc) · 1.81 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
#pragma once
#include "duckdb_python/nb/casters.hpp"
#include "duckdb/common/types.hpp"
namespace duckdb {
class PyGenericAlias : public nb::object {
public:
using nb::object::object;
public:
static bool check_(const nb::handle &object);
};
class PyUnionType : public nb::object {
public:
using nb::object::object;
public:
static bool check_(const nb::handle &object);
};
//! Value-semantic wrapper around a LogicalType. There is no shared ownership to model -- every factory returns a
//! brand-new, fully-owned type. Bound to Python by value (returned as std::unique_ptr); implicit
//! str/type-object/dict -> DuckDBPyType conversions are handled by nanobind's value caster + the registered
//! implicitly_convertible<>() rules (no custom shared_ptr caster).
class DuckDBPyType {
public:
explicit DuckDBPyType(LogicalType type);
public:
static void Initialize(nb::handle &m);
//! Convert a Python object (an existing DuckDBPyType, a type string, a Python type object such as `int`, or a
//! dict describing a struct) into an owned DuckDBPyType. An existing DuckDBPyType is copied (value semantics);
//! anything else is routed through the registered Python constructor, which drives the same factories as the
//! registered implicit conversions. Returns false (clearing any pending Python error) when the object can't be
//! converted, so a caller can raise a context-specific message.
static bool TryConvert(const nb::object &object, std::unique_ptr<DuckDBPyType> &result);
public:
bool Equals(const DuckDBPyType &other) const;
bool EqualsString(const string &type_str) const;
std::unique_ptr<DuckDBPyType> GetAttribute(const string &name) const;
nb::list Children() const;
string ToString() const;
const LogicalType &Type() const;
string GetId() const;
private:
private:
LogicalType type;
};
} // namespace duckdb