12#if (defined(_MSVC_LANG) ? _MSVC_LANG : __cplusplus) < 201703L
14 "OpenPine C++ wrapper headers require C++17 (std::optional, std::string_view)."
35 const ffi::ScriptInfo* p_;
44 bool overlay()
const {
return ffi::scriptInfoOverlay(p_); }
50 ScriptTypeKind
scriptType()
const {
return ffi::scriptInfoScriptType(p_); }
56 std::optional<std::string_view>
title()
const {
57 ffi::PineStringRef ref{};
58 if (ffi::scriptInfoTitle(p_, &ref)) {
71 if (ffi::scriptInfoIndicator(p_, &out))
return out;
80 if (ffi::scriptInfoLibrary(p_, &out))
return out;
91 if (ffi::scriptInfoStrategy(p_, &out))
return out;
98 uintptr_t
inputsLength()
const {
return ffi::scriptInfoInputsLength(p_); }
103 std::optional<ScriptInput>
inputAt(uintptr_t index)
const {
104 const ffi::Input* inp = ffi::scriptInfoInput(p_, index);
113 return ffi::scriptInfoAlertConditionsLength(p_);
120 ffi::PineStringRef ref{};
121 if (!ffi::scriptInfoAlertConditionTitle(p_, index, &ref))
130 ffi::PineStringRef ref{};
131 if (!ffi::scriptInfoAlertConditionMessage(p_, index, &ref))
uintptr_t alertConditionsLength() const
Number of declared alert conditions.
ScriptInfo(const ffi::ScriptInfo *p)
uintptr_t inputsLength() const
Number of declared user inputs.
bool overlay() const
Whether the script is drawn on the price chart.
std::optional< std::string_view > alertConditionMessage(uintptr_t index) const
Alert condition message at the given index.
std::optional< std::string_view > alertConditionTitle(uintptr_t index) const
Alert condition title at the given index.
std::optional< Indicator > indicator() const
Full indicator payload. Only defined when scriptType() == Indicator. String refs inside the struct ar...
ScriptTypeKind scriptType() const
Script type discriminant.
std::optional< std::string_view > title() const
Script title if present.
std::optional< Strategy > strategy() const
Full strategy payload. Only defined when scriptType() == Strategy. String refs inside the struct are ...
std::optional< ScriptInput > inputAt(uintptr_t index) const
Input at the given index, or nullopt if index is out of range.
std::optional< Library > library() const
Full library payload. Only defined when scriptType() == Library.
std::optional< std::string_view > optRefToView(bool has_field, const ffi::PineStringRef &ref)
Returns optional string_view when has_field is true, otherwise std::nullopt.
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.