From c9ad56dacc24ac9a1cd24aab8b0a688c4e28db83 Mon Sep 17 00:00:00 2001 From: Tomoya Tanjo Date: Tue, 3 Nov 2020 10:01:13 +0000 Subject: [PATCH] Add Node.startMark --- source/dyaml/exception.d | 16 ++++++++++++++-- source/dyaml/node.d | 6 ++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/source/dyaml/exception.d b/source/dyaml/exception.d index 7a8c426..7e05b96 100644 --- a/source/dyaml/exception.d +++ b/source/dyaml/exception.d @@ -25,8 +25,7 @@ class YAMLException : Exception } } -package: -// Position in a YAML stream, used for error messages. +/// Position in a YAML stream, used for error messages. struct Mark { package: @@ -45,6 +44,18 @@ struct Mark column_ = cast(ushort)column; } + /// Get a line number. + @property ushort line() @safe pure nothrow @nogc const + { + return line_; + } + + /// Get a column number. + @property ushort column() @safe pure nothrow @nogc const + { + return column_; + } + /// Get a string representation of the mark. string toString() @safe pure nothrow const { @@ -57,6 +68,7 @@ struct Mark } } +package: // A struct storing parameters to the MarkedYAMLException constructor. struct MarkedYAMLExceptionData { diff --git a/source/dyaml/node.d b/source/dyaml/node.d index 5a74a13..24a62a4 100644 --- a/source/dyaml/node.d +++ b/source/dyaml/node.d @@ -402,6 +402,12 @@ struct Node return tag_; } + /// Return the start position of the node. + @property Mark startMark() const @safe pure nothrow + { + return startMark_; + } + /** Equality test. * * If T is Node, recursively compares all subnodes.