1 /* Invisible Vector Library
2 * coded by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
3 * Understanding is not required. Only obedience.
5 * This software is provided 'as-is', without any express or implied
6 * warranty. In no event will the authors be held liable for any damages
7 * arising from the use of this software.
8 * Permission is granted to anyone to use this software for any purpose,
9 * including commercial applications, and to alter it and redistribute it
10 * freely, subject to the following restrictions:
11 * 1. The origin of this software must not be misrepresented; you must not
12 * claim that you wrote the original software. If you use this software
13 * in a product, an acknowledgment in the product documentation would be
14 * appreciated but is not required.
15 * 2. Altered source versions must be plainly marked as such, and must not be
16 * misrepresented as being the original software.
17 * 3. This notice may not be removed or altered from any source distribution.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23 module saxytest
/*is aliced*/;
29 static if (is(typeof({import iv
.vfs
;}))) {
36 static if (is(typeof({import iv
.strex
;}))) {
39 private string
quote (const(char)[] s
) {
40 import std
.array
: appender
;
41 import std
.format
: formatElement
, FormatSpec
;
42 auto res
= appender
!string();
43 FormatSpec
!char fspc
; // defaults to 's'
44 formatElement(res
, s
, fspc
);
50 // ////////////////////////////////////////////////////////////////////////// //
51 char[] readFile (const(char)[] fname
) {
53 auto fl
= VFile(fname
);
54 auto res
= new char[](cast(int)fl
.size
);
55 fl
.rawReadExact(res
[]);
59 import std
.stdio
: File
;
60 auto fl
= File(fname
.to
!string
);
61 auto res
= new char[](cast(int)fl
.size
);
68 // ////////////////////////////////////////////////////////////////////////// //
69 void main (string
[] args
) {
72 string infilename
= (args
.length
> 1 ? args
[1] : "z00.xml");
76 auto inst
= VFile(infilename
);
78 auto inst
= File(infilename
);
81 auto inst
= readFile(infilename
).byChar
;
84 (char[] name
, char[][string
] attrs
) {
87 write("tag '", name
, "' opened");
90 foreach (const ref kv
; attrs
.byKeyValue
) {
91 write(' ', kv
.key
, "=", kv
.value
.quote
);
100 indent
.assumeSafeAppend
;
101 writeln(indent
, "tag '", name
, "' closed");
105 writeln(indent
, text
.length
, " bytes of content: ", text
.quote
);