From 334bb9c301bb72d5331a2e9e067211c18e5f7c69 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 23 Jan 2017 17:17:47 -0500 Subject: templates --- src/sdp/ao_conf_make_meta_native.d | 50 ++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 15 deletions(-) (limited to 'src/sdp/ao_conf_make_meta_native.d') diff --git a/src/sdp/ao_conf_make_meta_native.d b/src/sdp/ao_conf_make_meta_native.d index d95a8dd..6fe38e9 100644 --- a/src/sdp/ao_conf_make_meta_native.d +++ b/src/sdp/ao_conf_make_meta_native.d @@ -17,12 +17,18 @@ template SiSUheaderExtractNative() { auto rgx = Rgx(); enum State { off, on } string hm, hs; - auto header_metadata_and_make_aa( - string header, - string[string][string] dochead_meta, - string[string][string] dochead_make + auto header_metadata_and_make_aa(H,Me,Ma)( + H header, + Me dochead_meta, + Ma dochead_make ) - in { } + in { + debug(asserts){ + static assert(is(typeof(header) == string)); + static assert(is(typeof(dochead_meta) == string[string][string])); + static assert(is(typeof(dochead_make) == string[string][string])); + } + } body { scope(exit) { destroy(header); @@ -203,12 +209,18 @@ template SiSUheaderExtractNative() { static assert(t.length==2); return t; } - private auto native_header_extract( - char[] line, - ref int[string] line_occur, - ref string[string] an_object, - ref int[string] type + private auto native_header_extract(L,Lo,O,T)( + L line, + ref Lo line_occur, + ref O an_object, + ref T type ) { + debug(asserts){ + static assert(is(typeof(line) == char[])); + static assert(is(typeof(line_occur) == int[string])); + static assert(is(typeof(an_object) == string[string])); + static assert(is(typeof(type) == int[string])); + } if (matchFirst(line, rgx.native_header_make)) { /+ matched header_make +/ debug(header1) { /+ writeln(line); +/ } type["header"] = State.on; @@ -241,11 +253,16 @@ template SiSUheaderExtractNative() { } return an_object; } - auto header_reset_states_common( - ref int[string] line_occur, - ref string[string] an_object, - ref int[string] type + auto header_reset_states_common(Lo,O,T)( + ref Lo line_occur, + ref O an_object, + ref T type ) { + debug(asserts){ + static assert(is(typeof(line_occur) == int[string])); + static assert(is(typeof(an_object) == string[string])); + static assert(is(typeof(type) == int[string])); + } line_occur["header_make"] = State.off; line_occur["header_meta"] = State.off; type["header"] = State.off; @@ -253,7 +270,10 @@ template SiSUheaderExtractNative() { an_object.remove("is"); an_object.remove("attrib"); } - private auto headerNativeToAA(in char[] src_header) { + private auto headerNativeToAA(Hn)(Hn src_header) { + debug(asserts){ + static assert(is(typeof(src_header) == char[])); + } auto type = flags_type_init; type = [ "header" : State.off, -- cgit v1.2.3