OpenPine C++ API
C++ wrapper for the OpenPine Pine Script VM
Loading...
Searching...
No Matches
string_ref.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 <optional>
14
#include <string_view>
15
16
#include "
ffi.hpp
"
17
18
namespace
openpine
{
19
20
namespace
detail
{
21
24
inline
std::string_view
refToView
(
const
ffi::PineStringRef& ref) {
25
if
(!ref.data)
return
std::string_view{};
26
return
std::string_view(
reinterpret_cast<
const
char
*
>
(ref.data), ref.len);
27
}
28
30
inline
std::optional<std::string_view>
optRefToView
(
31
bool
has_field,
const
ffi::PineStringRef& ref) {
32
return
has_field ? std::optional<std::string_view>(
refToView
(ref))
33
: std::nullopt;
34
}
35
36
}
// namespace detail
37
}
// namespace openpine
ffi.hpp
openpine::detail
Definition
string_ref.hpp:20
openpine::detail::optRefToView
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.
Definition
string_ref.hpp:30
openpine::detail::refToView
std::string_view refToView(const ffi::PineStringRef &ref)
Definition
string_ref.hpp:24
openpine
Definition
chart.hpp:28
cpp
include
string_ref.hpp
Generated by
1.16.1