Exemplo n.º 1
0
			public InvalidVersion(IO.ITagStream tag, int expected, int expected_size, int got, int got_size) : base()
			{
				Debug.LogFile.WriteLine("Invalid versioning: expected {0} (0x{1}) but got {2} (0x{3})" + Program.NewLine +
					"\tIn {4}",
					expected.ToString(), expected_size.ToString("X4"), got.ToString(), got_size.ToString("X4"),
					tag.GetExceptionDescription());
			}
Exemplo n.º 2
0
			public InvalidVersion(IO.ITagStream tag, int expected, int got) : base()
			{
				Debug.LogFile.WriteLine("Invalid versioning: expected {0} but got {1}" + Program.NewLine +
					"\tIn {2}",
					expected.ToString(), got.ToString(),
					tag.GetExceptionDescription());
			}
Exemplo n.º 3
0
			public InvalidVersion(IO.ITagStream tag, string msg)
			{
				Debug.LogFile.WriteLine("Invalid versioning ({0})" + Program.NewLine +
					"\tIn {1}",
					msg,
					tag.GetExceptionDescription());
			}
Exemplo n.º 4
0
			/// <summary>
			/// Raise an exception for an invalid <c>string_id</c> field in a stream
			/// </summary>
			/// <param name="inner"></param>
			/// <param name="offset_field">Offset of the <c>string_id</c> field</param>
			/// <param name="offset_data">Offset of the <c>string_id</c> data</param>
			/// <param name="tag">Tag which this <c>string_id</c> ultimately belongs to</param>
			/// <param name="length">Expected length of the <c>string_id</c></param>
			/// <param name="value">String read from the stream as the <c>string_id</c>'s value. Can be null.</param>
			public InvalidStringId(
				Exception inner, 
				uint offset_field, uint offset_data, 
				IO.ITagStream tag,
				int length, string value) : base(inner, "Invalid String Id")
			{
				Debug.LogFile.WriteLine(
					"Invalid string_id: field@{0:X8}\tdata@{1:X8}\tlength:{2:X2}\tvalue:{3}" + Program.NewLine +
					"\tIn {4}",
					offset_field, offset_data, 
					length, value != null ? value : "UNKNOWN",
					tag.GetExceptionDescription());
			}
Exemplo n.º 5
0
			void VerifyHeaderVersionIds(IO.ITagStream ts, Type type_of)
			{
				if ((header.Index != state.Attribute.Version || header.Size != state.Attribute.SizeOf) &&
					 state.VersionIsValid(header.Index, header.Size))
				{
					needsUpgrading = true;
				}
				else
				{
					if (header.Index != state.Attribute.Version)
					{
						if (header.Index > state.Attribute.Version)
							failureReason = VersioningFailureReason.VersionIdIsNewer;
						else
							failureReason = VersioningFailureReason.VersionIdNotSupported;

						Debug.LogFile.WriteLine("{5} field set version mismatch\t@{0:X8} [{1} !{2}] in {3}\t {4}",
							relativeOffset, state.Attribute.Version, header.Index,
							type_of, ts.GetExceptionDescription(),
							GetTypeString());
						throw new Exceptions.InvalidVersion(ts, state.Attribute.Version, header.Index);
					}

					int expected_size;
					if (!state.VersioningSizeIsValid(header, ts.Flags, out expected_size))
					{
						if (state.VersioningCanBeImplicitlyPerformed(header, ts.Flags))
						{
							needsUpgrading = true;
							useImplicitUpgrading = true;
						}
						else
						{
							failureReason = VersioningFailureReason.VersionIdMismatch;

							Debug.LogFile.WriteLine("{5} field set sizeof mismatch \t@{0:X8} [{1} !{2}] in {3}\t {4}",
								relativeOffset, expected_size, header.Size,
								type_of, ts.GetExceptionDescription(),
								GetTypeString());
							throw new Exceptions.InvalidVersion(ts, state.Attribute.Version, expected_size, header.Index, header.Size);
						}
					}
				}
			}
Exemplo n.º 6
0
			void VerifyHeaderCount(IO.ITagStream ts, Type type_of)
			{
				if (header.Count != expectedCount)
				{
					failureReason = VersioningFailureReason.CountMismatch;

					throw new Debug.ExceptionLog("{5} field set count mismatch \t@{0:X8} [{1} !{2}] in {3}\t {4}",
						relativeOffset, expectedCount, header.Count,
						type_of, ts.GetExceptionDescription(),
						GetTypeString());
				}
			}
Exemplo n.º 7
0
			void VerifyHeaderGroupTag(IO.ITagStream ts, Type type_of)
			{
				if (header.GroupTag != headerGroupTag.ID)
				{
					if(type == FieldType.Struct)
					{
						var groups = ts.Engine.VersionToStructCollection();
						int index = groups.FindGroupIndex(header.GroupTag);

						if(index == -1)
						{
							failureReason = VersioningFailureReason.GroupTagNotFound;

							Debug.LogFile.WriteLine("{5} field set signature failed (signature not found) \t@{0:X8} [{1} !{2}] in {3}\t {4}",
								relativeOffset, headerGroupTag.TagToString(), new string(TagGroup.FromUInt(header.GroupTag)),
								type_of, ts.GetExceptionDescription(),
								GetTypeString());
							throw new Exceptions.InvalidVersion(ts);
						}
					}

					failureReason = VersioningFailureReason.GroupTagMismatch;

					Debug.LogFile.WriteLine("{5} field set signature failed\t@{0:X8} [{1} !{2}] in {3}\t {4}",
						relativeOffset,
						headerGroupTag.TagToString(), new string(TagGroup.FromUInt(header.GroupTag)),
						type_of, ts.GetExceptionDescription(),
						GetTypeString());
					throw new Exceptions.InvalidVersion(ts);
				}
			}
Exemplo n.º 8
0
			/// <summary>
			/// Raise an exception for an invalid <c>tag_reference</c> field in a stream
			/// </summary>
			/// <param name="inner"></param>
			/// <param name="offset_field">Offset of the <c>tag_reference</c> field</param>
			/// <param name="offset_data">Offset of the <c>tag_reference</c> data (ie, tag name)</param>
			/// <param name="owner">Owner of the <see cref="TagReference"/> field. Can be null.</param>
			/// <param name="tag">Tag which this <c>tag_reference</c> ultimately belongs to</param>
			/// <param name="group_tag"><c>tag_reference</c>'s group tag</param>
			/// <param name="value"><c>tag_reference</c>'s tag name data. Can be null.</param>
			public InvalidTagReference(
				Exception inner, 
				uint offset_field, uint offset_data, 
				IStructureOwner owner, IO.ITagStream tag, 
				uint group_tag, string value) : base(inner, "Invalid Tag Reference")
			{
				Debug.LogFile.WriteLine(
					"Invalid tag_reference: field@{0:X8}\tdata@{1:X8}\tgroup={2,4}\tpath={3}" + Program.NewLine +
					"\tIn {4} in {5}",
					offset_field, offset_data, 
					group_tag, value != null ? value : "UNKNOWN",
					tag.GetExceptionDescription(), 
					owner != null ? owner.GetType().FullName : "UNKNOWN");
			}
Exemplo n.º 9
0
			/// <summary>
			/// Raise an exception for an invalid data reference field in a stream
			/// </summary>
			/// <param name="inner"></param>
			/// <param name="offset_field">Offset of the data reference field</param>
			/// <param name="offset_data">Offset of the data reference data</param>
			/// <param name="owner">Owner of the <see cref="StructReference{T}"/> field. Can be null.</param>
			/// <param name="tag">Tag which this data reference ultimately belongs to</param>
			public InvalidStructReference(
				Exception inner, 
				uint offset_field, uint offset_data, 
				IStructureOwner owner, IO.ITagStream tag
				) : base(inner, "Invalid Data Reference")
			{
				Debug.LogFile.WriteLine(
					"Invalid data reference: field@{0:X8}\tdata@{1:X8}" + Program.NewLine +
					"\tIn {2} in {3}",
					offset_field, offset_data,
					tag.GetExceptionDescription(),
					owner != null ? owner.GetType().FullName : "UNKNOWN");
			}
Exemplo n.º 10
0
			/// <summary>
			/// Raise an exception for an invalid inline struct field in a stream
			/// </summary>
			/// <param name="inner"></param>
			/// <param name="offset_data">Offset of the inline struct data</param>
			/// <param name="owner">Owner of the <see cref="Struct{T}"/> field. Can be null.</param>
			/// <param name="tag">Tag which this inline struct ultimately belongs to</param>
			public InvalidTagStruct(
				Exception inner, 
				uint offset_data,
				IStructureOwner owner, IO.ITagStream tag
				) : base(inner, "Invalid Tag Struct")
			{
				Debug.LogFile.WriteLine(
					"Invalid inline struct: data@{0:X8}" + Program.NewLine +
					"\tIn {1} in {2}",
					offset_data,
					tag.GetExceptionDescription(),
					owner != null ? owner.GetType().FullName : "UNKNOWN");
			}