@@ -14,7 +14,6 @@ import std.algorithm;
14
14
import std.array ;
15
15
import std.ascii ;
16
16
import std.conv ;
17
- import std.encoding ;
18
17
import std.exception ;
19
18
import std.format ;
20
19
import std.range ;
@@ -23,7 +22,6 @@ import std.system;
23
22
import std.typecons ;
24
23
import std.utf ;
25
24
26
- import dyaml.encoding;
27
25
import dyaml.escapes;
28
26
import dyaml.event;
29
27
import dyaml.exception;
@@ -67,7 +65,7 @@ private alias isFlowIndicator = among!(',', '?', '[', ']', '{', '}');
67
65
private alias isSpace = among! (' \0 ' , ' \n ' , ' \r ' , ' \u0085 ' , ' \u2028 ' , ' \u2029 ' , ' ' , ' \t ' );
68
66
69
67
// Emits YAML events into a file/stream.
70
- struct Emitter (Range , CharType ) if (isOutputRange! (Range , CharType ))
68
+ struct Emitter (Range ) if (isOutputRange! (Range , char ))
71
69
{
72
70
private :
73
71
// /Default tag handle shortcuts and replacements.
@@ -222,20 +220,7 @@ struct Emitter(Range, CharType) if (isOutputRange!(Range, CharType))
222
220
// /Write a string to the file/stream.
223
221
void writeString (const scope char [] str) @safe
224
222
{
225
- static if (is (CharType == char ))
226
- {
227
- copy(str, stream_);
228
- }
229
- static if (is (CharType == wchar ))
230
- {
231
- const buffer = to! wstring (str);
232
- copy(buffer, stream_);
233
- }
234
- static if (is (CharType == dchar ))
235
- {
236
- const buffer = to! dstring (str);
237
- copy(buffer, stream_);
238
- }
223
+ copy(str, stream_);
239
224
}
240
225
241
226
// /In some cases, we wait for a few next events before emitting.
@@ -731,7 +716,7 @@ struct Emitter(Range, CharType) if (isOutputRange!(Range, CharType))
731
716
// {
732
717
// writeIndent();
733
718
// }
734
- auto writer = ScalarWriter! ( Range , CharType) (&this , analysis_.scalar,
719
+ auto writer = ScalarWriter! Range (&this , analysis_.scalar,
735
720
context_ != Context.mappingSimpleKey);
736
721
final switch (style_)
737
722
{
@@ -1172,14 +1157,9 @@ struct Emitter(Range, CharType) if (isOutputRange!(Range, CharType))
1172
1157
1173
1158
// Writers.
1174
1159
1175
- // /Start the YAML stream (write the unicode byte order mark ).
1160
+ // /Start the YAML stream (do nothing ).
1176
1161
void writeStreamStart () @safe
1177
1162
{
1178
- // Write BOM (except for UTF-8)
1179
- static if (is (CharType == wchar ) || is (CharType == dchar ))
1180
- {
1181
- stream_.put(cast (CharType)' \uFEFF ' );
1182
- }
1183
1163
}
1184
1164
1185
1165
// /End the YAML stream.
@@ -1274,7 +1254,7 @@ struct Emitter(Range, CharType) if (isOutputRange!(Range, CharType))
1274
1254
private :
1275
1255
1276
1256
// /RAII struct used to write out scalar values.
1277
- struct ScalarWriter (Range , CharType )
1257
+ struct ScalarWriter (Range )
1278
1258
{
1279
1259
invariant ()
1280
1260
{
@@ -1283,14 +1263,14 @@ struct ScalarWriter(Range, CharType)
1283
1263
}
1284
1264
1285
1265
private :
1286
- @disable int opCmp (ref Emitter! (Range , CharType ));
1287
- @disable bool opEquals (ref Emitter! (Range , CharType ));
1266
+ @disable int opCmp (ref Emitter! (Range ));
1267
+ @disable bool opEquals (ref Emitter! (Range ));
1288
1268
1289
1269
// /Used as "null" UTF-32 character.
1290
1270
static immutable dcharNone = dchar .max;
1291
1271
1292
1272
// /Emitter used to emit the scalar.
1293
- Emitter! ( Range , CharType) * emitter_;
1273
+ Emitter! Range * emitter_;
1294
1274
1295
1275
// /UTF-8 encoded text of the scalar to write.
1296
1276
string text_;
@@ -1311,7 +1291,7 @@ struct ScalarWriter(Range, CharType)
1311
1291
1312
1292
public :
1313
1293
// /Construct a ScalarWriter using emitter to output text.
1314
- this (Emitter! ( Range , CharType) * emitter, string text, const bool split = true ) @safe nothrow
1294
+ this (Emitter! Range * emitter, string text, const bool split = true ) @safe nothrow
1315
1295
{
1316
1296
emitter_ = emitter;
1317
1297
text_ = text;
@@ -1506,7 +1486,7 @@ struct ScalarWriter(Range, CharType)
1506
1486
// /Write text as plain scalar.
1507
1487
void writePlain () @safe
1508
1488
{
1509
- if (emitter_.context_ == Emitter! ( Range , CharType) .Context.root){emitter_.openEnded_ = true ;}
1489
+ if (emitter_.context_ == Emitter! Range .Context.root){emitter_.openEnded_ = true ;}
1510
1490
if (text_ == " " ){return ;}
1511
1491
if (! emitter_.whitespace_)
1512
1492
{
0 commit comments