LLVM 19.0.0git
Public Member Functions | List of all members
llvm::msgpack::Writer Class Reference

Writes MessagePack objects to an output stream, one at a time. More...

#include "llvm/BinaryFormat/MsgPackWriter.h"

Public Member Functions

 Writer (raw_ostream &OS, bool Compatible=false)
 Construct a writer, optionally enabling "Compatibility Mode" as defined in the MessagePack specification.
 
 Writer (const Writer &)=delete
 
Writeroperator= (const Writer &)=delete
 
void writeNil ()
 Write a Nil to the output stream.
 
void write (bool b)
 Write a Boolean to the output stream.
 
void write (int64_t i)
 Write a signed integer to the output stream.
 
void write (uint64_t u)
 Write an unsigned integer to the output stream.
 
void write (double d)
 Write a floating point number to the output stream.
 
void write (StringRef s)
 Write a string to the output stream.
 
void write (MemoryBufferRef Buffer)
 Write a memory buffer to the output stream.
 
void writeArraySize (uint32_t Size)
 Write the header for an Array of the given size.
 
void writeMapSize (uint32_t Size)
 Write the header for a Map of the given size.
 
void writeExt (int8_t Type, MemoryBufferRef Buffer)
 Write a typed memory buffer (an extension type) to the output stream.
 

Detailed Description

Writes MessagePack objects to an output stream, one at a time.

Definition at line 41 of file MsgPackWriter.h.

Constructor & Destructor Documentation

◆ Writer() [1/2]

Writer::Writer ( raw_ostream OS,
bool  Compatible = false 
)

Construct a writer, optionally enabling "Compatibility Mode" as defined in the MessagePack specification.

When in Compatible mode, the writer will write Str16 formats instead of Str8 formats, and will refuse to write any Bin formats.

Parameters
OSstream to output MessagePack objects to.
Compatiblewhen set, write in "Compatibility Mode".

Definition at line 22 of file MsgPackWriter.cpp.

◆ Writer() [2/2]

llvm::msgpack::Writer::Writer ( const Writer )
delete

Member Function Documentation

◆ operator=()

Writer & llvm::msgpack::Writer::operator= ( const Writer )
delete

◆ write() [1/6]

void Writer::write ( bool  b)

Write a Boolean to the output stream.

The output will be a bool format.

Definition at line 27 of file MsgPackWriter.cpp.

References llvm::support::endian::Writer::write().

Referenced by write(), and llvm::msgpack::Document::writeToBlob().

◆ write() [2/6]

void Writer::write ( double  d)

Write a floating point number to the output stream.

The output will be in the smallest possible float format.

Definition at line 90 of file MsgPackWriter.cpp.

References llvm::support::endian::Writer::write().

◆ write() [3/6]

void Writer::write ( int64_t  i)

Write a signed integer to the output stream.

The output will be in the smallest possible int format.

The format chosen may be for an unsigned integer.

Definition at line 29 of file MsgPackWriter.cpp.

References llvm::support::endian::Writer::write(), and write().

◆ write() [4/6]

void Writer::write ( MemoryBufferRef  Buffer)

Write a memory buffer to the output stream.

The output will be in the smallest possible bin format.

Warning
Do not use this overload if in Compatible mode.

Definition at line 123 of file MsgPackWriter.cpp.

References assert(), llvm::MemoryBufferRef::getBufferSize(), llvm::MemoryBufferRef::getBufferStart(), llvm::support::endian::Writer::OS, Size, llvm::support::endian::Writer::write(), and llvm::raw_ostream::write().

◆ write() [5/6]

void Writer::write ( StringRef  s)

Write a string to the output stream.

The output will be in the smallest possible str format.

Definition at line 103 of file MsgPackWriter.cpp.

References assert(), llvm::support::endian::Writer::OS, llvm::StringRef::size(), Size, and llvm::support::endian::Writer::write().

◆ write() [6/6]

void Writer::write ( uint64_t  u)

Write an unsigned integer to the output stream.

The output will be in the smallest possible int format.

Definition at line 62 of file MsgPackWriter.cpp.

References llvm::support::endian::Writer::write().

◆ writeArraySize()

void Writer::writeArraySize ( uint32_t  Size)

Write the header for an Array of the given size.

The output will be in the smallest possible array format. The header contains an identifier for the array format used, as well as an encoding of the size of the array.

N.B. The caller must subsequently call Write an additional Size times to complete the array.

Definition at line 143 of file MsgPackWriter.cpp.

References Size, and llvm::support::endian::Writer::write().

Referenced by llvm::msgpack::Document::writeToBlob().

◆ writeExt()

void Writer::writeExt ( int8_t  Type,
MemoryBufferRef  Buffer 
)

Write a typed memory buffer (an extension type) to the output stream.

The output will be in the smallest possible ext format.

Definition at line 175 of file MsgPackWriter.cpp.

References assert(), llvm::MemoryBufferRef::getBufferSize(), llvm::MemoryBufferRef::getBufferStart(), llvm::support::endian::Writer::OS, Size, llvm::support::endian::Writer::write(), and llvm::raw_ostream::write().

◆ writeMapSize()

void Writer::writeMapSize ( uint32_t  Size)

Write the header for a Map of the given size.

The output will be in the smallest possible map format. The header contains an identifier for the map format used, as well as an encoding of the size of the map.

N.B. The caller must subsequently call Write and additional Size*2 times to complete the map. Each even numbered call to Write defines a new key, and each odd numbered call defines the previous key's value.

Definition at line 159 of file MsgPackWriter.cpp.

References Size, and llvm::support::endian::Writer::write().

Referenced by llvm::msgpack::Document::writeToBlob().

◆ writeNil()

void Writer::writeNil ( )

Write a Nil to the output stream.

The output will be the nil format.

Definition at line 25 of file MsgPackWriter.cpp.

References llvm::support::endian::Writer::write().

Referenced by llvm::msgpack::Document::writeToBlob().


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