Skip to content

Commit

Permalink
#861 Doc marshalling with type - reading back
Browse files Browse the repository at this point in the history
  • Loading branch information
zhabis committed May 11, 2023
1 parent 06f7385 commit dcd2e11
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/Azos/Serialization/Bix/BixContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ internal static BixContext ObtainDefault()

private bool m_Default;
private int m_Nesting;
private Atom m_Version;
private int m_Version;
private string m_TargetName = TargetedAttribute.ANY_TARGET;
private int m_MaxDepth = DEFAULT_MAX_DEPTH;
private bool m_HasHeader;
Expand Down Expand Up @@ -83,7 +83,7 @@ internal void DisposeDefault()
if (m_Default) Dispose();
}

public Atom Version { get => m_Version; set => m_Version = value; }
public int Version { get => m_Version; set => m_Version = value; }
public string TargetName { get => m_TargetName; set => m_TargetName = value.IsNullOrWhiteSpace() ? TargetedAttribute.ANY_TARGET : value; }
public int MaxDepth { get => m_MaxDepth; set => m_MaxDepth = value.KeepBetween(0, 1024); }
public bool HasHeader { get => m_HasHeader; set => m_HasHeader = value; }
Expand Down
15 changes: 10 additions & 5 deletions src/Azos/Serialization/Bix/Bixon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@ public static class Bixon
/// Structured data bix binary version tag. Serializer writes this as the first field of structured data stream.
/// Deserializer reads it and can adjust the reading format for backward compatibility
/// </summary>
public const byte VERSION = 1;
public const byte SUBVERSION = 1;

public const byte HEADER1 = 0xB1;
public const byte HEADER2 = 0xD1;

/// <summary>
/// Absolute limit on maximum number of map properties per level
/// </summary>
public const int MAX_MAP_PROPS = 512;
public const int MAX_MAP_PROPS = 2 * 1024;

/// <summary>
/// Absolute limit on maximum number of array elements
/// </summary>
public const int MAX_ARRAY_ELM = 4 * 1024;
public const int MAX_ARRAY_ELM = 64 * 1024;

// Null/NonNull map flags, also used as a stream alignment crosscheck code
private const byte SD_FMT_NULL = 0x55;
Expand Down Expand Up @@ -78,7 +78,11 @@ public static object ReadObject(BixReader reader)
{
Aver.AreEqual(HEADER1, reader.ReadByte(), "hdr1");
Aver.AreEqual(HEADER2, reader.ReadByte(), "hdr2");
var ver = reader.ReadByte();

var readVersion = reader.ReadInt();
Aver.IsTrue(Format.VERSION >= readVersion);

var ver = reader.ReadByte();//sub version of this
return readValue(reader, ver);
}

Expand Down Expand Up @@ -129,7 +133,8 @@ public static void WriteObject(BixWriter writer, object obj, JsonWritingOptions
{
writer.Write(HEADER1);
writer.Write(HEADER2);
writer.Write(VERSION);
writer.Write(Format.VERSION);
writer.Write(Bixon.SUBVERSION);
writeValue(writer, obj, jopt, null);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Azos/Serialization/Bix/format/Format.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static class Format
{
public static readonly UTF8Encoding ENCODING = new UTF8Encoding(false, false);

public static readonly Atom VERSION = Atom.Encode("2");
public const int VERSION = 2;

public const int MAX_BYTE_ARRAY_LEN = 128 * //mb
1024 * //kb
Expand Down

0 comments on commit dcd2e11

Please sign in to comment.