namespace UglyToad.PdfPig.Core { using System.IO; /// /// Handles writing specified data types to an output stream in a valid PDF compliant format. /// public static class WritingExtensions { /// /// Write the to the stream as a . /// public static void WriteUInt(this Stream stream, long value) => WriteUInt(stream, (uint)value); /// /// Write the to the stream as a . /// public static void WriteUInt(this Stream stream, uint value) { var buffer = new[] { (byte) (value >> 24), (byte) (value >> 16), (byte) (value >> 8), (byte) value }; stream.Write(buffer, 0, 4); } /// /// Write the to the stream as a . /// public static void WriteUShort(this Stream stream, int value) => WriteUShort(stream, (ushort)value); /// /// Write the to the stream as a . /// public static void WriteUShort(this Stream stream, ushort value) { var buffer = new[] { (byte) (value >> 8), (byte) value }; stream.Write(buffer, 0, 2); } /// /// Write the to the stream as a . /// public static void WriteShort(this Stream stream, ushort value) => WriteShort(stream, (short)value); /// /// Write the to the stream as a . /// public static void WriteShort(this Stream stream, short value) { var buffer = new[] { (byte) (value >> 8), (byte) value }; stream.Write(buffer, 0, 2); } } }