From ba5d5bb3dab51d413fe6013124006f50bb9af22f Mon Sep 17 00:00:00 2001 From: Ferdinand Majerech Date: Wed, 23 Jul 2014 18:16:05 +0200 Subject: [PATCH] A struct storing constructor parameters for MarkedYAMLException. --- source/dyaml/exception.d | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/source/dyaml/exception.d b/source/dyaml/exception.d index 3268abc..7a525ea 100644 --- a/source/dyaml/exception.d +++ b/source/dyaml/exception.d @@ -59,7 +59,20 @@ struct Mark static assert(Mark.sizeof == 4, "Unexpected Mark size"); package: -//Base class of YAML exceptions with marked positions of the problem. +// A struct storing parameters to the MarkedYAMLException constructor. +struct MarkedYAMLExceptionData +{ + // Context of the error. + string context; + // Position of the context in a YAML buffer. + Mark contextMark; + // The error itself. + string problem; + // Position if the error. + Mark problemMark; +} + +// Base class of YAML exceptions with marked positions of the problem. abstract class MarkedYAMLException : YAMLException { // Construct a MarkedYAMLException with specified context and problem. @@ -78,6 +91,12 @@ abstract class MarkedYAMLException : YAMLException { super(problem ~ '\n' ~ problemMark.toString(), file, line); } + + /// Construct a MarkedYAMLException from a struct storing constructor parameters. + this(ref const(MarkedYAMLExceptionData) data) @safe pure nothrow + { + with(data) this(context, contextMark, problem, problemMark); + } } // Constructors of YAML exceptions are mostly the same, so we use a mixin.