Skip to content

Commit

Permalink
Add KVFile as a root type
Browse files Browse the repository at this point in the history
  • Loading branch information
xPaw committed Feb 11, 2024
1 parent f2b7166 commit 7eb8994
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
19 changes: 18 additions & 1 deletion ValveKeyValue/ValveKeyValue.Test/Test Data/apisurface.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ public class ValveKeyValue.KeyValueException
public string ToString();
}

public class ValveKeyValue.KVFile
{
public void Add(ValveKeyValue.KVObject value);
public bool Equals(object obj);
protected void Finalize();
public System.Collections.Generic.IEnumerable`1[[ValveKeyValue.KVObject]] get_Children();
public ValveKeyValue.KVValue get_Item(string key);
public string get_Name();
public ValveKeyValue.KVValue get_Value();
public System.Collections.Generic.IEnumerator`1[[ValveKeyValue.KVObject]] GetEnumerator();
public int GetHashCode();
public Type GetType();
protected object MemberwiseClone();
public void set_Item(string key, ValveKeyValue.KVValue value);
public string ToString();
}

public sealed class ValveKeyValue.KVIgnoreAttribute
{
public bool Equals(object obj);
Expand Down Expand Up @@ -95,7 +112,7 @@ public sealed enum ValveKeyValue.KVSerializationFormat
public class ValveKeyValue.KVSerializer
{
public static ValveKeyValue.KVSerializer Create(ValveKeyValue.KVSerializationFormat format);
public ValveKeyValue.KVObject Deserialize(System.IO.Stream stream, ValveKeyValue.KVSerializerOptions options);
public ValveKeyValue.KVFile Deserialize(System.IO.Stream stream, ValveKeyValue.KVSerializerOptions options);
public ValveKeyValue.TObject Deserialize<ValveKeyValue.TObject>(System.IO.Stream stream, ValveKeyValue.KVSerializerOptions options);
public bool Equals(object obj);
protected void Finalize();
Expand Down
10 changes: 10 additions & 0 deletions ValveKeyValue/ValveKeyValue/KVFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace ValveKeyValue
{
public class KVFile : KVObject
{
public KVFile(string name, KVValue value) : base(name, value)
{
// KV3 will require a header field that contains format/encoding here.
}
}
}
7 changes: 4 additions & 3 deletions ValveKeyValue/ValveKeyValue/KVSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public static KVSerializer Create(KVSerializationFormat format)
/// </summary>
/// <param name="stream">The stream to deserialize from.</param>
/// <param name="options">Options to use that can influence the deserialization process.</param>
/// <returns>A <see cref="KVObject"/> representing the KeyValues structure encoded in the stream.</returns>
public KVObject Deserialize(Stream stream, KVSerializerOptions options = null)
/// <returns>A <see cref="KVFile"/> representing the KeyValues structure encoded in the stream.</returns>
public KVFile Deserialize(Stream stream, KVSerializerOptions options = null)
{
Require.NotNull(stream, nameof(stream));
var builder = new KVObjectBuilder();
Expand All @@ -41,7 +41,8 @@ public KVObject Deserialize(Stream stream, KVSerializerOptions options = null)
reader.ReadObject();
}

return builder.GetObject();
var root = builder.GetObject();
return new KVFile(root.Name, root.Value);
}

/// <summary>
Expand Down

0 comments on commit 7eb8994

Please sign in to comment.