A struct storing constructor parameters for MarkedYAMLException.

This commit is contained in:
Ferdinand Majerech 2014-07-23 18:16:05 +02:00
parent f5e027e9bb
commit ba5d5bb3da

View file

@ -59,7 +59,20 @@ struct Mark
static assert(Mark.sizeof == 4, "Unexpected Mark size"); static assert(Mark.sizeof == 4, "Unexpected Mark size");
package: 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 abstract class MarkedYAMLException : YAMLException
{ {
// Construct a MarkedYAMLException with specified context and problem. // Construct a MarkedYAMLException with specified context and problem.
@ -78,6 +91,12 @@ abstract class MarkedYAMLException : YAMLException
{ {
super(problem ~ '\n' ~ problemMark.toString(), file, line); 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. // Constructors of YAML exceptions are mostly the same, so we use a mixin.