Implements serialization feature of MsgPack. More...

Inherits IDisposable.

Inherited by MsgPack.ByteArrayPacker, and MsgPack.MessagePackStreamPacker.

Public Member Functions

void Dispose ()
 Clean up internal resources. More...
 
virtual void Flush ()
 Flushes internal buffer (including underlying stream). More...
 
Packer Pack (sbyte value)
 Packs SByte value to current stream. More...
 
Packer Pack (byte value)
 Packs Byte value to current stream. More...
 
Packer Pack (bool value)
 Packs Boolean value to current stream. More...
 
Packer PackNull ()
 Packs a null value to current stream. More...
 
Packer Pack (SByte? value)
 Pack nullable SByte value. More...
 
Packer Pack (Byte? value)
 Pack nullable Byte value. More...
 
Packer Pack (Int16? value)
 Pack nullable Int16 value. More...
 
Packer Pack (UInt16? value)
 Pack nullable UInt16 value. More...
 
Packer Pack (Int32? value)
 Pack nullable Int32 value. More...
 
Packer Pack (UInt32? value)
 Pack nullable UInt32 value. More...
 
Packer Pack (Int64? value)
 Pack nullable Int64 value. More...
 
Packer Pack (UInt64? value)
 Pack nullable UInt64 value. More...
 
Packer Pack (Single? value)
 Pack nullable Single value. More...
 
Packer Pack (Double? value)
 Pack nullable Double value. More...
 
Packer Pack (Boolean? value)
 Pack nullable Boolean value. More...
 
Packer Pack (Int16 value)
 Packs Int16 value to current stream. More...
 
Packer Pack (UInt16 value)
 Packs UInt16 value to current stream. More...
 
Packer Pack (Int32 value)
 Packs Int32 value to current stream. More...
 
Packer Pack (UInt32 value)
 Packs UInt32 value to current stream. More...
 
Packer Pack (Int64 value)
 Packs Int64 value to current stream. More...
 
Packer Pack (UInt64 value)
 Packs UInt64 value to current stream. More...
 
Packer Pack (float value)
 Packs Single value to current stream. More...
 
Packer Pack (double value)
 Packs Double value to current stream. More...
 
Packer PackArrayHeader (int count)
 Bookkeep array length or list items count to be packed on current stream. More...
 
Packer PackMapHeader (int count)
 Bookkeep dictionary (map) items count to be packed on current stream. More...
 
Packer PackRawHeader (int length)
 Bookkeep byte length to be packed on current stream as the bytes might represent well formed encoded string. More...
 
Packer PackStringHeader (int length)
 Bookkeep byte length to be packed on current stream as the bytes should represent well formed encoded string. More...
 
Packer PackBinaryHeader (int length)
 Bookkeep byte length to be packed on current stream as the bytes should not represent well formed encoded string. More...
 
Packer PackRaw (IEnumerable< byte > value)
 Packs specified byte sequence(it may or may not be string to current stream. More...
 
Packer PackRaw (IList< byte > value)
 Packs specified byte collection(it may or may not be string to current stream. More...
 
Packer PackRaw (byte[] value)
 Packs specified byte array(it may or may not be string to current stream. More...
 
Packer PackBinary (IEnumerable< byte > value)
 Packs specified byte sequence(it should not be string to current stream. More...
 
Packer PackBinary (IList< byte > value)
 Packs specified byte collection(it should not be string to current stream. More...
 
Packer PackBinary (byte[] value)
 Packs specified byte array(it should not be string to current stream. More...
 
Packer PackString (IEnumerable< char > value)
 Packs specified charactor sequence to current stream with UTF-8 Encoding. More...
 
Packer PackString (IEnumerable< char > value, Encoding encoding)
 Packs specified charactor sequence to current stream with specified Encoding. More...
 
Packer PackString (string value)
 Packs specified string to current stream with UTF-8 Encoding. More...
 
Packer PackString (string value, Encoding encoding)
 Packs specified string to current stream with specified Encoding. More...
 
Packer PackRawBody (byte[] value)
 Packs specified byte array to current stream without any header. More...
 
Packer PackRawBody (IEnumerable< byte > value)
 Packs specified byte sequence to current stream without any header. More...
 
Packer PackArrayHeader< TItem > (IList< TItem > array)
 Bookkeep collection count to be packed on current stream. More...
 
Packer PackMapHeader< TKey, TValue > (IDictionary< TKey, TValue > map)
 Bookkeep dictionary count to be packed on current stream. More...
 
Packer PackExtendedTypeValue (byte typeCode, byte[] body)
 Packs an extended type value. More...
 
Packer PackExtendedTypeValue (MessagePackExtendedTypeObject mpeto)
 Packs an extended type value. More...
 

Static Public Member Functions

static Packer Create (Stream stream)
 Create standard Safe Packer instance wrapping specified Stream with DefaultCompatibilityOptions. More...
 
static Packer Create (Stream stream, PackerCompatibilityOptions compatibilityOptions)
 Create standard Safe Packer instance wrapping specified Stream with specified PackerCompatibilityOptions. More...
 
static Packer Create (Stream stream, bool ownsStream)
 Create standard Safe Packer instance wrapping specified Stream with DefaultCompatibilityOptions. More...
 
static Packer Create (Stream stream, PackerCompatibilityOptions compatibilityOptions, bool ownsStream)
 Create standard Safe Packer instance wrapping specified Stream with specified PackerCompatibilityOptions. More...
 
static Packer Create (Stream stream, PackerCompatibilityOptions compatibilityOptions, PackerUnpackerStreamOptions streamOptions)
 Create standard Safe Packer instance wrapping specified Stream with specified PackerCompatibilityOptions. More...
 
static ByteArrayPacker Create (byte[] buffer)
 Creates a new ByteArrayPacker from specified byte array with DefaultCompatibilityOptions allowing expansion. More...
 
static ByteArrayPacker Create (byte[] buffer, int startOffset)
 Creates a new ByteArrayPacker from specified byte array list with DefaultCompatibilityOptions allowing expansion. More...
 
static ByteArrayPacker Create (byte[] buffer, bool allowsBufferExpansion, PackerCompatibilityOptions compatibilityOptions)
 Creates a new ByteArrayPacker from specified byte array list with compatibility options. More...
 
static ByteArrayPacker Create (byte[] buffer, int startOffset, bool allowsBufferExpansion, PackerCompatibilityOptions compatibilityOptions)
 Creates a new ByteArrayPacker from specified byte array with compatibility options. More...
 
static ByteArrayPacker Create (byte[] buffer, Func< byte[], int, byte[]> allocator, PackerCompatibilityOptions compatibilityOptions)
 Creates a new ByteArrayPacker from specified byte array with compatibility options and custom allocator. More...
 
static ByteArrayPacker Create (byte[] buffer, int startOffset, Func< byte[], int, byte[]> allocator, PackerCompatibilityOptions compatibilityOptions)
 Creates a new ByteArrayPacker from specified byte array with compatibility options and custom allocator. More...
 

Protected Member Functions

 Packer ()
 Initializes a new instance of the Packer class with DefaultCompatibilityOptions. More...
 
 Packer (PackerCompatibilityOptions compatibilityOptions)
 Initializes a new instance of the Packer class with specified PackerCompatibilityOptions. More...
 
virtual void Dispose (bool disposing)
 When overridden by derived class, release all unmanaged resources, optionally release managed resources. More...
 
virtual void SeekTo (long offset)
 When overridden by derived class, change current position to specified offset. More...
 
abstract void WriteByte (byte value)
 When overridden by derived class, writes specified byte to stream using implementation specific manner. More...
 
virtual void WriteBytes (ICollection< byte > value)
 Writes specified bytes to stream using implementation specific most efficient manner. More...
 
virtual void WriteBytes (byte[] value, bool isImmutable)
 Writes specified bytes to stream using implementation specific most efficient manner. More...
 
virtual void PackCore (sbyte value)
 Packs SByte value to current stream. More...
 
bool TryPackInt8 (long value)
 Try packs SByte value to current stream strictly. More...
 
virtual void PackCore (byte value)
 Packs Byte value to current stream. More...
 
bool TryPackUInt8 (ulong value)
 Try packs Byte value to current stream strictly. More...
 
virtual void PackCore (bool value)
 Packs Boolean value to current stream. More...
 
bool TryPackTinySignedInteger (long value)
 Try packs SByte value to current stream as tiny fix num. More...
 
bool TryPackTinyUnsignedInteger (ulong value)
 Try packs Byte value to current stream as tiny fix num. More...
 
virtual void PackCore (Int16 value)
 Packs Int16 value to current stream. More...
 
bool TryPackInt16 (Int64 value)
 Try packs Int16 value to current stream strictly. More...
 
virtual void PackCore (UInt16 value)
 Packs UInt16 value to current stream. More...
 
bool TryPackUInt16 (UInt64 value)
 Try packs UInt16 value to current stream strictly. More...
 
virtual void PackCore (Int32 value)
 Packs Int32 value to current stream. More...
 
bool TryPackInt32 (Int64 value)
 Try packs Int32 value to current stream strictly. More...
 
virtual void PackCore (UInt32 value)
 Packs UInt32 value to current stream. More...
 
bool TryPackUInt32 (UInt64 value)
 Try packs UInt32 value to current stream strictly. More...
 
virtual void PackCore (Int64 value)
 Packs Int64 value to current stream. More...
 
bool TryPackInt64 (Int64 value)
 Try packs Int64 value to current stream strictly. More...
 
virtual void PackCore (UInt64 value)
 Packs UInt64 value to current stream. More...
 
bool TryPackUInt64 (UInt64 value)
 Try packs UInt64 value to current stream strictly. More...
 
virtual void PackCore (float value)
 Packs Single value to current stream. More...
 
virtual void PackCore (double value)
 Packs Double value to current stream. More...
 
virtual void PackArrayHeaderCore (int count)
 Bookkeep array length or list items count to be packed on current stream. More...
 
virtual void PackMapHeaderCore (int count)
 Bookkeep dictionary (map) items count to be packed on current stream. More...
 
void PackRawHeaderCore (int length)
 Bookkeep byte length to be packed on current stream as the bytes might represent well formed encoded string. More...
 
virtual void PackStringHeaderCore (int length)
 Bookkeep byte length to be packed on current stream as the bytes should represent well formed encoded string. More...
 
virtual void PackBinaryHeaderCore (int length)
 Bookkeep byte length to be packed on current stream as the bytes should not represent well formed encoded string. More...
 
virtual void PackRawCore (byte[] value)
 Packs specified byte array(it may or may not be string to current stream. More...
 
virtual void PackBinaryCore (byte[] value)
 Packs specified byte array(it should not be string to current stream. More...
 
virtual void PackStringCore (IEnumerable< char > value, Encoding encoding)
 Packs specified charactor sequence to current stream with specified Encoding. More...
 
virtual void PackStringCore (string value, Encoding encoding)
 Packs specified string to current stream with specified Encoding. More...
 
virtual void PackRawCore (string value)
 Packs specified String to current stream with UTF-8 Encoding. More...
 
virtual void PackExtendedTypeValueCore (byte typeCode, byte[] body)
 Packs an extended type value. More...
 

Properties

static PackerCompatibilityOptions DefaultCompatibilityOptions [get, set]
 Gets or sets the default PackerCompatibilityOptions for all instances. More...
 
virtual bool CanSeek [get]
 Get whether this class supports seek operation and quering Position property. More...
 
virtual long Position [get]
 Get current position of underlying stream. More...
 
PackerCompatibilityOptions CompatibilityOptions [get]
 Gets a compatibility options for this instance. More...
 

Detailed Description

Implements serialization feature of MsgPack.

Constructor & Destructor Documentation

◆ Packer() [1/2]

MsgPack.Packer.Packer ( )
protected

Initializes a new instance of the Packer class with DefaultCompatibilityOptions.

◆ Packer() [2/2]

MsgPack.Packer.Packer ( PackerCompatibilityOptions  compatibilityOptions)
protected

Initializes a new instance of the Packer class with specified PackerCompatibilityOptions.

Parameters
compatibilityOptionsA PackerCompatibilityOptions which specifies compatibility options.

Member Function Documentation

◆ Create() [1/11]

static ByteArrayPacker MsgPack.Packer.Create ( byte[]  buffer)
static

Creates a new ByteArrayPacker from specified byte array with DefaultCompatibilityOptions allowing expansion.

Parameters
bufferThe source byte array.
Returns
ByteArrayPacker instance. This value will not be null.

◆ Create() [2/11]

static ByteArrayPacker MsgPack.Packer.Create ( byte[]  buffer,
bool  allowsBufferExpansion,
PackerCompatibilityOptions  compatibilityOptions 
)
static

Creates a new ByteArrayPacker from specified byte array list with compatibility options.

Parameters
bufferThe source byte array.
allowsBufferExpansionIf true, new buffer is allocated in product of the original size and golden ratio. Otherwise, the buffer will never be replaced.
compatibilityOptionsA PackerCompatibilityOptions which specifies compatibility options.
Returns
ByteArrayPacker instance. This value will not be null.

◆ Create() [3/11]

static ByteArrayPacker MsgPack.Packer.Create ( byte[]  buffer,
Func< byte[], int, byte[]>  allocator,
PackerCompatibilityOptions  compatibilityOptions 
)
static

Creates a new ByteArrayPacker from specified byte array with compatibility options and custom allocator.

Parameters
bufferThe source byte array.
allocatorA delegate to allocate new byte array which has requested size at least. The first argument is old buffer which contains written data and second argument is requested (required) size. The delegate must return new byte array which has enough size for requested write and contains old buffer's content. If the delegate returns null, the packer will consider it as allocation failure.
compatibilityOptionsA PackerCompatibilityOptions which specifies compatibility options.
Returns
ByteArrayPacker instance. This value will not be null.
Exceptions
ArgumentNullExceptionallocator is null.

◆ Create() [4/11]

static ByteArrayPacker MsgPack.Packer.Create ( byte[]  buffer,
int  startOffset 
)
static

Creates a new ByteArrayPacker from specified byte array list with DefaultCompatibilityOptions allowing expansion.

Parameters
bufferThe source byte array.
startOffsetThe effective start offset of the buffer .
Returns
ByteArrayPacker instance. This value will not be null.
Exceptions
ArgumentOutOfRangeExceptionstartOffset is negative.
ArgumentExceptionThe array length of buffer is too small.

◆ Create() [5/11]

static ByteArrayPacker MsgPack.Packer.Create ( byte[]  buffer,
int  startOffset,
bool  allowsBufferExpansion,
PackerCompatibilityOptions  compatibilityOptions 
)
static

Creates a new ByteArrayPacker from specified byte array with compatibility options.

Parameters
bufferThe source byte array.
startOffsetThe effective start offset of the buffer .
allowsBufferExpansionIf true, new buffer is allocated in product of the original size and golden ratio. Otherwise, the buffer will never be replaced.
compatibilityOptionsA PackerCompatibilityOptions which specifies compatibility options.
Returns
ByteArrayPacker instance. This value will not be null.
Exceptions
ArgumentOutOfRangeExceptionstartOffset is negative.
ArgumentExceptionThe array length of buffer is too small.

◆ Create() [6/11]

static ByteArrayPacker MsgPack.Packer.Create ( byte[]  buffer,
int  startOffset,
Func< byte[], int, byte[]>  allocator,
PackerCompatibilityOptions  compatibilityOptions 
)
static

Creates a new ByteArrayPacker from specified byte array with compatibility options and custom allocator.

Parameters
bufferThe source byte array.
startOffsetThe effective start offset of the buffer .
allocatorA delegate to allocate new byte array which has requested size at least. The first argument is old buffer which contains written data and second argument is requested (required) size. The delegate must return new byte array which has enough size for requested write and contains old buffer's content. If the delegate returns null, the packer will consider it as allocation failure.
compatibilityOptionsA PackerCompatibilityOptions which specifies compatibility options.
Returns
ByteArrayPacker instance. This value will not be null.
Exceptions
ArgumentNullExceptionallocator is null.
ArgumentOutOfRangeExceptionstartOffset is negative.
ArgumentExceptionThe array length of buffer is too small.

◆ Create() [7/11]

static Packer MsgPack.Packer.Create ( Stream  stream)
static

Create standard Safe Packer instance wrapping specified Stream with DefaultCompatibilityOptions.

Parameters
streamStream object. This stream will be closed when Packer.Dispose(Boolean) is called.
Returns
Safe Packer. This will not be null.
Exceptions
ArgumentNullExceptionstream is null.

You can specify any derived Stream class like FileStream, MemoryStream, NetworkStream, UnmanagedMemoryStream, or so.

◆ Create() [8/11]

static Packer MsgPack.Packer.Create ( Stream  stream,
bool  ownsStream 
)
static

Create standard Safe Packer instance wrapping specified Stream with DefaultCompatibilityOptions.

Parameters
streamStream object.
ownsStreamtrue to close stream when this instance is disposed; false, otherwise.
Returns
Safe Packer. This will not be null.
Exceptions
ArgumentNullExceptionstream is null.

You can specify any derived Stream class like FileStream, MemoryStream, NetworkStream, UnmanagedMemoryStream, or so.

◆ Create() [9/11]

static Packer MsgPack.Packer.Create ( Stream  stream,
PackerCompatibilityOptions  compatibilityOptions 
)
static

Create standard Safe Packer instance wrapping specified Stream with specified PackerCompatibilityOptions.

Parameters
streamStream object. This stream will be closed when Packer.Dispose(Boolean) is called.
compatibilityOptionsA PackerCompatibilityOptions which specifies compatibility options.
Returns
Safe Packer. This will not be null.
Exceptions
ArgumentNullExceptionstream is null.

You can specify any derived Stream class like FileStream, MemoryStream, NetworkStream, UnmanagedMemoryStream, or so.

◆ Create() [10/11]

static Packer MsgPack.Packer.Create ( Stream  stream,
PackerCompatibilityOptions  compatibilityOptions,
bool  ownsStream 
)
static

Create standard Safe Packer instance wrapping specified Stream with specified PackerCompatibilityOptions.

Parameters
streamStream object.
compatibilityOptionsA PackerCompatibilityOptions which specifies compatibility options.
ownsStreamtrue to close stream when this instance is disposed; false, otherwise.
Returns
Safe Packer. This will not be null.
Exceptions
ArgumentNullExceptionstream is null.

You can specify any derived Stream class like FileStream, MemoryStream, NetworkStream, UnmanagedMemoryStream, or so.

◆ Create() [11/11]

static Packer MsgPack.Packer.Create ( Stream  stream,
PackerCompatibilityOptions  compatibilityOptions,
PackerUnpackerStreamOptions  streamOptions 
)
static

Create standard Safe Packer instance wrapping specified Stream with specified PackerCompatibilityOptions.

Parameters
streamStream object.
compatibilityOptionsA PackerCompatibilityOptions which specifies compatibility options.
streamOptionsPackerUnpackerStreamOptions which specifies stream handling options.
Returns
Safe Packer. This will not be null.
Exceptions
ArgumentNullExceptionstream is null.

You can specify any derived Stream class like FileStream, MemoryStream, NetworkStream, UnmanagedMemoryStream, or so.

◆ Dispose() [1/2]

void MsgPack.Packer.Dispose ( )

Clean up internal resources.

◆ Dispose() [2/2]

virtual void MsgPack.Packer.Dispose ( bool  disposing)
protectedvirtual

When overridden by derived class, release all unmanaged resources, optionally release managed resources.

Parameters
disposingIf true, release managed resources too.

◆ Flush()

virtual void MsgPack.Packer.Flush ( )
virtual

Flushes internal buffer (including underlying stream).

◆ Pack() [1/22]

Packer MsgPack.Packer.Pack ( bool  value)

Packs Boolean value to current stream.

Parameters
valueBoolean value.
Returns
This instance.

◆ Pack() [2/22]

Packer MsgPack.Packer.Pack ( Boolean?  value)

Pack nullable Boolean value.

Parameters
valueValue to serialize.
Returns
This instance.

◆ Pack() [3/22]

Packer MsgPack.Packer.Pack ( byte  value)

Packs Byte value to current stream.

Parameters
valueByte value.
Returns
This instance.
Exceptions
ObjectDisposedExceptionThis instance has been disposed.

◆ Pack() [4/22]

Packer MsgPack.Packer.Pack ( Byte?  value)

Pack nullable Byte value.

Parameters
valueValue to serialize.
Returns
This instance.

◆ Pack() [5/22]

Packer MsgPack.Packer.Pack ( double  value)

Packs Double value to current stream.

Parameters
valueDouble value.
Returns
This instance.

◆ Pack() [6/22]

Packer MsgPack.Packer.Pack ( Double?  value)

Pack nullable Double value.

Parameters
valueValue to serialize.
Returns
This instance.

◆ Pack() [7/22]

Packer MsgPack.Packer.Pack ( float  value)

Packs Single value to current stream.

Parameters
valueSingle value.
Returns
This instance.

◆ Pack() [8/22]

Packer MsgPack.Packer.Pack ( Int16  value)

Packs Int16 value to current stream.

Parameters
valueInt16 value.
Returns
This instance.
Exceptions
ObjectDisposedExceptionThis instance has been disposed.

◆ Pack() [9/22]

Packer MsgPack.Packer.Pack ( Int16?  value)

Pack nullable Int16 value.

Parameters
valueValue to serialize.
Returns
This instance.

◆ Pack() [10/22]

Packer MsgPack.Packer.Pack ( Int32  value)

Packs Int32 value to current stream.

Parameters
valueInt32 value.
Returns
This instance.
Exceptions
ObjectDisposedExceptionThis instance has been disposed.

◆ Pack() [11/22]

Packer MsgPack.Packer.Pack ( Int32?  value)

Pack nullable Int32 value.

Parameters
valueValue to serialize.
Returns
This instance.

◆ Pack() [12/22]

Packer MsgPack.Packer.Pack ( Int64  value)

Packs Int64 value to current stream.

Parameters
valueInt64 value.
Returns
This instance.
Exceptions
ObjectDisposedExceptionThis instance has been disposed.

◆ Pack() [13/22]

Packer MsgPack.Packer.Pack ( Int64?  value)

Pack nullable Int64 value.

Parameters
valueValue to serialize.
Returns
This instance.

◆ Pack() [14/22]

Packer MsgPack.Packer.Pack ( sbyte  value)

Packs SByte value to current stream.

Parameters
valueSByte value.
Returns
This instance.
Exceptions
ObjectDisposedExceptionThis instance has been disposed.

◆ Pack() [15/22]

Packer MsgPack.Packer.Pack ( SByte?  value)

Pack nullable SByte value.

Parameters
valueValue to serialize.
Returns
This instance.

◆ Pack() [16/22]

Packer MsgPack.Packer.Pack ( Single?  value)

Pack nullable Single value.

Parameters
valueValue to serialize.
Returns
This instance.

◆ Pack() [17/22]

Packer MsgPack.Packer.Pack ( UInt16  value)

Packs UInt16 value to current stream.

Parameters
valueUInt16 value.
Returns
This instance.
Exceptions
ObjectDisposedExceptionThis instance has been disposed.

◆ Pack() [18/22]

Packer MsgPack.Packer.Pack ( UInt16?  value)

Pack nullable UInt16 value.

Parameters
valueValue to serialize.
Returns
This instance.

◆ Pack() [19/22]

Packer MsgPack.Packer.Pack ( UInt32  value)

Packs UInt32 value to current stream.

Parameters
valueUInt32 value.
Returns
This instance.
Exceptions
ObjectDisposedExceptionThis instance has been disposed.

◆ Pack() [20/22]

Packer MsgPack.Packer.Pack ( UInt32?  value)

Pack nullable UInt32 value.

Parameters
valueValue to serialize.
Returns
This instance.

◆ Pack() [21/22]

Packer MsgPack.Packer.Pack ( UInt64  value)

Packs UInt64 value to current stream.

Parameters
valueUInt64 value.
Returns
This instance.
Exceptions
ObjectDisposedExceptionThis instance has been disposed.

◆ Pack() [22/22]

Packer MsgPack.Packer.Pack ( UInt64?  value)

Pack nullable UInt64 value.

Parameters
valueValue to serialize.
Returns
This instance.

◆ PackArrayHeader()

Packer MsgPack.Packer.PackArrayHeader ( int  count)

Bookkeep array length or list items count to be packed on current stream.

Parameters
countArray length or list items count.
Returns
This instance.
Exceptions
ObjectDisposedExceptionThis instance has been disposed.

◆ PackArrayHeader< TItem >()

Packer MsgPack.Packer.PackArrayHeader< TItem > ( IList< TItem >  array)

Bookkeep collection count to be packed on current stream.

Parameters
arrayCollection count to be written.
Returns
This instance.
Exceptions
ObjectDisposedExceptionThis instance has been disposed.

◆ PackArrayHeaderCore()

virtual void MsgPack.Packer.PackArrayHeaderCore ( int  count)
protectedvirtual

Bookkeep array length or list items count to be packed on current stream.

Parameters
countArray length or list items count.

◆ PackBinary() [1/3]

Packer MsgPack.Packer.PackBinary ( byte[]  value)

Packs specified byte array(it should not be string to current stream.

Parameters
valueA byte array.
Returns
This instance.
Exceptions
ObjectDisposedExceptionThis instance has been disposed.

This method use bin types unless CompatibilityOptions contains PackerCompatibilityOptions.PackBinaryAsRaw.

◆ PackBinary() [2/3]

Packer MsgPack.Packer.PackBinary ( IEnumerable< byte >  value)

Packs specified byte sequence(it should not be string to current stream.

Parameters
valueSource bytes its size is not known.
Returns
This instance.
Exceptions
ObjectDisposedExceptionThis instance has been disposed.

This method use bin types unless CompatibilityOptions contains PackerCompatibilityOptions.PackBinaryAsRaw.

◆ PackBinary() [3/3]

Packer MsgPack.Packer.PackBinary ( IList< byte >  value)

Packs specified byte collection(it should not be string to current stream.

Parameters
valueSource bytes its size is known.
Returns
This instance.
Exceptions
ObjectDisposedExceptionThis instance has been disposed.

This method use bin types unless CompatibilityOptions contains PackerCompatibilityOptions.PackBinaryAsRaw.

◆ PackBinaryCore()

virtual void MsgPack.Packer.PackBinaryCore ( byte[]  value)
protectedvirtual

Packs specified byte array(it should not be string to current stream.

Parameters
valueA byte array.

◆ PackBinaryHeader()

Packer MsgPack.Packer.PackBinaryHeader ( int  length)

Bookkeep byte length to be packed on current stream as the bytes should not represent well formed encoded string.

Parameters
lengthA length of byte array.
Returns
This instance.
Exceptions
ObjectDisposedExceptionThis instance has been disposed.

◆ PackBinaryHeaderCore()

virtual void MsgPack.Packer.PackBinaryHeaderCore ( int  length)
protectedvirtual

Bookkeep byte length to be packed on current stream as the bytes should not represent well formed encoded string.

Parameters
lengthA length of byte array.

◆ PackCore() [1/11]

virtual void MsgPack.Packer.PackCore ( bool  value)
protectedvirtual

Packs Boolean value to current stream.

Parameters
valueBoolean value.

◆ PackCore() [2/11]

virtual void MsgPack.Packer.PackCore ( byte  value)
protectedvirtual

Packs Byte value to current stream.

Parameters
valueByte value.

◆ PackCore() [3/11]

virtual void MsgPack.Packer.PackCore ( double  value)
protectedvirtual

Packs Double value to current stream.

Parameters
valueDouble value.

◆ PackCore() [4/11]

virtual void MsgPack.Packer.PackCore ( float  value)
protectedvirtual

Packs Single value to current stream.

Parameters
valueSingle value.

◆ PackCore() [5/11]

virtual void MsgPack.Packer.PackCore ( Int16  value)
protectedvirtual

Packs Int16 value to current stream.

Parameters
valueInt16 value.

◆ PackCore() [6/11]

virtual void MsgPack.Packer.PackCore ( Int32  value)
protectedvirtual

Packs Int32 value to current stream.

Parameters
valueInt32 value.

◆ PackCore() [7/11]

virtual void MsgPack.Packer.PackCore ( Int64  value)
protectedvirtual

Packs Int64 value to current stream.

Parameters
valueInt64 value.

◆ PackCore() [8/11]

virtual void MsgPack.Packer.PackCore ( sbyte  value)
protectedvirtual

Packs SByte value to current stream.

Parameters
valueSByte value.

◆ PackCore() [9/11]

virtual void MsgPack.Packer.PackCore ( UInt16  value)
protectedvirtual

Packs UInt16 value to current stream.

Parameters
valueUInt16 value.

◆ PackCore() [10/11]

virtual void MsgPack.Packer.PackCore ( UInt32  value)
protectedvirtual

Packs UInt32 value to current stream.

Parameters
valueUInt32 value.

◆ PackCore() [11/11]

virtual void MsgPack.Packer.PackCore ( UInt64  value)
protectedvirtual

Packs UInt64 value to current stream.

Parameters
valueUInt64 value.

◆ PackExtendedTypeValue() [1/2]

Packer MsgPack.Packer.PackExtendedTypeValue ( byte  typeCode,
byte[]  body 
)

Packs an extended type value.

Parameters
typeCodeA type code of the extended type value.
bodyA binary value portion of the extended type value.
Returns
This instance.
Exceptions
ArgumentNullExceptionbody is null.
InvalidOperationExceptionCompatibilityOptions property contains PackerCompatibilityOptions.ProhibitExtendedTypeObjects.
ObjectDisposedExceptionThis instance has been disposed.

◆ PackExtendedTypeValue() [2/2]

Packer MsgPack.Packer.PackExtendedTypeValue ( MessagePackExtendedTypeObject  mpeto)

Packs an extended type value.

Parameters
mpetoA MessagePackExtendedTypeObject to be packed.
Returns
This instance.
Exceptions
ArgumentExceptionMessagePackExtendedTypeObject.IsValid of mpeto is false.
InvalidOperationExceptionCompatibilityOptions property contains PackerCompatibilityOptions.ProhibitExtendedTypeObjects.
ObjectDisposedExceptionThis instance has been disposed.

◆ PackExtendedTypeValueCore()

virtual void MsgPack.Packer.PackExtendedTypeValueCore ( byte  typeCode,
byte[]  body 
)
protectedvirtual

Packs an extended type value.

Parameters
typeCodeA type code of the extended type value.
bodyA binary value portion of the extended type value.

◆ PackMapHeader()

Packer MsgPack.Packer.PackMapHeader ( int  count)

Bookkeep dictionary (map) items count to be packed on current stream.

Parameters
countDictionary (map) items count.
Returns
This instance.
Exceptions
ObjectDisposedExceptionThis instance has been disposed.

◆ PackMapHeader< TKey, TValue >()

Packer MsgPack.Packer.PackMapHeader< TKey, TValue > ( IDictionary< TKey, TValue >  map)

Bookkeep dictionary count to be packed on current stream.

Parameters
mapDictionary count to be written.
Returns
This instance.
Exceptions
ObjectDisposedExceptionThis instance has been disposed.

◆ PackMapHeaderCore()

virtual void MsgPack.Packer.PackMapHeaderCore ( int  count)
protectedvirtual

Bookkeep dictionary (map) items count to be packed on current stream.

Parameters
countDictionary (map) items count.

◆ PackNull()

Packer MsgPack.Packer.PackNull ( )

Packs a null value to current stream.

Returns
This instance.
Exceptions
ObjectDisposedExceptionThis instance has been disposed.

◆ PackRaw() [1/3]

Packer MsgPack.Packer.PackRaw ( byte[]  value)

Packs specified byte array(it may or may not be string to current stream.

Parameters
valueA byte array.
Returns
This instance.
Exceptions
ObjectDisposedExceptionThis instance has been disposed.

This method use str types (previously known as raw types) for compability.

◆ PackRaw() [2/3]

Packer MsgPack.Packer.PackRaw ( IEnumerable< byte >  value)

Packs specified byte sequence(it may or may not be string to current stream.

Parameters
valueSource bytes its size is not known.
Returns
This instance.
Exceptions
ObjectDisposedExceptionThis instance has been disposed.

This method use str types (previously known as raw types) for compability.

◆ PackRaw() [3/3]

Packer MsgPack.Packer.PackRaw ( IList< byte >  value)

Packs specified byte collection(it may or may not be string to current stream.

Parameters
valueSource bytes its size is known.
Returns
This instance.
Exceptions
ObjectDisposedExceptionThis instance has been disposed.

This method use str types (previously known as raw types) for compability.

◆ PackRawBody() [1/2]

Packer MsgPack.Packer.PackRawBody ( byte[]  value)

Packs specified byte array to current stream without any header.

Parameters
valueSource byte array.
Returns
This instance.
Exceptions
ObjectDisposedExceptionThis instance has been disposed.

If you forget to write header first, then resulting stream will be corrupsed.

◆ PackRawBody() [2/2]

Packer MsgPack.Packer.PackRawBody ( IEnumerable< byte >  value)

Packs specified byte sequence to current stream without any header.

Parameters
valueSource byte array.
Returns
This instance.
Exceptions
ObjectDisposedExceptionThis instance has been disposed.

If you forget to write header first, then resulting stream will be corrupsed.

◆ PackRawCore() [1/2]

virtual void MsgPack.Packer.PackRawCore ( byte[]  value)
protectedvirtual

Packs specified byte array(it may or may not be string to current stream.

Parameters
valueA byte array.

◆ PackRawCore() [2/2]

virtual void MsgPack.Packer.PackRawCore ( string  value)
protectedvirtual

Packs specified String to current stream with UTF-8 Encoding.

Parameters
valueA string.

◆ PackRawHeader()

Packer MsgPack.Packer.PackRawHeader ( int  length)

Bookkeep byte length to be packed on current stream as the bytes might represent well formed encoded string.

Parameters
lengthA length of byte array.
Returns
This instance.
Exceptions
ObjectDisposedExceptionThis instance has been disposed.

This method effectively acts as alias of PackStringHeader for compatibility.

◆ PackRawHeaderCore()

void MsgPack.Packer.PackRawHeaderCore ( int  length)
protected

Bookkeep byte length to be packed on current stream as the bytes might represent well formed encoded string.

Parameters
lengthA length of byte array.

This method acts as alias of PackStringHeaderCore for compatibility.

◆ PackString() [1/4]

Packer MsgPack.Packer.PackString ( IEnumerable< char >  value)

Packs specified charactor sequence to current stream with UTF-8 Encoding.

Parameters
valueSource chars its size is not known.
Returns
This instance.
Exceptions
ObjectDisposedExceptionThis instance has been disposed.

◆ PackString() [2/4]

Packer MsgPack.Packer.PackString ( IEnumerable< char >  value,
Encoding  encoding 
)

Packs specified charactor sequence to current stream with specified Encoding.

Parameters
valueSource chars its size is not known.
encodingEncoding to be used.
Returns
This instance.
Exceptions
ArgumentNullExceptionencoding is null.
ObjectDisposedExceptionThis instance has been disposed.

◆ PackString() [3/4]

Packer MsgPack.Packer.PackString ( string  value)

Packs specified string to current stream with UTF-8 Encoding.

Parameters
valueSource string.
Returns
This instance.
Exceptions
ObjectDisposedExceptionThis instance has been disposed.

◆ PackString() [4/4]

Packer MsgPack.Packer.PackString ( string  value,
Encoding  encoding 
)

Packs specified string to current stream with specified Encoding.

Parameters
valueSource string.
encodingEncoding to be used.
Returns
This instance.
Exceptions
ArgumentNullExceptionencoding is null.
ObjectDisposedExceptionThis instance has been disposed.

◆ PackStringCore() [1/2]

virtual void MsgPack.Packer.PackStringCore ( IEnumerable< char >  value,
Encoding  encoding 
)
protectedvirtual

Packs specified charactor sequence to current stream with specified Encoding.

Parameters
valueSource chars its size is not known.
encodingEncoding to be used.
Exceptions
ArgumentNullExceptionencoding is null.

◆ PackStringCore() [2/2]

virtual void MsgPack.Packer.PackStringCore ( string  value,
Encoding  encoding 
)
protectedvirtual

Packs specified string to current stream with specified Encoding.

Parameters
valueSource string.
encodingEncoding to be used.
Exceptions
ArgumentNullExceptionencoding is null.

◆ PackStringHeader()

Packer MsgPack.Packer.PackStringHeader ( int  length)

Bookkeep byte length to be packed on current stream as the bytes should represent well formed encoded string.

Parameters
lengthA length of encoded byte array.
Returns
This instance.
Exceptions
ObjectDisposedExceptionThis instance has been disposed.

◆ PackStringHeaderCore()

virtual void MsgPack.Packer.PackStringHeaderCore ( int  length)
protectedvirtual

Bookkeep byte length to be packed on current stream as the bytes should represent well formed encoded string.

Parameters
lengthA length of encoded byte array.

◆ SeekTo()

virtual void MsgPack.Packer.SeekTo ( long  offset)
protectedvirtual

When overridden by derived class, change current position to specified offset.

Parameters
offsetOffset. You shoud not specify the value which causes underflow or overflow.
Exceptions
NotSupportedExceptionA class of this instance does not support seek.

◆ TryPackInt16()

bool MsgPack.Packer.TryPackInt16 ( Int64  value)
protected

Try packs Int16 value to current stream strictly.

Parameters
valueMaybe Int16 value.
Returns
If value has be packed successfully then true, otherwise false (normally, larger type required).

◆ TryPackInt32()

bool MsgPack.Packer.TryPackInt32 ( Int64  value)
protected

Try packs Int32 value to current stream strictly.

Parameters
valueMaybe Int32 value.
Returns
If value has be packed successfully then true, otherwise false (normally, larger type required).

◆ TryPackInt64()

bool MsgPack.Packer.TryPackInt64 ( Int64  value)
protected

Try packs Int64 value to current stream strictly.

Parameters
valueMaybe Int64 value.
Returns
If value has be packed successfully then true, otherwise false (normally, larger type required).

◆ TryPackInt8()

bool MsgPack.Packer.TryPackInt8 ( long  value)
protected

Try packs SByte value to current stream strictly.

Parameters
valueMaybe SByte value.
Returns
If value has be packed successfully then true, otherwise false (normally, larger type required).

◆ TryPackTinySignedInteger()

bool MsgPack.Packer.TryPackTinySignedInteger ( long  value)
protected

Try packs SByte value to current stream as tiny fix num.

Parameters
valueMaybe tiny SByte value.
Returns
If value has be packed successfully then true, otherwise false (normally, larger type required).

◆ TryPackTinyUnsignedInteger()

bool MsgPack.Packer.TryPackTinyUnsignedInteger ( ulong  value)
protected

Try packs Byte value to current stream as tiny fix num.

Parameters
valueMaybe tiny Byte value.
Returns
If value has be packed successfully then true, otherwise false (normally, larger type required).

◆ TryPackUInt16()

bool MsgPack.Packer.TryPackUInt16 ( UInt64  value)
protected

Try packs UInt16 value to current stream strictly.

Parameters
valueMaybe UInt16 value.
Returns
If value has be packed successfully then true, otherwise false (normally, larger type required).

◆ TryPackUInt32()

bool MsgPack.Packer.TryPackUInt32 ( UInt64  value)
protected

Try packs UInt32 value to current stream strictly.

Parameters
valueMaybe UInt32 value.
Returns
If value has be packed successfully then true, otherwise false (normally, larger type required).

◆ TryPackUInt64()

bool MsgPack.Packer.TryPackUInt64 ( UInt64  value)
protected

Try packs UInt64 value to current stream strictly.

Parameters
valueMaybe UInt64 value.
Returns
If value has be packed successfully then true, otherwise false (normally, larger type required).

◆ TryPackUInt8()

bool MsgPack.Packer.TryPackUInt8 ( ulong  value)
protected

Try packs Byte value to current stream strictly.

Parameters
valueMaybe Byte value.
Returns
If value has be packed successfully then true, otherwise false (normally, larger type required).

◆ WriteByte()

abstract void MsgPack.Packer.WriteByte ( byte  value)
protectedpure virtual

When overridden by derived class, writes specified byte to stream using implementation specific manner.

Parameters
valueA byte to be written.

◆ WriteBytes() [1/2]

virtual void MsgPack.Packer.WriteBytes ( byte[]  value,
bool  isImmutable 
)
protectedvirtual

Writes specified bytes to stream using implementation specific most efficient manner.

Parameters
valueBytes to be written.
isImmutableIf the value can be treat as immutable (that is, can be used safely without copying) then true.

◆ WriteBytes() [2/2]

virtual void MsgPack.Packer.WriteBytes ( ICollection< byte >  value)
protectedvirtual

Writes specified bytes to stream using implementation specific most efficient manner.

Parameters
valueCollection of bytes to be written.

Property Documentation

◆ CanSeek

virtual bool MsgPack.Packer.CanSeek
get

Get whether this class supports seek operation and quering Position property.

If this class supports seek operation and quering Position property then true.

◆ CompatibilityOptions

PackerCompatibilityOptions MsgPack.Packer.CompatibilityOptions
get

Gets a compatibility options for this instance.

The compatibility options.

◆ DefaultCompatibilityOptions

PackerCompatibilityOptions MsgPack.Packer.DefaultCompatibilityOptions
staticgetset

Gets or sets the default PackerCompatibilityOptions for all instances.

The default PackerCompatibilityOptions. The default value is PackerCompatibilityOptions.Classic.

Note that modification of this value will affect all new instances from the point. Existent instances are not afectted by the modification.

This property is intended to be set in application initialization code.

Note that the default value is PackerCompatibilityOptions.Classic, not PackerCompatibilityOptions.None.

◆ Position

virtual long MsgPack.Packer.Position
get

Get current position of underlying stream.

Opaque position value of underlying stream.

Exceptions
NotSupportedExceptionA class of this instance does not support seek.

The documentation for this class was generated from the following files:
  • MsgPackSources/Packer.cs
  • MsgPackSources/Packer.Factory.cs
  • MsgPackSources/Packer.Nullable.cs
  • MsgPackSources/Packer.Packing.cs