internal Enumerator(PackedBinaryStream stream, Handle start)
 {
     m_Stream  = stream;
     m_Start   = start;
     m_Current = new Handle {
         Index = -1, Version = -1
     };
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="SerializedObjectReader"/> class based on the specified input stream, output stream and configuration.
        /// </summary>
        /// <param name="input">The input stream.</param>
        /// <param name="output">The output stream.</param>
        /// <param name="configuration">The configuration parameters to use for the reader.</param>
        /// <param name="label">The memory allocator label to use.</param>
        /// <param name="leaveInputOpen">True to leave the input stream open after the reader object is disposed; otherwise, false.</param>
        /// <param name="leaveOutputOpen">True to leave the output stream open after the reader object is disposed; otherwise, false.</param>
        /// <exception cref="ArgumentException">The configuration is invalid.</exception>
        public SerializedObjectReader(Stream input, PackedBinaryStream output, SerializedObjectReaderConfiguration configuration, Allocator label = SerializationConfiguration.DefaultAllocatorLabel, bool leaveInputOpen = true, bool leaveOutputOpen = true)
        {
            if (configuration.BlockBufferSize < 16)
            {
                throw new ArgumentException("BlockBufferSize < 16");
            }

            if (configuration.TokenBufferSize < 16)
            {
                throw new ArgumentException("TokenBufferSize < 16");
            }

            m_LeaveOutputOpen = leaveOutputOpen;
            var blockBufferCharSize = configuration.BlockBufferSize / sizeof(char);

            m_StreamReader = new StreamReader(input, Encoding.UTF8, detectEncodingFromByteOrderMarks: true, bufferSize: configuration.BlockBufferSize, leaveInputOpen);
            m_BlockReader  = configuration.UseReadAsync ? new AsyncBlockReader(m_StreamReader, blockBufferCharSize) : (IBlockReader) new SyncBlockReader(m_StreamReader, blockBufferCharSize);
            m_Tokenizer    = new JsonTokenizer(configuration.TokenBufferSize, configuration.ValidationType, label);
            m_Parser       = new NodeParser(m_Tokenizer, configuration.NodeBufferSize, label);
            m_BinaryStream = output;
            m_BinaryWriter = new PackedBinaryWriter(m_BinaryStream, m_Tokenizer);
        }
Ejemplo n.º 3
0
 public PackedBinaryWriter(PackedBinaryStream stream, ITokenizer tokenizer)
 {
     m_Stream    = stream;
     m_Tokenizer = tokenizer;
     Seek(0, -1);
 }
 internal SerializedPrimitiveView(PackedBinaryStream stream, Handle handle)
 {
     m_Stream = stream;
     m_Handle = handle;
 }
 internal SerializedArrayView(PackedBinaryStream stream, Handle handle)
 {
     m_Stream = stream;
     m_Handle = handle;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SerializedObjectReader"/> class based on the specified input stream and output stream.
 /// </summary>
 /// <param name="input">The input stream.</param>
 /// <param name="output">The output stream.</param>
 /// <param name="label">The memory allocator label to use.</param>
 /// <param name="leaveInputOpen">True to leave the input stream open after the reader object is disposed; otherwise, false.</param>
 /// <param name="leaveOutputOpen">True to leave the output stream open after the reader object is disposed; otherwise, false.</param>
 public SerializedObjectReader(Stream input, PackedBinaryStream output, Allocator label = SerializationConfiguration.DefaultAllocatorLabel, bool leaveInputOpen = true, bool leaveOutputOpen = true)
     : this(input, output, SerializedObjectReaderConfiguration.Default, label, leaveInputOpen, leaveOutputOpen)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SerializedObjectReader"/> class with the specified path, output stream and configuration.
 /// </summary>
 /// <param name="path">A relative or absolute file path.</param>
 /// <param name="output">The output stream.</param>
 /// <param name="configuration">The configuration parameters to use for the reader.</param>
 /// <param name="label">The memory allocator label to use.</param>
 /// <param name="leaveOutputOpen">True to leave the output stream open after the reader object is disposed; otherwise, false.</param>
 public SerializedObjectReader(string path, PackedBinaryStream output, SerializedObjectReaderConfiguration configuration, Allocator label = SerializationConfiguration.DefaultAllocatorLabel, bool leaveOutputOpen = true)
     : this(OpenFileStreamWithConfiguration(path, configuration), output, configuration, label, false, leaveOutputOpen)
 {
 }