@@ -125,12 +125,6 @@ Distributed under the Boost Software License, Version 1.0.
125125*/
126126module std.xml ;
127127
128- import std.algorithm.searching : count, startsWith;
129- import std.array ;
130- import std.ascii ;
131- import std.string ;
132- import std.encoding ;
133-
134128enum cdata = " <![CDATA[" ;
135129
136130/**
@@ -351,6 +345,8 @@ bool isExtender(dchar c) @safe @nogc nothrow pure
351345 */
352346S encode (S)(S s)
353347{
348+ import std.array : appender;
349+
354350 string r;
355351 size_t lastI;
356352 auto result = appender! S();
@@ -436,6 +432,8 @@ enum DecodeMode
436432 */
437433string decode (string s, DecodeMode mode=DecodeMode.LOOSE ) @system pure
438434{
435+ import std.algorithm.searching : startsWith;
436+
439437 if (mode == DecodeMode.NONE ) return s;
440438
441439 char [] buffer;
@@ -922,6 +920,8 @@ class Element : Item
922920 */
923921 override string [] pretty (uint indent=2 )
924922 {
923+ import std.algorithm.searching : count;
924+ import std.string : rightJustify;
925925
926926 if (isEmptyXML) return [ tag.toEmptyString() ];
927927
@@ -1056,6 +1056,9 @@ class Tag
10561056 */
10571057 private this (ref string s, bool dummy) @system
10581058 {
1059+ import std.ascii : whitespace;
1060+ import std.string : munch;
1061+
10591062 // @system because of decode
10601063 tagString = s;
10611064 try
@@ -1166,6 +1169,8 @@ class Tag
11661169 {
11671170 string toNonEndString ()
11681171 {
1172+ import std.format : format;
1173+
11691174 string s = " <" ~ name;
11701175 foreach (key,val;attr)
11711176 s ~= format(" %s=\" %s\" " ,key,encode(val));
@@ -1235,6 +1240,8 @@ class Comment : Item
12351240 */
12361241 this (string content) @safe pure
12371242 {
1243+ import std.string : indexOf;
1244+
12381245 if (content == " -" || content.indexOf(" --" ) != - 1 )
12391246 throw new CommentException(content);
12401247 this .content = content;
@@ -1323,6 +1330,7 @@ class CData : Item
13231330 */
13241331 this (string content) @safe pure
13251332 {
1333+ import std.string : indexOf;
13261334 if (content.indexOf(" ]]>" ) != - 1 ) throw new CDataException(content);
13271335 this .content = content;
13281336 }
@@ -1482,6 +1490,7 @@ class XMLInstruction : Item
14821490 */
14831491 this (string content) @safe pure
14841492 {
1493+ import std.string : indexOf;
14851494 if (content.indexOf(" >" ) != - 1 ) throw new XIException(content);
14861495 this .content = content;
14871496 }
@@ -1561,6 +1570,7 @@ class ProcessingInstruction : Item
15611570 */
15621571 this (string content) @safe pure
15631572 {
1573+ import std.string : indexOf;
15641574 if (content.indexOf(" ?>" ) != - 1 ) throw new PIException(content);
15651575 this .content = content;
15661576 }
@@ -1642,6 +1652,7 @@ abstract class Item
16421652 */
16431653 string [] pretty (uint indent) const
16441654 {
1655+ import std.string : strip;
16451656 string s = strip(toString());
16461657 return s.length == 0 ? [] : [ s ];
16471658 }
@@ -1970,6 +1981,9 @@ class ElementParser
19701981 */
19711982 void parse ()
19721983 {
1984+ import std.algorithm.searching : startsWith;
1985+ import std.string : indexOf;
1986+
19731987 string t;
19741988 Tag root = tag_;
19751989 Tag[string ] startTags;
@@ -2128,6 +2142,8 @@ private
21282142
21292143 void checkMisc (ref string s) @safe pure // rule 27
21302144 {
2145+ import std.algorithm.searching : startsWith;
2146+
21312147 mixin Check! (" Misc" );
21322148
21332149 try
@@ -2155,6 +2171,7 @@ private
21552171 {
21562172 // TO DO - Fix std.utf stride and decode functions, then use those
21572173 // instead
2174+ import std.format : format;
21582175
21592176 mixin Check! (" Chars" );
21602177
@@ -2178,6 +2195,8 @@ private
21782195
21792196 void checkSpace (ref string s) @safe pure // rule 3
21802197 {
2198+ import std.string : munch;
2199+
21812200 mixin Check! (" Whitespace" );
21822201 munch(s," \u0020\u0009\u000A\u000D " );
21832202 if (s is old) fail();
@@ -2204,6 +2223,8 @@ private
22042223
22052224 void checkAttValue (ref string s) @safe pure // rule 10
22062225 {
2226+ import std.string : munch;
2227+
22072228 mixin Check! (" AttValue" );
22082229
22092230 if (s.length == 0 ) fail();
@@ -2224,6 +2245,8 @@ private
22242245
22252246 void checkCharData (ref string s) @safe pure // rule 14
22262247 {
2248+ import std.algorithm.searching : startsWith;
2249+
22272250 mixin Check! (" CharData" );
22282251
22292252 while (s.length != 0 )
@@ -2237,6 +2260,8 @@ private
22372260
22382261 void checkComment (ref string s) @safe pure // rule 15
22392262 {
2263+ import std.string : indexOf;
2264+
22402265 mixin Check! (" Comment" );
22412266
22422267 try { checkLiteral(" <!--" ,s); } catch (Err e) { fail(e); }
@@ -2332,6 +2357,8 @@ private
23322357
23332358 void checkVersionNum (ref string s) @safe pure // rule 26
23342359 {
2360+ import std.string : munch;
2361+
23352362 mixin Check! (" VersionNum" );
23362363
23372364 munch(s," a-zA-Z0-9_.:-" );
@@ -2356,6 +2383,8 @@ private
23562383
23572384 void checkSDDecl (ref string s) @safe pure // rule 32
23582385 {
2386+ import std.algorithm.searching : startsWith;
2387+
23592388 mixin Check! (" SDDecl" );
23602389
23612390 try
@@ -2452,6 +2481,8 @@ private
24522481
24532482 void checkContent (ref string s) @safe pure // rule 43
24542483 {
2484+ import std.algorithm.searching : startsWith;
2485+
24552486 mixin Check! (" Content" );
24562487
24572488 try
@@ -2473,6 +2504,8 @@ private
24732504
24742505 void checkCharRef (ref string s, out dchar c) @safe pure // rule 66
24752506 {
2507+ import std.format : format;
2508+
24762509 mixin Check! (" CharRef" );
24772510
24782511 c = 0 ;
@@ -2522,6 +2555,8 @@ private
25222555
25232556 void checkReference (ref string s) @safe pure // rule 67
25242557 {
2558+ import std.algorithm.searching : startsWith;
2559+
25252560 mixin Check! (" Reference" );
25262561
25272562 try
@@ -2549,6 +2584,8 @@ private
25492584
25502585 void checkEncName (ref string s) @safe pure // rule 81
25512586 {
2587+ import std.string : munch;
2588+
25522589 mixin Check! (" EncName" );
25532590
25542591 munch(s," a-zA-Z" );
@@ -2574,6 +2611,8 @@ private
25742611
25752612 void checkLiteral (string literal,ref string s) @safe pure
25762613 {
2614+ import std.string : startsWith;
2615+
25772616 mixin Check! (" Literal" );
25782617
25792618 if (! s.startsWith(literal)) fail(" Expected literal \" " ~ literal~ " \" " );
@@ -2582,6 +2621,7 @@ private
25822621
25832622 void checkEnd (string end,ref string s) @safe pure
25842623 {
2624+ import std.string : indexOf;
25852625 // Deliberately no mixin Check here.
25862626
25872627 auto n = s.indexOf(end);
@@ -2614,6 +2654,8 @@ private
26142654
26152655 void quoted (alias f)(ref string s)
26162656 {
2657+ import std.string : startsWith;
2658+
26172659 if (s.startsWith(" '" ))
26182660 {
26192661 checkLiteral(" '" ,s);
@@ -2664,6 +2706,8 @@ void check(string s) pure
26642706
26652707@system pure unittest
26662708{
2709+ import std.string : indexOf;
2710+
26672711 try
26682712 {
26692713 check(q" [<?xml version=" 1.0 " ?>
@@ -2837,6 +2881,9 @@ class CheckException : XMLException
28372881
28382882 private void complete (string entire) pure
28392883 {
2884+ import std.encoding : transcode;
2885+ import std.string : count, lastIndexOf;
2886+
28402887 string head = entire[0 .. $- tail.length];
28412888 ptrdiff_t n = head.lastIndexOf(' \n ' ) + 1 ;
28422889 line = head.count(" \n " ) + 1 ;
@@ -2848,6 +2895,8 @@ class CheckException : XMLException
28482895
28492896 override string toString () const @safe pure
28502897 {
2898+ import std.format : format;
2899+
28512900 string s;
28522901 if (line != 0 ) s = format(" Line %d, column %d: " ,line,column);
28532902 s ~= msg;
@@ -2897,6 +2946,8 @@ private
28972946
28982947 char requireOneOf (ref string s, string chars) @safe pure
28992948 {
2949+ import std.string : indexOf;
2950+
29002951 if (s.length == 0 || indexOf(chars,s[0 ]) == - 1 )
29012952 throw new TagException(" " );
29022953 char ch = s[0 ];
0 commit comments