Class jac::OwnedString
ClassList > jac > OwnedString
An owning RAII handle for a QuickJS-allocated C string. More...
#include <ownedString.h>
Public Functions
| Type | Name |
|---|---|
| OwnedString () = default |
|
| OwnedString (ContextRef ctx, const char * str) Wrap a QuickJS allocated, null-terminated string. |
|
| OwnedString (ContextRef ctx, const char * str, std::size_t len) Wrap a QuickJS allocated string of a known length. The string may contain embedded null bytes. |
|
| const char * | c_str () noexcept const Get the underlying null-terminated C string. |
| const char * | data () noexcept const |
| bool | empty () noexcept const |
| string () const |
|
| string_view () noexcept const |
|
| std::size_t | size () noexcept const |
| std::string_view | view () noexcept const Get a non-owning view of the string. |
Detailed Description
The string must be allocated using QuickJS functions (JS_ToCString, JS_AtomToCString, etc.); it is released with JS_FreeCString when the handle is destroyed. The handle is move-only. Use view to obtain a (non-owning) std::string_view for inspection.
Public Functions Documentation
function OwnedString [1/3]
function OwnedString [2/3]
Wrap a QuickJS allocated, null-terminated string.
Parameters:
ctxcontext to work instrstring to take ownership of
function OwnedString [3/3]
Wrap a QuickJS allocated string of a known length. The string may contain embedded null bytes.
Parameters:
ctxcontext to work instrstring to take ownership oflenlength of the string in bytes
function c_str
Get the underlying null-terminated C string.
Returns:
const char*
function data
function empty
function string
function string_view
function size
function view
Get a non-owning view of the string.
Returns:
std::string_view valid for the lifetime of this handle
Friends Documentation
friend operator<<
The documentation for this class was generated from the following file src/jac/machine/ownedString.h