Prism Ruby parser
Loading...
Searching...
No Matches
stringy.hpp
Go to the documentation of this file.
1
6#ifndef PRISM_STRINGY_HPP
7#define PRISM_STRINGY_HPP
8
9#include "prism/compiler/cplusplus.hpp"
10#include "prism/compiler/lifetimebound.hpp"
11
12#include "prism/stringy.h"
13
14#include <string_view>
15
16namespace prism {
17
24[[nodiscard]] inline std::string_view
25view(const pm_string_t &string PRISM_LIFETIMEBOUND) noexcept {
26 return std::string_view(reinterpret_cast<const char *>(pm_string_source(&string)), pm_string_length(&string));
27}
28
29}
30
31#endif
std::string_view view(const pm_buffer_t *buffer) noexcept
The bytes written to the given buffer so far.
Definition buffer.hpp:49
A view of a sequence of bytes owned by someone else.
PRISM_EXPORTED_FUNCTION size_t pm_string_length(const pm_string_t *string) PRISM_NONNULL(1)
Returns the length associated with the string.
PRISM_EXPORTED_FUNCTION const uint8_t * pm_string_source(const pm_string_t *string) PRISM_NONNULL(1)
Returns the start pointer associated with the string.
A view of a sequence of bytes.
Definition stringy.h:23