LLVM 20.0.0git
|
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 | |
Writer & | operator= (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. | |
Writes MessagePack objects to an output stream, one at a time.
Definition at line 41 of file MsgPackWriter.h.
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.
OS | stream to output MessagePack objects to. |
Compatible | when set, write in "Compatibility Mode". |
Definition at line 22 of file MsgPackWriter.cpp.
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().
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().
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().
void Writer::write | ( | MemoryBufferRef | Buffer | ) |
Write a memory buffer to the output stream.
The output will be in the smallest possible bin format.
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().
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().
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().
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().
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().
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().
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().