OpenPine C++ API
C++ wrapper for the OpenPine Pine Script VM
Loading...
Searching...
No Matches
fill.hpp
Go to the documentation of this file.
1#pragma once
2
7
8#if (defined(_MSVC_LANG) ? _MSVC_LANG : __cplusplus) < 201703L
9#error \
10 "OpenPine C++ wrapper headers require C++17 (std::optional, std::string_view)."
11#endif
12
13#include <cstdint>
14#include <optional>
15#include <string_view>
16
17#include "../display.hpp"
18#include "../ffi.hpp"
19#include "../string_ref.hpp"
20#include "../types.hpp"
21
22namespace openpine {
23namespace seriesgraph {
24
28class Fill {
29 private:
30 const ffi::Fill* p_;
31
32 public:
33 Fill(const ffi::Fill* p) : p_(p) {}
34
38 FillAnchorType fromType() const { return ffi::fillFromType(p_); }
39
43 std::optional<int64_t> fromPlotId() const {
44 int64_t v;
45 if (ffi::fillFromPlotId(p_, &v)) {
46 return v;
47 } else {
48 return std::nullopt;
49 }
50 }
51
55 std::optional<int64_t> fromHlineId() const {
56 int64_t v;
57 if (ffi::fillFromHlineId(p_, &v)) {
58 return v;
59 } else {
60 return std::nullopt;
61 }
62 }
63
67 FillAnchorType toType() const { return ffi::fillToType(p_); }
68
72 std::optional<int64_t> toPlotId() const {
73 int64_t v;
74 if (ffi::fillToPlotId(p_, &v)) {
75 return v;
76 } else {
77 return std::nullopt;
78 }
79 }
80
84 std::optional<int64_t> toHlineId() const {
85 int64_t v;
86 if (ffi::fillToHlineId(p_, &v)) {
87 return v;
88 } else {
89 return std::nullopt;
90 }
91 }
92
96 std::optional<std::string_view> title() const {
97 ffi::PineStringRef ref;
98 if (ffi::fillTitle(p_, &ref)) {
99 return detail::refToView(ref);
100 } else {
101 return std::nullopt;
102 }
103 }
104
108 bool editable() const { return ffi::fillEditable(p_); }
109
113 std::optional<uintptr_t> showLast() const {
114 uintptr_t v;
115 if (ffi::fillShowLast(p_, &v)) {
116 return v;
117 } else {
118 return std::nullopt;
119 }
120 }
121
125 bool fillGaps() const { return ffi::fillFillGaps(p_); }
126
130 Display display() const { return Display(ffi::fillDisplay(p_)); }
131
135 std::optional<FillColorType> colorType(uintptr_t idx) const {
136 FillColorType t;
137 if (ffi::fillColorType(p_, idx, &t)) {
138 return t;
139 } else {
140 return std::nullopt;
141 }
142 }
143
147 std::optional<uint32_t> solidColor(uintptr_t idx) const {
148 uint32_t col;
149 if (ffi::fillColorSolid(p_, idx, &col)) {
150 return col;
151 } else {
152 return std::nullopt;
153 }
154 }
155
159 std::optional<FillGradient> gradient(uintptr_t idx) const {
160 FillGradient g;
161 if (ffi::fillColorGradient(p_, idx, &g)) {
162 return g;
163 } else {
164 return std::nullopt;
165 }
166 }
167};
168
169} // namespace seriesgraph
170} // namespace openpine
A type-safe display bitmask.
Definition display.hpp:25
FillAnchorType fromType() const
Gets the kind of the "from" anchor.
Definition fill.hpp:38
std::optional< uintptr_t > showLast() const
Gets the show_last value, if set.
Definition fill.hpp:113
std::optional< int64_t > fromHlineId() const
Gets the hline id of the "from" anchor, if it is a hline.
Definition fill.hpp:55
std::optional< uint32_t > solidColor(uintptr_t idx) const
Gets the solid fill color at the specified index.
Definition fill.hpp:147
std::optional< int64_t > toPlotId() const
Gets the plot id of the "to" anchor, if it is a plot.
Definition fill.hpp:72
std::optional< std::string_view > title() const
Gets the fill title, if set.
Definition fill.hpp:96
FillAnchorType toType() const
Gets the kind of the "to" anchor.
Definition fill.hpp:67
std::optional< FillGradient > gradient(uintptr_t idx) const
Gets the gradient fill definition at the specified index.
Definition fill.hpp:159
bool fillGaps() const
Returns whether the fill is drawn across gaps.
Definition fill.hpp:125
std::optional< int64_t > toHlineId() const
Gets the hline id of the "to" anchor, if it is a hline.
Definition fill.hpp:84
std::optional< FillColorType > colorType(uintptr_t idx) const
Gets the fill color kind at the specified index.
Definition fill.hpp:135
bool editable() const
Returns whether the fill is user-editable.
Definition fill.hpp:108
std::optional< int64_t > fromPlotId() const
Gets the plot id of the "from" anchor, if it is a plot.
Definition fill.hpp:43
Display display() const
Gets the display bitmask.
Definition fill.hpp:130
Fill(const ffi::Fill *p)
Definition fill.hpp:33
Type-safe wrappers for display bitmasks used by visuals.
std::string_view refToView(const ffi::PineStringRef &ref)
Shared helpers for converting C ABI string refs to std::string_view.
Re-exports FFI types into the openpine namespace.