OpenPine C++ API
C++ wrapper for the OpenPine Pine Script VM
Loading...
Searching...
No Matches
hline.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 graph {
24
28class Hline {
29 private:
30 const ffi::Hline* p_;
31
32 public:
33 Hline(const ffi::Hline* p) : p_(p) {}
34
38 double value() const { return ffi::hlineValue(p_); }
39
43 std::optional<uint32_t> color() const {
44 uint32_t v;
45 if (ffi::hlineColor(p_, &v)) {
46 return v;
47 } else {
48 return std::nullopt;
49 }
50 }
51
55 std::optional<std::string_view> title() const {
56 ffi::PineStringRef ref;
57 if (ffi::hlineTitle(p_, &ref)) {
58 return detail::refToView(ref);
59 } else {
60 return std::nullopt;
61 }
62 }
63
67 HlineStyle lineStyle() const { return ffi::hlineLineStyle(p_); }
68
72 int32_t lineWidth() const { return ffi::hlineLineWidth(p_); }
73
77 bool editable() const { return ffi::hlineEditable(p_); }
78
82 Display display() const { return Display(ffi::hlineDisplay(p_)); }
83};
84
85} // namespace graph
86} // namespace openpine
A type-safe display bitmask.
Definition display.hpp:25
double value() const
Gets the Y-axis value of the horizontal line.
Definition hline.hpp:38
Hline(const ffi::Hline *p)
Definition hline.hpp:33
bool editable() const
Gets whether the line is user-editable.
Definition hline.hpp:77
std::optional< std::string_view > title() const
Gets the optional title/label.
Definition hline.hpp:55
std::optional< uint32_t > color() const
Gets the optional line color.
Definition hline.hpp:43
Display display() const
Gets the display mask for the hline.
Definition hline.hpp:82
int32_t lineWidth() const
Gets the stroke width.
Definition hline.hpp:72
HlineStyle lineStyle() const
Gets the stroke style.
Definition hline.hpp:67
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.