From 397ac65baa4e9024143d769a7eb952ab0d4c567e Mon Sep 17 00:00:00 2001 From: John-Colvin Date: Tue, 11 Dec 2012 15:32:25 +0000 Subject: [PATCH] modified: dyaml/exception.d modified: dyaml/representer.d --- dyaml/exception.d | 3 ++- dyaml/representer.d | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/dyaml/exception.d b/dyaml/exception.d index 2421ccf..3f2c4b9 100644 --- a/dyaml/exception.d +++ b/dyaml/exception.d @@ -11,6 +11,7 @@ module dyaml.exception; import std.algorithm; import std.array; import std.string; +import std.conv; ///Base class for all exceptions thrown by D:YAML. @@ -45,7 +46,7 @@ struct Mark string toString() const @trusted { //Line/column numbers start at zero internally, make them start at 1. - string clamped(ushort v){return format(v + 1, v == ushort.max ? " or higher" : "");} + string clamped(ushort v){return to!string(v + 1) ~ (v == ushort.max ? " or higher" : "");} return format("line ", clamped(line_), ",column ", clamped(column_)); } } diff --git a/dyaml/representer.d b/dyaml/representer.d index a3c242d..a785cb1 100644 --- a/dyaml/representer.d +++ b/dyaml/representer.d @@ -24,6 +24,7 @@ import std.format; import std.math; import std.stream; import std.typecons; +import std.string; import dyaml.exception; import dyaml.node; @@ -592,10 +593,9 @@ Node representPairs(ref Node node, Representer representer) @system } //Unittests +//These should really all be encapsulated in unittests. private: -import std.string; - import dyaml.dumper; struct MyStruct @@ -616,7 +616,7 @@ Node representMyStruct(ref Node node, Representer representer) @system //The node is guaranteed to be MyStruct as we add representer for MyStruct. auto value = node.as!MyStruct; //Using custom scalar format, x:y:z. - auto scalar = format(value.x, ":", value.y, ":", value.z); + auto scalar = format("%s:%s:%s", value.x, value.y, value.z); //Representing as a scalar, with custom tag to specify this data type. return representer.representScalar("!mystruct.tag", scalar); } @@ -671,7 +671,7 @@ Node representMyClass(ref Node node, Representer representer) @system //The node is guaranteed to be MyClass as we add representer for MyClass. auto value = node.as!MyClass; //Using custom scalar format, x:y:z. - auto scalar = format(value.x, ":", value.y, ":", value.z); + auto scalar = format("%s:%s:%s", value.x, value.y, value.z); //Representing as a scalar, with custom tag to specify this data type. return representer.representScalar("!myclass.tag", scalar); }