OpenPine C++ API
C++ wrapper for the OpenPine Pine Script VM
Loading...
Searching...
No Matches
bar_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 {
22
29class BarColors {
30 private:
31 const ffi::BarColors* p_;
32
33 public:
34 BarColors(const ffi::BarColors* p) : p_(p) {}
35
39 int32_t offset() const { return ffi::barcolorsOffset(p_); }
40
44 bool editable() const { return ffi::barcolorsEditable(p_); }
45
49 std::optional<uintptr_t> showLast() const {
50 uintptr_t v;
51 if (ffi::barcolorsShowLast(p_, &v)) {
52 return v;
53 } else {
54 return std::nullopt;
55 }
56 }
57
62 std::optional<std::string_view> title() const {
63 ffi::PineStringRef ref;
64 if (ffi::barcolorsTitle(p_, &ref)) {
65 return detail::refToView(ref);
66 } else {
67 return std::nullopt;
68 }
69 }
70
74 Display display() const { return Display(ffi::barcolorsDisplay(p_)); }
75
82 std::optional<uint32_t> color(uintptr_t idx) const {
83 uint32_t col;
84 if (ffi::barcolorsColor(p_, idx, &col)) {
85 return col;
86 } else {
87 return std::nullopt;
88 }
89 }
90};
91
92} // namespace openpine
std::optional< uintptr_t > showLast() const
Gets the show_last value, if set.
bool editable() const
Returns whether bar-colors are editable.
std::optional< std::string_view > title() const
Gets the title of the bar-colors series.
int32_t offset() const
Returns the bar-colors offset.
Display display() const
Gets the display bitmask.
std::optional< uint32_t > color(uintptr_t idx) const
Gets the bar color at the specified index.
BarColors(const ffi::BarColors *p)
A type-safe display bitmask.
Definition display.hpp:25
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.