mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
* Dependencies update & cleanup Fixes security vuln warnings etc * Remove ILReader dependency RIP in piss FastAccessors.
84 lines
2.1 KiB
C#
84 lines
2.1 KiB
C#
using System;
|
|
using YamlDotNet.Core;
|
|
|
|
namespace Robust.Shared.Serialization.Markdown
|
|
{
|
|
public readonly struct NodeMark : IEquatable<NodeMark>, IComparable<NodeMark>
|
|
{
|
|
public static NodeMark Invalid => new(-1, -1);
|
|
|
|
public NodeMark(int line, int column)
|
|
{
|
|
Line = line;
|
|
Column = column;
|
|
}
|
|
|
|
// TODO: Make Line/Column longs
|
|
public NodeMark(Mark mark) : this((int)mark.Line, (int)mark.Column)
|
|
{
|
|
}
|
|
|
|
public int Line { get; init; }
|
|
|
|
public int Column { get; init; }
|
|
|
|
public override string ToString()
|
|
{
|
|
return $"Line: {Line}, Col: {Column}";
|
|
}
|
|
|
|
public bool Equals(NodeMark other)
|
|
{
|
|
return Line == other.Line && Column == other.Column;
|
|
}
|
|
|
|
public override bool Equals(object? obj)
|
|
{
|
|
return obj is NodeMark other && Equals(other);
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return HashCode.Combine(Line, Column);
|
|
}
|
|
|
|
public int CompareTo(NodeMark other)
|
|
{
|
|
var lineNum = Line.CompareTo(other.Line);
|
|
return lineNum == 0 ? Column.CompareTo(other.Column) : lineNum;
|
|
}
|
|
|
|
public static implicit operator NodeMark(Mark mark) => new(mark);
|
|
|
|
public static bool operator ==(NodeMark left, NodeMark right)
|
|
{
|
|
return left.Equals(right);
|
|
}
|
|
|
|
public static bool operator !=(NodeMark left, NodeMark right)
|
|
{
|
|
return !left.Equals(right);
|
|
}
|
|
|
|
public static bool operator <(NodeMark? left, NodeMark? right)
|
|
{
|
|
if (left == null || right == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return left.Value.CompareTo(right.Value) < 0;
|
|
}
|
|
|
|
public static bool operator >(NodeMark? left, NodeMark? right)
|
|
{
|
|
if (left == null || right == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return left.Value.CompareTo(right.Value) > 0;
|
|
}
|
|
}
|
|
}
|