OpenPine C++ API
C++ wrapper for the OpenPine Pine Script VM
Loading...
Searching...
No Matches
polyline.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
16#include "../ffi.hpp"
17#include "../types.hpp"
18
19namespace openpine {
20namespace graph {
21
25class Polyline {
26 private:
27 const ffi::Polyline* p_;
28
29 public:
30 Polyline(const ffi::Polyline* p) : p_(p) {}
31
35 uintptr_t pointsLength() const { return ffi::polylinePointsLength(p_); }
36
40 std::optional<ffi::PolylinePoint> point(uintptr_t idx) const {
41 ffi::PolylinePoint pt;
42 if (ffi::polylinePoint(p_, idx, &pt)) {
43 return pt;
44 } else {
45 return std::nullopt;
46 }
47 }
48
52 bool curved() const { return ffi::polylineCurved(p_); }
53
57 bool closed() const { return ffi::polylineClosed(p_); }
58
62 std::optional<uint32_t> lineColor() const {
63 uint32_t v;
64 if (ffi::polylineLineColor(p_, &v)) {
65 return v;
66 } else {
67 return std::nullopt;
68 }
69 }
70
74 std::optional<uint32_t> fillColor() const {
75 uint32_t v;
76 if (ffi::polylineFillColor(p_, &v)) {
77 return v;
78 } else {
79 return std::nullopt;
80 }
81 }
82
86 LineStyle lineStyle() const { return ffi::polylineLineStyle(p_); }
87
91 int32_t lineWidth() const { return ffi::polylineLineWidth(p_); }
92
96 bool forceOverlay() const { return ffi::polylineForceOverlay(p_); }
97};
98
99} // namespace graph
100} // namespace openpine
LineStyle lineStyle() const
Gets the line style.
Definition polyline.hpp:86
int32_t lineWidth() const
Gets the line width.
Definition polyline.hpp:91
std::optional< uint32_t > lineColor() const
Gets the optional line color.
Definition polyline.hpp:62
bool forceOverlay() const
Gets whether the polyline is forced to render as overlay.
Definition polyline.hpp:96
std::optional< uint32_t > fillColor() const
Gets the optional fill color.
Definition polyline.hpp:74
Polyline(const ffi::Polyline *p)
Definition polyline.hpp:30
std::optional< ffi::PolylinePoint > point(uintptr_t idx) const
Returns the point at idx.
Definition polyline.hpp:40
bool closed() const
Gets whether the polyline is closed.
Definition polyline.hpp:57
bool curved() const
Gets whether the polyline is rendered as a smooth curve.
Definition polyline.hpp:52
uintptr_t pointsLength() const
Returns the number of points in the polyline.
Definition polyline.hpp:35
Re-exports FFI types into the openpine namespace.