/* Copyright 2010-2016 MongoDB Inc.
*
* Licensed 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;
namespace MongoDB.Bson.IO
{
///
/// Represents a BSON writer.
///
public interface IBsonWriter : IDisposable
{
// properties
///
/// Gets the current serialization depth.
///
int SerializationDepth { get; }
///
/// Gets the settings of the writer.
///
BsonWriterSettings Settings { get; }
// methods
///
/// Gets the current state of the writer.
///
BsonWriterState State { get; }
// methods
///
/// Closes the writer.
///
void Close();
///
/// Flushes any pending data to the output destination.
///
void Flush();
///
/// Pops the element name validator.
///
/// The popped element validator.
void PopElementNameValidator();
///
/// Pushes the element name validator.
///
/// The validator.
void PushElementNameValidator(IElementNameValidator validator);
///
/// Writes BSON binary data to the writer.
///
/// The binary data.
void WriteBinaryData(BsonBinaryData binaryData);
///
/// Writes a BSON Boolean to the writer.
///
/// The Boolean value.
void WriteBoolean(bool value);
///
/// Writes BSON binary data to the writer.
///
/// The bytes.
void WriteBytes(byte[] bytes);
///
/// Writes a BSON DateTime to the writer.
///
/// The number of milliseconds since the Unix epoch.
void WriteDateTime(long value);
///
/// Writes a BSON Decimal128 to the writer.
///
/// The value.
void WriteDecimal128(Decimal128 value);
///
/// Writes a BSON Double to the writer.
///
/// The Double value.
void WriteDouble(double value);
///
/// Writes the end of a BSON array to the writer.
///
void WriteEndArray();
///
/// Writes the end of a BSON document to the writer.
///
void WriteEndDocument();
///
/// Writes a BSON Int32 to the writer.
///
/// The Int32 value.
void WriteInt32(int value);
///
/// Writes a BSON Int64 to the writer.
///
/// The Int64 value.
void WriteInt64(long value);
///
/// Writes a BSON JavaScript to the writer.
///
/// The JavaScript code.
void WriteJavaScript(string code);
///
/// Writes a BSON JavaScript to the writer (call WriteStartDocument to start writing the scope).
///
/// The JavaScript code.
void WriteJavaScriptWithScope(string code);
///
/// Writes a BSON MaxKey to the writer.
///
void WriteMaxKey();
///
/// Writes a BSON MinKey to the writer.
///
void WriteMinKey();
///
/// Writes the name of an element to the writer.
///
/// The name of the element.
void WriteName(string name);
///
/// Writes a BSON null to the writer.
///
void WriteNull();
///
/// Writes a BSON ObjectId to the writer.
///
/// The ObjectId.
void WriteObjectId(ObjectId objectId);
///
/// Writes a raw BSON array.
///
/// The byte buffer containing the raw BSON array.
void WriteRawBsonArray(IByteBuffer slice);
///
/// Writes a raw BSON document.
///
/// The byte buffer containing the raw BSON document.
void WriteRawBsonDocument(IByteBuffer slice);
///
/// Writes a BSON regular expression to the writer.
///
/// A BsonRegularExpression.
void WriteRegularExpression(BsonRegularExpression regex);
///
/// Writes the start of a BSON array to the writer.
///
void WriteStartArray();
///
/// Writes the start of a BSON document to the writer.
///
void WriteStartDocument();
///
/// Writes a BSON String to the writer.
///
/// The String value.
void WriteString(string value);
///
/// Writes a BSON Symbol to the writer.
///
/// The symbol.
void WriteSymbol(string value);
///
/// Writes a BSON timestamp to the writer.
///
/// The combined timestamp/increment value.
void WriteTimestamp(long value);
///
/// Writes a BSON undefined to the writer.
///
void WriteUndefined();
}
}