Update ZNI Library
This commit is contained in:
parent
0638f7e642
commit
eeadcb1959
10 changed files with 753 additions and 388 deletions
|
@ -51,7 +51,7 @@ namespace LibZNI.Serialization.ZNIFile
|
|||
|
||||
public override void SkipTag(BinaryReader br)
|
||||
{
|
||||
_ = new BoolTag().ReadTag(br);
|
||||
_ = new ByteArrayTag().ReadTag(br);
|
||||
}
|
||||
|
||||
public override void WriteData(BinaryWriter bw)
|
||||
|
|
|
@ -182,6 +182,15 @@ namespace LibZNI.Serialization.ZNIFile
|
|||
case TagType.STRING:
|
||||
_next = new StringTag();
|
||||
break;
|
||||
case TagType.BYTEARRAY:
|
||||
_next = new ByteArrayTag();
|
||||
break;
|
||||
case TagType.INTARRAY:
|
||||
_next = new IntArrayTag();
|
||||
break;
|
||||
case TagType.LONGARRAY:
|
||||
_next = new LongArrayTag();
|
||||
break;
|
||||
case TagType.END:
|
||||
return true;
|
||||
}
|
||||
|
|
84
Serialization/ZNIFile/IntArrayTag.cs
Normal file
84
Serialization/ZNIFile/IntArrayTag.cs
Normal file
|
@ -0,0 +1,84 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LibZNI.Serialization.ZNIFile
|
||||
{
|
||||
public class IntArrayTag : Tag
|
||||
{
|
||||
private int[] BArrVal;
|
||||
public int[] Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return BArrVal;
|
||||
}
|
||||
}
|
||||
|
||||
public IntArrayTag(string _Name, int[] val)
|
||||
{
|
||||
Name = _Name;
|
||||
BArrVal = val;
|
||||
}
|
||||
public IntArrayTag(int[] boolVal) : this(null, boolVal)
|
||||
{
|
||||
}
|
||||
public IntArrayTag() : this(null, new int[] {}) { }
|
||||
|
||||
public override TagType Type
|
||||
{
|
||||
get
|
||||
{
|
||||
return TagType.INTARRAY;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool ReadTag(BinaryReader br)
|
||||
{
|
||||
Name = br.ReadString();
|
||||
int count = br.ReadInt32();
|
||||
BArrVal = new int[count];
|
||||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
BArrVal[i] = br.ReadInt32();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Rename(string old, string newName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void SkipTag(BinaryReader br)
|
||||
{
|
||||
_ = new IntArrayTag().ReadTag(br);
|
||||
}
|
||||
|
||||
public override void WriteData(BinaryWriter bw)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void WriteTag(BinaryWriter bw)
|
||||
{
|
||||
bw.Write(((int)Type));
|
||||
bw.Write(Name);
|
||||
bw.Write(Value.Length);
|
||||
|
||||
foreach(int i in Value)
|
||||
{
|
||||
bw.Write(i);
|
||||
}
|
||||
}
|
||||
|
||||
public override object Clone()
|
||||
{
|
||||
return new IntArrayTag(Name, Value);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -142,6 +142,15 @@ namespace LibZNI.Serialization.ZNIFile
|
|||
case TagType.STRING:
|
||||
_next = new StringTag();
|
||||
break;
|
||||
case TagType.BYTEARRAY:
|
||||
_next = new ByteArrayTag();
|
||||
break;
|
||||
case TagType.INTARRAY:
|
||||
_next = new IntArrayTag();
|
||||
break;
|
||||
case TagType.LONGARRAY:
|
||||
_next = new LongArrayTag();
|
||||
break;
|
||||
case TagType.END:
|
||||
return true;
|
||||
}
|
||||
|
|
84
Serialization/ZNIFile/LongArrayTag.cs
Normal file
84
Serialization/ZNIFile/LongArrayTag.cs
Normal file
|
@ -0,0 +1,84 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LibZNI.Serialization.ZNIFile
|
||||
{
|
||||
public class LongArrayTag : Tag
|
||||
{
|
||||
private long[] BArrVal;
|
||||
public long[] Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return BArrVal;
|
||||
}
|
||||
}
|
||||
|
||||
public LongArrayTag(string _Name, long[] val)
|
||||
{
|
||||
Name = _Name;
|
||||
BArrVal = val;
|
||||
}
|
||||
public LongArrayTag(long[] boolVal) : this(null, boolVal)
|
||||
{
|
||||
}
|
||||
public LongArrayTag() : this(null, new long[] {}) { }
|
||||
|
||||
public override TagType Type
|
||||
{
|
||||
get
|
||||
{
|
||||
return TagType.LONGARRAY;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool ReadTag(BinaryReader br)
|
||||
{
|
||||
Name = br.ReadString();
|
||||
int count = br.ReadInt32();
|
||||
BArrVal = new long[count];
|
||||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
BArrVal[i] = br.ReadInt64();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Rename(string old, string newName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void SkipTag(BinaryReader br)
|
||||
{
|
||||
_ = new LongArrayTag().ReadTag(br);
|
||||
}
|
||||
|
||||
public override void WriteData(BinaryWriter bw)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void WriteTag(BinaryWriter bw)
|
||||
{
|
||||
bw.Write(((int)Type));
|
||||
bw.Write(Name);
|
||||
bw.Write(Value.Length);
|
||||
|
||||
foreach(int i in Value)
|
||||
{
|
||||
bw.Write(i);
|
||||
}
|
||||
}
|
||||
|
||||
public override object Clone()
|
||||
{
|
||||
return new LongArrayTag(Name, Value);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -224,6 +224,32 @@ namespace LibZNI.Serialization.ZNIFile
|
|||
}
|
||||
}
|
||||
}
|
||||
public ulong uLongValue
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (Type)
|
||||
{
|
||||
case TagType.ULONG:
|
||||
return (this as uLongTag).Value;
|
||||
default:
|
||||
throw new Exception("Invalid type");
|
||||
}
|
||||
}
|
||||
}
|
||||
public Guid UUIDValue
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (Type)
|
||||
{
|
||||
case TagType.UUID:
|
||||
return (this as UUIDTag).Value;
|
||||
default:
|
||||
throw new Exception("Invalid type");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void Rename(string old, string newName);
|
||||
|
||||
|
|
|
@ -8,17 +8,21 @@ namespace LibZNI.Serialization.ZNIFile
|
|||
{
|
||||
public enum TagType
|
||||
{
|
||||
FOLDER = 0,
|
||||
STRING = 1,
|
||||
INTEGER = 2,
|
||||
LIST = 3, // List can be any valid Tag Type
|
||||
END = 4, // Present at the end of a folder or list
|
||||
BOOL = 5,
|
||||
FOLDER = 10,
|
||||
STRING = 8,
|
||||
INTEGER = 3,
|
||||
LIST = 9, // List can be any valid Tag Type
|
||||
END = 0, // Present at the end of a folder or list
|
||||
BOOL = 13,
|
||||
DOUBLE = 6,
|
||||
FLOAT = 7,
|
||||
LONG = 8,
|
||||
BYTE = 9,
|
||||
BYTEARRAY = 10,
|
||||
FLOAT = 5,
|
||||
LONG = 4,
|
||||
BYTE = 1,
|
||||
BYTEARRAY = 7,
|
||||
INTARRAY = 11,
|
||||
LONGARRAY=12,
|
||||
ULONG=14,
|
||||
UUID=15,
|
||||
|
||||
|
||||
|
||||
|
|
74
Serialization/ZNIFile/UUIDTag.cs
Normal file
74
Serialization/ZNIFile/UUIDTag.cs
Normal file
|
@ -0,0 +1,74 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LibZNI.Serialization.ZNIFile
|
||||
{
|
||||
public class UUIDTag : Tag
|
||||
{
|
||||
private Guid LongVal;
|
||||
public Guid Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return LongVal;
|
||||
}
|
||||
}
|
||||
|
||||
public UUIDTag(string _Name, Guid val)
|
||||
{
|
||||
Name = _Name;
|
||||
LongVal = val;
|
||||
}
|
||||
public UUIDTag(Guid _LongVal) : this(null, _LongVal)
|
||||
{
|
||||
}
|
||||
public UUIDTag() : this(null, Guid.Empty) { }
|
||||
|
||||
public override TagType Type
|
||||
{
|
||||
get
|
||||
{
|
||||
return TagType.UUID;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool ReadTag(BinaryReader br)
|
||||
{
|
||||
Name = br.ReadString();
|
||||
LongVal = Guid.Parse(br.ReadString());
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Rename(string old, string newName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void SkipTag(BinaryReader br)
|
||||
{
|
||||
_ = new UUIDTag().ReadTag(br);
|
||||
}
|
||||
|
||||
public override void WriteData(BinaryWriter bw)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void WriteTag(BinaryWriter bw)
|
||||
{
|
||||
bw.Write(((int)Type));
|
||||
bw.Write(Name);
|
||||
|
||||
bw.Write(Value.ToString());
|
||||
}
|
||||
|
||||
public override object Clone()
|
||||
{
|
||||
return new UUIDTag(Name, Value);
|
||||
}
|
||||
}
|
||||
}
|
74
Serialization/ZNIFile/ulongTag.cs
Normal file
74
Serialization/ZNIFile/ulongTag.cs
Normal file
|
@ -0,0 +1,74 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LibZNI.Serialization.ZNIFile
|
||||
{
|
||||
public class uLongTag : Tag
|
||||
{
|
||||
private ulong LongVal;
|
||||
public ulong Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return LongVal;
|
||||
}
|
||||
}
|
||||
|
||||
public uLongTag(string _Name, ulong val)
|
||||
{
|
||||
Name = _Name;
|
||||
LongVal = val;
|
||||
}
|
||||
public uLongTag(ulong _LongVal) : this(null, _LongVal)
|
||||
{
|
||||
}
|
||||
public uLongTag() : this(null, 0) { }
|
||||
|
||||
public override TagType Type
|
||||
{
|
||||
get
|
||||
{
|
||||
return TagType.ULONG;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool ReadTag(BinaryReader br)
|
||||
{
|
||||
Name = br.ReadString();
|
||||
LongVal = br.ReadUInt64();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Rename(string old, string newName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void SkipTag(BinaryReader br)
|
||||
{
|
||||
_ = new uLongTag().ReadTag(br);
|
||||
}
|
||||
|
||||
public override void WriteData(BinaryWriter bw)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void WriteTag(BinaryWriter bw)
|
||||
{
|
||||
bw.Write(((int)Type));
|
||||
bw.Write(Name);
|
||||
|
||||
bw.Write(Value);
|
||||
}
|
||||
|
||||
public override object Clone()
|
||||
{
|
||||
return new uLongTag(Name, Value);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue