/// <summary> /// Reads the next <see cref="count"/> elements of an array and writes views to the given buffer. /// </summary> /// <param name="views">The buffer to write the views to.</param> /// <param name="count">The number of elements to read.</param> /// <returns>The number of elements read.</returns> public unsafe int ReadArrayElementBatch(SerializedValueView *views, int count) { if (!CheckArrayElement()) { return(0); } count = ReadInternalBatch(views, count, NodeType.Any, m_Parser.TokenParentIndex); return(count); }
unsafe int ReadInternalBatch(SerializedValueView *views, int count, NodeType type, int parent) { var index = 0; for (;;) { // Parse and tokenize the input stream. if (FillBuffers()) { // Remap the parent if the internal buffers have shifted. if (parent >= 0) { parent = m_Tokenizer.DiscardRemap[parent]; } } var parserStart = m_Parser.TokenNextIndex - 1; var writerStart = m_BinaryStream.TokenNextIndex - 1; var batchCount = m_Parser.StepBatch(count - index, type, parent); Write(m_Parser.TokenNextIndex - m_BinaryWriter.TokenNextIndex); for (var i = 0; i < batchCount; i++) { views[index + i] = m_BinaryWriter.GetView(GetViewIndex(m_Parser.Nodes[i], parserStart, writerStart)); } index += batchCount; if (m_Parser.NodeType == NodeType.None && !IsEmpty(m_Block)) { continue; } return(index); } }
private unsafe int ReadInternalBatch(SerializedValueView *views, int count, NodeType type, int parent) { var index = 0; for (;;) { if (FillBuffer()) { if (parent >= 0) { parent = m_Tokenizer.DiscardRemap[parent]; } } var parserStart = m_Parser.TokenNextIndex - 1; var writerStart = m_BinaryStream.TokenNextIndex - 1; var batchCount = m_Parser.StepBatch(count - index, type, parent); Write(m_Parser.TokenNextIndex - m_BinaryWriter.TokenNextIndex); for (var i = 0; i < batchCount; i++) { views[index + i] = m_BinaryWriter.GetView(GetViewIndex(m_Parser.Nodes[i], parserStart, writerStart)); } index += batchCount; if (m_Parser.NodeType == NodeType.None && m_Block != null) { continue; } return(index); } }