Avro C#
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Avro.IO.ParsingEncoder Class Referenceabstract

Base class for a Parsing.Parser-based Encoders. More...

Inheritance diagram for Avro.IO.ParsingEncoder:
Avro.IO.Encoder Avro.IO.JsonEncoder

Public Member Functions

void WriteNull ()
 Writes a null value.
 
void WriteBoolean (bool value)
 Writes a boolean value.
Parameters
valueValue to write.

 
void WriteInt (int value)
 Writes an int value.
Parameters
valueValue to write.

 
void WriteLong (long value)
 Writes a long value.
Parameters
valueValue to write.

 
void WriteFloat (float value)
 Writes a float value.
Parameters
valueValue to write.

 
void WriteDouble (double value)
 Writes a double value.
Parameters
valueValue to write.

 
void WriteBytes (byte[] value)
 Writes a byte string.
Parameters
valueValue to write.

 
void WriteBytes (byte[] value, int offset, int length)
 Writes a byte string.
Parameters
valueThe byte[] to be read (fully or partially)
offsetThe offset from the beginning of the byte[] to start writing
lengthThe length of the data to be read from the byte[].

 
void WriteString (string value)
 Writes an Unicode string.
Parameters
valueValue to write.

 
void WriteEnum (int value)
 Writes an enumeration.
Parameters
valueValue to write.

 
void WriteArrayStart ()
 Call this method to start writing an array. When starting to serialize an array, call WriteArrayStart. Then, before writing any data for any item call SetItemCount(long) followed by a sequence of StartItem and the item itself. The number of StartItem should match the number specified in SetItemCount(long). When actually writing the data of the item, you can call any Encoder method (e.g., WriteLong(long)). When all items of the array have been written, call WriteArrayEnd. As an example, let's say you want to write an array of records, the record consisting of an Long field and a Boolean field. Your code would look something like this:
out.WriteArrayStart();
out.SetItemCount(list.Count);
foreach (var r in list)
{
out.StartItem();
out.WriteLong(r.LongField);
out.WriteBoolean(r.BoolField);
}
out.WriteArrayEnd();

 
void WriteArrayEnd ()
 Call this method to finish writing an array. See WriteArrayStart for usage information.
 
void WriteMapStart ()
 Call this to start a new map. See WriteArrayStart for details on usage. As an example of usage, let's say you want to write a map of records, the record consisting of an Long field and a Boolean field. Your code would look something like this:
out.WriteMapStart();
out.SetItemCount(dictionary.Count);
foreach (var entry in dictionary)
{
out.StartItem();
out.WriteString(entry.Key);
out.writeLong(entry.Value.LongField);
out.writeBoolean(entry.Value.BoolField);
}
out.WriteMapEnd();

 
void WriteMapEnd ()
 Call this method to terminate the inner-most, currently-opened map. See WriteArrayStart for more details.
 
void WriteUnionIndex (int value)
 Call this method to write the tag of a union. As an example of usage, let's say you want to write a union, whose second branch is a record consisting of an Long field and a Boolean field. Your code would look something like this:
out.WriteIndex(1);
out.WriteLong(record.LongField);
out.WriteBoolean(record.BoolField);

 
void WriteFixed (byte[] data)
 Writes a fixed value.
Parameters
dataThe contents to write.

 
void WriteFixed (byte[] data, int start, int len)
 Writes a fixed value.
Parameters
dataContents to write.
startPosition within data where the contents start.
lenNumber of bytes to write.

 
void Flush ()
 Flushes the encoder.
 
virtual void SetItemCount (long value)
 Call this method before writing a batch of items in an array or a map.
Parameters
valueNumber of StartItem calls to follow.

 
virtual void StartItem ()
 Start a new item of an array or map. See WriteArrayStart for usage information.
 

Protected Member Functions

void Push ()
 Push a new collection on to the stack.
 
void Pop ()
 Pop a new collection on to the stack.
 
int Depth ()
 Returns the position into the stack.
 

Protected Attributes

int Pos = -1
 Position into the counts stack.
 

Detailed Description

Base class for a Parsing.Parser-based Encoders.

Member Function Documentation

◆ Flush()

void Avro.IO.ParsingEncoder.Flush ( )
abstract

Flushes the encoder.

Implements Avro.IO.Encoder.

◆ SetItemCount()

virtual void Avro.IO.ParsingEncoder.SetItemCount ( long  value)
inlinevirtual

Call this method before writing a batch of items in an array or a map.

Parameters
valueNumber of StartItem calls to follow.

Implements Avro.IO.Encoder.

◆ StartItem()

virtual void Avro.IO.ParsingEncoder.StartItem ( )
inlinevirtual

Start a new item of an array or map. See WriteArrayStart for usage information.

Implements Avro.IO.Encoder.

Reimplemented in Avro.IO.JsonEncoder.

◆ WriteArrayEnd()

void Avro.IO.ParsingEncoder.WriteArrayEnd ( )
abstract

Call this method to finish writing an array. See WriteArrayStart for usage information.

Implements Avro.IO.Encoder.

◆ WriteArrayStart()

void Avro.IO.ParsingEncoder.WriteArrayStart ( )
abstract

Call this method to start writing an array. When starting to serialize an array, call WriteArrayStart. Then, before writing any data for any item call SetItemCount(long) followed by a sequence of StartItem and the item itself. The number of StartItem should match the number specified in SetItemCount(long). When actually writing the data of the item, you can call any Encoder method (e.g., WriteLong(long)). When all items of the array have been written, call WriteArrayEnd. As an example, let's say you want to write an array of records, the record consisting of an Long field and a Boolean field. Your code would look something like this:

out.WriteArrayStart();
out.SetItemCount(list.Count);
foreach (var r in list)
{
out.StartItem();
out.WriteLong(r.LongField);
out.WriteBoolean(r.BoolField);
}
out.WriteArrayEnd();

Implements Avro.IO.Encoder.

◆ WriteBoolean()

void Avro.IO.ParsingEncoder.WriteBoolean ( bool  value)
abstract

Writes a boolean value.

Parameters
valueValue to write.

Implements Avro.IO.Encoder.

◆ WriteBytes() [1/2]

void Avro.IO.ParsingEncoder.WriteBytes ( byte[]  value)
abstract

Writes a byte string.

Parameters
valueValue to write.

Implements Avro.IO.Encoder.

◆ WriteBytes() [2/2]

void Avro.IO.ParsingEncoder.WriteBytes ( byte[]  value,
int  offset,
int  length 
)
abstract

Writes a byte string.

Parameters
valueThe byte[] to be read (fully or partially)
offsetThe offset from the beginning of the byte[] to start writing
lengthThe length of the data to be read from the byte[].

Implements Avro.IO.Encoder.

◆ WriteDouble()

void Avro.IO.ParsingEncoder.WriteDouble ( double  value)
abstract

Writes a double value.

Parameters
valueValue to write.

Implements Avro.IO.Encoder.

◆ WriteEnum()

void Avro.IO.ParsingEncoder.WriteEnum ( int  value)
abstract

Writes an enumeration.

Parameters
valueValue to write.

Implements Avro.IO.Encoder.

◆ WriteFixed() [1/2]

void Avro.IO.ParsingEncoder.WriteFixed ( byte[]  data)
abstract

Writes a fixed value.

Parameters
dataThe contents to write.

Implements Avro.IO.Encoder.

◆ WriteFixed() [2/2]

void Avro.IO.ParsingEncoder.WriteFixed ( byte[]  data,
int  start,
int  len 
)
abstract

Writes a fixed value.

Parameters
dataContents to write.
startPosition within data where the contents start.
lenNumber of bytes to write.

Implements Avro.IO.Encoder.

◆ WriteFloat()

void Avro.IO.ParsingEncoder.WriteFloat ( float  value)
abstract

Writes a float value.

Parameters
valueValue to write.

Implements Avro.IO.Encoder.

◆ WriteInt()

void Avro.IO.ParsingEncoder.WriteInt ( int  value)
abstract

Writes an int value.

Parameters
valueValue to write.

Implements Avro.IO.Encoder.

◆ WriteLong()

void Avro.IO.ParsingEncoder.WriteLong ( long  value)
abstract

Writes a long value.

Parameters
valueValue to write.

Implements Avro.IO.Encoder.

◆ WriteMapEnd()

void Avro.IO.ParsingEncoder.WriteMapEnd ( )
abstract

Call this method to terminate the inner-most, currently-opened map. See WriteArrayStart for more details.

Implements Avro.IO.Encoder.

◆ WriteMapStart()

void Avro.IO.ParsingEncoder.WriteMapStart ( )
abstract

Call this to start a new map. See WriteArrayStart for details on usage. As an example of usage, let's say you want to write a map of records, the record consisting of an Long field and a Boolean field. Your code would look something like this:

out.WriteMapStart();
out.SetItemCount(dictionary.Count);
foreach (var entry in dictionary)
{
out.StartItem();
out.WriteString(entry.Key);
out.writeLong(entry.Value.LongField);
out.writeBoolean(entry.Value.BoolField);
}
out.WriteMapEnd();

Implements Avro.IO.Encoder.

◆ WriteNull()

void Avro.IO.ParsingEncoder.WriteNull ( )
abstract

Writes a null value.

Implements Avro.IO.Encoder.

◆ WriteString()

void Avro.IO.ParsingEncoder.WriteString ( string  value)
abstract

Writes an Unicode string.

Parameters
valueValue to write.

Implements Avro.IO.Encoder.

◆ WriteUnionIndex()

void Avro.IO.ParsingEncoder.WriteUnionIndex ( int  value)
abstract

Call this method to write the tag of a union. As an example of usage, let's say you want to write a union, whose second branch is a record consisting of an Long field and a Boolean field. Your code would look something like this:

out.WriteIndex(1);
out.WriteLong(record.LongField);
out.WriteBoolean(record.BoolField);

Implements Avro.IO.Encoder.


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