/* 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; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MongoDB.Bson.IO { /// /// Represents a Stream has additional methods to suport reading and writing BSON values. /// public abstract class BsonStream : Stream { /// /// Reads a BSON CString from the stream. /// /// The encoding. /// A string. public abstract string ReadCString(UTF8Encoding encoding); /// /// Reads a BSON CString from the stream. /// /// An ArraySegment containing the CString bytes (without the null byte). public abstract ArraySegment ReadCStringBytes(); /// /// Reads a BSON Decimal128 from the stream. /// /// A . public abstract Decimal128 ReadDecimal128(); /// /// Reads a BSON double from the stream. /// /// A double. public abstract double ReadDouble(); /// /// Reads a 32-bit BSON integer from the stream. /// /// An int. public abstract int ReadInt32(); /// /// Reads a 64-bit BSON integer from the stream. /// /// A long. public abstract long ReadInt64(); /// /// Reads a BSON ObjectId from the stream. /// /// An ObjectId. public abstract ObjectId ReadObjectId(); /// /// Reads a raw length prefixed slice from the stream. /// /// A slice. public abstract IByteBuffer ReadSlice(); /// /// Reads a BSON string from the stream. /// /// The encoding. /// A string. public abstract string ReadString(UTF8Encoding encoding); /// /// Skips over a BSON CString leaving the stream positioned just after the terminating null byte. /// public abstract void SkipCString(); /// /// Writes a BSON CString to the stream. /// /// The value. public abstract void WriteCString(string value); /// /// Writes the CString bytes to the stream. /// /// The value. public abstract void WriteCStringBytes(byte[] value); /// /// Writes a BSON Decimal128 to the stream. /// /// The value. public abstract void WriteDecimal128(Decimal128 value); /// /// Writes a BSON double to the stream. /// /// The value. public abstract void WriteDouble(double value); /// /// Writes a 32-bit BSON integer to the stream. /// /// The value. public abstract void WriteInt32(int value); /// /// Writes a 64-bit BSON integer to the stream. /// /// The value. public abstract void WriteInt64(long value); /// /// Writes a BSON ObjectId to the stream. /// /// The value. public abstract void WriteObjectId(ObjectId value); /// /// Writes a BSON string to the stream. /// /// The value. /// The encoding. public abstract void WriteString(string value, UTF8Encoding encoding); } }