/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.IO;
namespace Avro.IO
{
///
/// Decoder is used to decode Avro data on a stream. There are methods to read the Avro types on the stream. There are also
/// methods to skip items, which are usually more efficient than reading, on the stream.
///
public interface Decoder
{
///
/// Reads a null Avro type.
///
void ReadNull();
///
/// Read a boolean Avro type
///
/// The boolean just read
bool ReadBoolean();
///
/// Reads an int Avro type.
///
/// The int just read
int ReadInt();
///
/// Reads a long Avro type.
///
/// The long just read
long ReadLong();
///
/// Reads a float Avro type
///
/// The float just read
float ReadFloat();
///
/// Reads a double Avro type
///
/// The double just read
double ReadDouble();
///
/// Reads the bytes Avro type
///
/// The bytes just read
byte[] ReadBytes();
///
/// Reads a string Avro type
///
/// The string just read
string ReadString();
///
/// Reads an enum AvroType
///
/// The enum just read
int ReadEnum();
///
/// Starts reading the array Avro type. This, together with ReadArrayNext() is used to read the
/// items from Avro array. This returns the number of entries in the initial chunk. After consuming
/// the chunk, the client should call ReadArrayNext() to get the number of entries in the next
/// chunk. The client should repeat the procedure until there are no more entries in the array.
///
/// for (int n = decoder.ReadArrayStart(); n > 0; n = decoder.ReadArrayNext())
/// {
/// // Read one array entry.
/// }
///
/// The number of entries in the initial chunk, 0 if the array is empty.
long ReadArrayStart();
///
/// See ReadArrayStart().
///
/// The number of array entries in the next chunk, 0 if there are no more entries.
long ReadArrayNext();
///
/// Starts reading the map Avro type. This, together with ReadMapNext() is used to read the
/// entries from Avro map. This returns the number of entries in the initial chunk. After consuming
/// the chunk, the client should call ReadMapNext() to get the number of entriess in the next
/// chunk. The client should repeat the procedure until there are no more entries in the array.
/// for (int n = decoder.ReadMapStart(); n > 0; n = decoder.ReadMapNext())
/// {
/// // Read one map entry.
/// }
///
/// The number of entries in the initial chunk, 0 if the map is empty.
long ReadMapStart();
///
/// See ReadMapStart().
///
/// The number of map entries in the next chunk, 0 if there are no more entries.
long ReadMapNext();
///
/// Reads the index, which determines the type in an union Avro type.
///
/// The index of the type within the union.
int ReadUnionIndex();
///
/// A convenience method for ReadFixed(buffer, 0, buffer.Length);
///
/// The buffer to read into.
void ReadFixed(byte[] buffer);
///
/// Read a Fixed Avro type of length.
///
/// Buffer to read into
/// Starting position of buffer to read into
/// Number of bytes to read
void ReadFixed(byte[] buffer, int start, int length);
///
/// Skips a null Avro type on the stream.
///
void SkipNull();
///
/// Skips a boolean Avro type on the stream.
///
void SkipBoolean();
///
/// Skips a int Avro type on the stream.
///
void SkipInt();
///
/// Skips a long Avro type on the stream.
///
void SkipLong();
///
/// Skips a float Avro type on the stream.
///
void SkipFloat();
///
/// Skips a double Avro type on the stream.
///
void SkipDouble();
///
/// Skips a bytes Avro type on the stream.
///
void SkipBytes();
///
/// Skips a string Avro type on the stream.
///
void SkipString();
void SkipEnum();
void SkipUnionIndex();
void SkipFixed(int len);
}
}