v8 12.4.254 (node 22.4.1)
V8 is Google's open source JavaScript engine
Loading...
Searching...
No Matches
ValueSerializer Class Reference

#include <v8-value-serializer.h>

Data Structures

class  Delegate
 

Public Member Functions

 ValueSerializer (Isolate *isolate)
 
 ValueSerializer (Isolate *isolate, Delegate *delegate)
 
 ~ValueSerializer ()
 
void WriteHeader ()
 
V8_WARN_UNUSED_RESULT Maybe< bool > WriteValue (Local< Context > context, Local< Value > value)
 
V8_WARN_UNUSED_RESULT std::pair< uint8_t *, size_t > Release ()
 
void TransferArrayBuffer (uint32_t transfer_id, Local< ArrayBuffer > array_buffer)
 
void SetTreatArrayBufferViewsAsHostObjects (bool mode)
 
void WriteUint32 (uint32_t value)
 
void WriteUint64 (uint64_t value)
 
void WriteDouble (double value)
 
void WriteRawBytes (const void *source, size_t length)
 
 ValueSerializer (const ValueSerializer &)=delete
 
void operator= (const ValueSerializer &)=delete
 

Detailed Description

Value serialization compatible with the HTML structured clone algorithm. The format is backward-compatible (i.e. safe to store to disk).

Definition at line 65 of file v8-value-serializer.h.

Constructor & Destructor Documentation

◆ ValueSerializer() [1/3]

ValueSerializer ( Isolate isolate)
explicit

◆ ValueSerializer() [2/3]

ValueSerializer ( Isolate isolate,
Delegate delegate 
)

◆ ~ValueSerializer()

◆ ValueSerializer() [3/3]

ValueSerializer ( const ValueSerializer )
delete

Member Function Documentation

◆ operator=()

void operator= ( const ValueSerializer )
delete

◆ Release()

V8_WARN_UNUSED_RESULT std::pair< uint8_t *, size_t > Release ( )

Returns the stored data (allocated using the delegate's ReallocateBufferMemory) and its size. This serializer should not be used once the buffer is released. The contents are undefined if a previous write has failed. Ownership of the buffer is transferred to the caller.

◆ SetTreatArrayBufferViewsAsHostObjects()

void SetTreatArrayBufferViewsAsHostObjects ( bool  mode)

Indicate whether to treat ArrayBufferView objects as host objects, i.e. pass them to Delegate::WriteHostObject. This should not be called when no Delegate was passed.

The default is not to treat ArrayBufferViews as host objects.

◆ TransferArrayBuffer()

void TransferArrayBuffer ( uint32_t  transfer_id,
Local< ArrayBuffer array_buffer 
)

Marks an ArrayBuffer as havings its contents transferred out of band. Pass the corresponding ArrayBuffer in the deserializing context to ValueDeserializer::TransferArrayBuffer.

◆ WriteDouble()

void WriteDouble ( double  value)

◆ WriteHeader()

void WriteHeader ( )

Writes out a header, which includes the format version.

◆ WriteRawBytes()

void WriteRawBytes ( const void *  source,
size_t  length 
)

◆ WriteUint32()

void WriteUint32 ( uint32_t  value)

Write raw data in various common formats to the buffer. Note that integer types are written in base-128 varint format, not with a binary copy. For use during an override of Delegate::WriteHostObject.

◆ WriteUint64()

void WriteUint64 ( uint64_t  value)

◆ WriteValue()

V8_WARN_UNUSED_RESULT Maybe< bool > WriteValue ( Local< Context context,
Local< Value value 
)

Serializes a JavaScript value into the buffer.


The documentation for this class was generated from the following file: