// Copyright (c) Dr. Dirk Lellinger. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.Text;
using SlobViewer.Common;
namespace SlobViewer.Slob
{
///
/// Part of a . A holds multiple dictionary values. After reading the SLOB file,
/// the content is stored in compressed form. If the contents is accessed, it is decompressed.
///
public class StoreItemInMemory : StoreItemBase
{
///
/// Initializes a new instance of the class.
///
/// The array of content IDs.
/// Compressed content as retrieved from the SLOB file.
public StoreItemInMemory(byte[] contentIds, byte[] compressedContent)
{
_contentIds = contentIds;
_compressedContent = compressedContent;
}
///
/// Get the content item with index .
///
/// The index.
/// A tuple, consisting of the content and content id at index .
public (string Content, int ContentId) GetAt(int idx, Encoding encoding, string compression, byte[] buffer)
{
if (null != _compressedContent)
{
DecompressContent(encoding, compression, buffer);
_compressedContent = null;
}
return (_content[idx], _contentIds[idx]);
}
}
}