Diffusion .NET Client Library  6.1.5
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
PushTechnology.ClientInterface.IO.CBOR.CBORWriter Class Reference

The CBOR writer that is able to write CBOR-encoded data to a stream. More...

Public Member Functions

 CBORWriter (Stream outputStream)
 Creates a new CBORWriter that is able to write CBOR-encoded data to a given output stream. More...
 
void WriteNull ()
 Writes a CBOR 'null' value to the stream. More...
 
void WriteBreak ()
 Writes a CBOR Break to the stream that indicates the end of a sequence or structure. More...
 
void WriteArray ()
 Writes a indefinite length CBOR array to the stream. More...
 
void WriteArray (int length)
 Writes a CBOR array with a specific number of items to the stream. More...
 
void WriteObject ()
 Writes a indefinite length CBOR object to the stream. More...
 
void WriteObject (int length)
 Writes a CBOR object with a specific number of key/value pairs to the stream. More...
 
void Write (bool value)
 Writes a CBOR boolean to the stream. More...
 
void Write (long value)
 Writes a CBOR integer to the stream. More...
 
void Write (float value)
 Writes a 32-bit CBOR floating point to the stream. More...
 
void Write (double value)
 Writes a 64-bit CBOR floating point to the stream. More...
 
void Write (byte[] value, int offset, int length)
 Writes a sequence of bytes to the stream. More...
 
void WriteIndefiniteBytes ()
 Writes a indefinite length byte sequence to the stream. More...
 
void Write (string value)
 Writes a CBOR string value to the stream. More...
 
void WriteIndefiniteString ()
 Writes a indefinite length CBOR string value to the stream. More...
 
void Flush ()
 Causes any buffered data to be written to the stream. More...
 

Static Public Member Functions

static int GetEncodedIntegerSize (long integerValue)
 Returns the size of a integer if encoded in CBOR. More...
 
static int GetEncodedByteSize (int byteLength)
 Returns the size of a byte sequence if encoded in CBOR. More...
 
static int GetEncodedStringSize (string stringValue)
 Returns the size of a UTF-8 encoded string if encoded in CBOR. More...
 

Public Attributes

Stream BaseStream => writer.BaseStream
 Returns the underlying stream. More...
 

Detailed Description

The CBOR writer that is able to write CBOR-encoded data to a stream.

The output is not validated which allows for illegal CBOR to be created by this writer.

Constructor & Destructor Documentation

PushTechnology.ClientInterface.IO.CBOR.CBORWriter.CBORWriter ( Stream  outputStream)

Creates a new CBORWriter that is able to write CBOR-encoded data to a given output stream.

The reader does not take ownership of the given outputStream . The stream needs to be disposed of if it is no longer needed.

Parameters
outputStreamThe output stream to write CBOR-encoded data to.
Exceptions
ArgumentNullExceptionThe given stream is null.
ArgumentExceptionThe given stream does not support writing.

Member Function Documentation

void PushTechnology.ClientInterface.IO.CBOR.CBORWriter.Flush ( )

Causes any buffered data to be written to the stream.

static int PushTechnology.ClientInterface.IO.CBOR.CBORWriter.GetEncodedByteSize ( int  byteLength)
static

Returns the size of a byte sequence if encoded in CBOR.

Parameters
byteLengthThe length of the byte sequence to be encoded in CBOR.
Returns
The size in bytes of the CBOR-encoded byte sequence.
static int PushTechnology.ClientInterface.IO.CBOR.CBORWriter.GetEncodedIntegerSize ( long  integerValue)
static

Returns the size of a integer if encoded in CBOR.

Parameters
integerValueThe integer value to be encoded in CBOR.
Returns
The size in bytes of the CBOR-encoded integer value.
static int PushTechnology.ClientInterface.IO.CBOR.CBORWriter.GetEncodedStringSize ( string  stringValue)
static

Returns the size of a UTF-8 encoded string if encoded in CBOR.

Parameters
stringValueThe string value to be encoded in CBOR.
Returns
The size in bytes of the CBOR-encoded UTF-8 string.
void PushTechnology.ClientInterface.IO.CBOR.CBORWriter.Write ( bool  value)

Writes a CBOR boolean to the stream.

Parameters
valueThe boolean value to write to the stream.
void PushTechnology.ClientInterface.IO.CBOR.CBORWriter.Write ( long  value)

Writes a CBOR integer to the stream.

Parameters
valueThe integer value to write to the stream.

The integer gets encoded in the smallest possible data type. See GetEncodedIntegerSize(long) to receive the size of the encoded value.

void PushTechnology.ClientInterface.IO.CBOR.CBORWriter.Write ( float  value)

Writes a 32-bit CBOR floating point to the stream.

Parameters
valueThe 32-bit floating point value to write to the stream.
void PushTechnology.ClientInterface.IO.CBOR.CBORWriter.Write ( double  value)

Writes a 64-bit CBOR floating point to the stream.

Parameters
valueThe 64-bit floating point value to write to the stream.
void PushTechnology.ClientInterface.IO.CBOR.CBORWriter.Write ( byte[]  value,
int  offset,
int  length 
)

Writes a sequence of bytes to the stream.

Parameters
valueThe byte sequence to write to the stream.
offsetThe starting index of the sequence.
lengthThe length of the sequence.
void PushTechnology.ClientInterface.IO.CBOR.CBORWriter.Write ( string  value)

Writes a CBOR string value to the stream.

Parameters
valueThe string value to write to the stream.

The string will be encoded in UTF-8 and can be a string value or a field name for key/value pairs.

void PushTechnology.ClientInterface.IO.CBOR.CBORWriter.WriteArray ( )

Writes a indefinite length CBOR array to the stream.

The array has to be closed by a CBOR Break in order to be valid.

void PushTechnology.ClientInterface.IO.CBOR.CBORWriter.WriteArray ( int  length)

Writes a CBOR array with a specific number of items to the stream.

Parameters
lengthThe number of items within the array.

This method has to be followed with the exact amount of items specified by the given length in order for the resulting CBOR to be valid.

void PushTechnology.ClientInterface.IO.CBOR.CBORWriter.WriteBreak ( )

Writes a CBOR Break to the stream that indicates the end of a sequence or structure.

void PushTechnology.ClientInterface.IO.CBOR.CBORWriter.WriteIndefiniteBytes ( )

Writes a indefinite length byte sequence to the stream.

The byte sequence has to be followed by a CBOR Break in order to be valid.

void PushTechnology.ClientInterface.IO.CBOR.CBORWriter.WriteIndefiniteString ( )

Writes a indefinite length CBOR string value to the stream.

The string sequence has to be followed by a CBOR Break in order to be valid.

void PushTechnology.ClientInterface.IO.CBOR.CBORWriter.WriteNull ( )

Writes a CBOR 'null' value to the stream.

void PushTechnology.ClientInterface.IO.CBOR.CBORWriter.WriteObject ( )

Writes a indefinite length CBOR object to the stream.

The object has to be closed by a CBOR Break in order to be valid.

void PushTechnology.ClientInterface.IO.CBOR.CBORWriter.WriteObject ( int  length)

Writes a CBOR object with a specific number of key/value pairs to the stream.

Parameters
lengthThe number of key/value pairs within the object.

This method has to be followed with the exact amount of key/value pairs specified by the given length in order for the resulting CBOR to be valid.

Member Data Documentation

Stream PushTechnology.ClientInterface.IO.CBOR.CBORWriter.BaseStream => writer.BaseStream

Returns the underlying stream.


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