OpenPine C++ API
C++ wrapper for the OpenPine Pine Script VM
Loading...
Searching...
No Matches
background_colors.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
21namespace openpine {
22namespace seriesgraph {
23
28 private:
29 const ffi::BackgroundColors* p_;
30
31 public:
32 BackgroundColors(const ffi::BackgroundColors* p) : p_(p) {}
33
37 int32_t offset() const { return ffi::bgcolorsOffset(p_); }
38
42 bool editable() const { return ffi::bgcolorsEditable(p_); }
43
47 std::optional<uintptr_t> showLast() const {
48 uintptr_t v;
49 if (ffi::bgcolorsShowLast(p_, &v)) {
50 return v;
51 } else {
52 return std::nullopt;
53 }
54 }
55
60 std::optional<std::string_view> title() const {
61 ffi::PineStringRef ref;
62 if (ffi::bgcolorsTitle(p_, &ref)) {
63 return detail::refToView(ref);
64 } else {
65 return std::nullopt;
66 }
67 }
68
72 Display display() const { return Display(ffi::bgcolorsDisplay(p_)); }
73
77 bool forceOverlay() const { return ffi::bgcolorsForceOverlay(p_); }
78
85 std::optional<uint32_t> color(uintptr_t idx) const {
86 uint32_t col;
87 if (ffi::bgcolorsColor(p_, idx, &col)) {
88 return col;
89 } else {
90 return std::nullopt;
91 }
92 }
93};
94
95} // namespace seriesgraph
96} // namespace openpine
A type-safe display bitmask.
Definition display.hpp:25
int32_t offset() const
Returns the background-colors offset.
bool forceOverlay() const
Gets whether the background colors are forced to render as overlay.
BackgroundColors(const ffi::BackgroundColors *p)
std::optional< std::string_view > title() const
Gets the title of the background-colors series.
std::optional< uintptr_t > showLast() const
Gets the show_last value, if set.
bool editable() const
Returns whether background-colors are editable.
std::optional< uint32_t > color(uintptr_t idx) const
Gets the background color at the specified index.
Display display() const
Gets the display bitmask.
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.