egra: more strict checks before applying asm optimisations
[iv.d.git] / btenc_samples / bte_dump.d
blobbdd418f76ea39c96099f310a2a9422237097bd16
1 /* Invisible Vector Library
2 * coded by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
3 * Understanding is not required. Only obedience.
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3 of the License ONLY.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 module dump /*is aliced*/;
19 import iv.alice;
20 import iv.btenc;
23 void dump (ref BTField fld, string indent="") {
24 import iv.strex : quote;
25 import std.stdio : writeln;
26 if (fld.type == BTField.Type.UInt) {
27 writeln(indent, "uint:<", fld.vuint, ">");
28 } else if (fld.type == BTField.Type.Str) {
29 writeln(indent, "str:<#", fld.vstr.length, ":", quote(fld.vstr), ">");
30 } else if (fld.type == BTField.Type.List) {
31 writeln(indent, "LIST");
32 indent ~= " ";
33 string ii = indent~" ";
34 foreach (immutable idx; 0..fld.vlist.length) {
35 writeln(indent, "#", idx);
36 dump(fld.vlist[idx], ii);
38 } else if (fld.type == BTField.Type.Dict) {
39 writeln(indent, "DICT");
40 indent ~= " ";
41 string ii = indent~" ";
42 foreach (string k; fld.vdict.byKey) {
43 writeln(indent, "[#", k.length, ":", quote(k), "]");
44 dump(fld.vdict[k], ii);
46 } else {
47 assert(0);
52 void main (string[] args) {
53 if (args.length != 2) assert(0);
54 auto nfo = BTField.load(args[1]);
55 dump(nfo);