daily update on 20240508 by nitload youmu, partical added
This commit is contained in:
@@ -77,6 +77,14 @@ namespace StgSharp.Data
|
||||
}
|
||||
target = new BitArray(boolStream.ToArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serialize a <see cref="BitArray"/>, useful when writing
|
||||
/// a Huffman tree index dictionary to file.
|
||||
/// </summary>
|
||||
/// <param name="bits"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="Exception"></exception>
|
||||
public static byte[] Serialize(BitArray bits)
|
||||
{
|
||||
int size = (bits.Count / 4) + 1;
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace StgSharp.Data
|
||||
|
||||
public abstract class SSDSerializable
|
||||
{
|
||||
public abstract byte SSDTypeCode { get; }
|
||||
public abstract SerializableTypeCode SSDTypeCode { get; }
|
||||
|
||||
public abstract byte[] GetBytes();
|
||||
|
||||
@@ -18,39 +18,17 @@ namespace StgSharp.Data
|
||||
internal abstract void BuildFromByteStream(byte[] stream);
|
||||
}
|
||||
|
||||
public static class SerializableTypeCode
|
||||
public enum SerializableTypeCode:byte
|
||||
{
|
||||
public const byte IndexTable = 1;
|
||||
public const byte Image = 2;
|
||||
public const byte Audio = 3;
|
||||
public const byte Shader = 4;
|
||||
public const byte Text = 5;
|
||||
public const byte RawData = 6;
|
||||
public const byte VirtualFolder = 7;
|
||||
IndexTable = 1,
|
||||
PixelImage = 2,
|
||||
VectorImage = 3,
|
||||
Audio = 4,
|
||||
Shader = 5,
|
||||
Text = 6,
|
||||
RawData = 7,
|
||||
VirtualFolder = 8,
|
||||
|
||||
|
||||
public static string GetNameTail(byte typeCode)
|
||||
{
|
||||
switch (typeCode)
|
||||
{
|
||||
case IndexTable:
|
||||
return "_indexT";
|
||||
case Image:
|
||||
return "_img";
|
||||
case Audio:
|
||||
return "_wav";
|
||||
case Shader:
|
||||
return "_gls";
|
||||
case Text:
|
||||
return "_txt";
|
||||
case RawData:
|
||||
return "_raw";
|
||||
case VirtualFolder:
|
||||
return "_f";
|
||||
default:
|
||||
throw new ArgumentException("Unknown file type");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static partial class Serializer
|
||||
@@ -66,5 +44,30 @@ namespace StgSharp.Data
|
||||
serializableObject.BuildFromByteStream(stream);
|
||||
return serializableObject;
|
||||
}
|
||||
|
||||
public static string GetNameTail(SerializableTypeCode typeCode)
|
||||
{
|
||||
switch (typeCode)
|
||||
{
|
||||
case SerializableTypeCode.IndexTable:
|
||||
return "_idt";
|
||||
case SerializableTypeCode.PixelImage:
|
||||
return "_pim";
|
||||
case SerializableTypeCode.VectorImage:
|
||||
return "_vim";
|
||||
case SerializableTypeCode.Audio:
|
||||
return "_wav";
|
||||
case SerializableTypeCode.Shader:
|
||||
return "_gls";
|
||||
case SerializableTypeCode.Text:
|
||||
return "_txt";
|
||||
case SerializableTypeCode.RawData:
|
||||
return "_raw";
|
||||
case SerializableTypeCode.VirtualFolder:
|
||||
return "_fod";
|
||||
default:
|
||||
throw new ArgumentException("Unknown file type");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user