aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sisudoc
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2024-06-29 14:02:54 -0400
committerRalph Amissah <ralph.amissah@gmail.com>2024-06-29 15:39:08 -0400
commit83b2933d683959afccfc6ba695ebc62a3e2a07c2 (patch)
treef468a35125e8f668b0c0d0d761c5d908afd75c12 /src/sisudoc
parentdocument digests and reduction in use of tuples (diff)
reduction in use of tuples
Diffstat (limited to 'src/sisudoc')
-rw-r--r--src/sisudoc/io_in/read_source_files.d137
1 files changed, 70 insertions, 67 deletions
diff --git a/src/sisudoc/io_in/read_source_files.d b/src/sisudoc/io_in/read_source_files.d
index 8d814fc..34ec9a9 100644
--- a/src/sisudoc/io_in/read_source_files.d
+++ b/src/sisudoc/io_in/read_source_files.d
@@ -68,14 +68,6 @@ template spineRawMarkupContent() {
static auto rgx = RgxI();
mixin spineRgxFiles;
static auto rgx_files = RgxFiles();
- struct ST_doc_parts {
- char[] header_raw;
- char[][] sourcefile_body_content;
- string[] insert_file_list;
- string[] images_list;
- ubyte[32] header_raw_digest;
- ubyte[32] src_txt_digest;
- }
string[] _images=[];
string[] _extract_images(S)(S content_block) {
string[] images_;
@@ -86,23 +78,31 @@ template spineRawMarkupContent() {
return images_;
}
auto rawsrc = RawMarkupContent();
- alias ContentsInsertsImages = Tuple!(
- char[][], "contents",
- string[], "insert_files",
- string[], "images"
- );
- alias HeaderContentInsertsImages = Tuple!(
- char[], "header",
- char[][], "src_txt",
- string[], "insert_files",
- string[], "images",
- ubyte[32], "header_digest",
- ubyte[32], "src_txt_digest"
- );
+ struct ST_contents_inserts_images {
+ char[][] contents;
+ string[] insert_files;
+ string[] images;
+ }
+ struct ST_header_content_inserts_images {
+ char[] header;
+ char[][] src_txt;
+ string[] insert_files;
+ string[] images;
+ ubyte[32] header_digest;
+ ubyte[32] src_txt_digest;
+ }
+ struct ST_doc_parts {
+ char[] header_raw;
+ char[][] sourcefile_body_content;
+ string[] insert_file_list;
+ string[] images_list;
+ ubyte[32] header_raw_digest;
+ ubyte[32] src_txt_digest;
+ }
auto spineRawMarkupContent(O,Fn)(O _opt_action, Fn fn_src) {
- auto _0_header_1_body_content_2_insert_filelist_tuple
+ ST_doc_parts _0_header_1_body_content_2_insert_filelist_struct
= rawsrc.sourceContentSplitIntoHeaderAndBody(_opt_action, rawsrc.sourceContent(fn_src), fn_src);
- return _0_header_1_body_content_2_insert_filelist_tuple;
+ return _0_header_1_body_content_2_insert_filelist_struct;
}
struct RawMarkupContent {
final sourceContent(in string fn_src) {
@@ -119,33 +119,33 @@ template spineRawMarkupContent() {
auto raw = MarkupRawUnit();
string[] insert_file_list_get;
string[] images_list_get;
- HeaderContentInsertsImages t
- = raw.markupSourceHeaderContentRawLineTupleArray(source_txt_str);
- char[] header_raw = t.header;
- ubyte[32] header_raw_digest = t.header.sha256Of;
- char[][] sourcefile_body_content = t.src_txt;
+ ST_header_content_inserts_images st
+ = raw.markupSourceHeaderContentRawLineStructArray(source_txt_str);
+ char[] header_raw = st.header;
+ ubyte[32] header_raw_digest = st.header.sha256Of;
+ char[][] sourcefile_body_content = st.src_txt;
if (fn_src.match(rgx_files.src_fn_master)) { // filename with path needed if master file (.ssm) not otherwise
auto ins = Inserts();
- ContentsInsertsImages tu
+ ST_contents_inserts_images _cii
= ins.scan_master_src_for_insert_files_and_import_content(_opt_action, sourcefile_body_content, fn_src);
- sourcefile_body_content = tu.contents;
- insert_file_list_get = tu.insert_files.dup;
- images_list_get = tu.images.dup;
+ sourcefile_body_content = _cii.contents;
+ insert_file_list_get = _cii.insert_files.dup;
+ images_list_get = _cii.images.dup;
} else if (_opt_action.source || _opt_action.pod) {
auto ins = Inserts();
- ContentsInsertsImages tu
+ ST_contents_inserts_images _cii
= ins.scan_master_src_for_insert_files_and_import_content(_opt_action, sourcefile_body_content, fn_src);
- images_list_get = tu.images.dup;
- }
+ images_list_get = _cii.images.dup;
+ } // image_list, if path could take sha256 digests already here?
ubyte[32] src_txt_digest = sourcefile_body_content.sha256Of;
string header_type = "";
ST_doc_parts ret;
{
- ret.header_raw = t.header;
+ ret.header_raw = st.header;
ret.sourcefile_body_content = sourcefile_body_content;
ret.insert_file_list = insert_file_list_get;
ret.images_list = images_list_get;
- ret.header_raw_digest = t.header.sha256Of;
+ ret.header_raw_digest = st.header.sha256Of;
ret.src_txt_digest = sourcefile_body_content.sha256Of;
}
return ret;
@@ -206,7 +206,7 @@ template spineRawMarkupContent() {
string source_txt_str = readInMarkupSource(fn_src);
return source_txt_str;
}
- HeaderContentInsertsImages markupSourceHeaderContentRawLineTupleArray(in string source_txt_str) {
+ ST_header_content_inserts_images markupSourceHeaderContentRawLineStructArray(in string source_txt_str) {
string[] file_insert_list = [];
string[] images_list = [];
char[][] hc = header0Content1(source_txt_str);
@@ -215,15 +215,16 @@ template spineRawMarkupContent() {
char[][] source_line_arr = markupSourceLineArray(source_txt);
ubyte[32] header_digest;
ubyte[32] src_txt_digest;
- HeaderContentInsertsImages t = tuple(
- header,
- source_line_arr,
- file_insert_list,
- images_list,
- header_digest,
- src_txt_digest
- );
- return t;
+ ST_header_content_inserts_images ret;
+ {
+ ret.header = header;
+ ret.src_txt = source_line_arr;
+ ret.insert_files = file_insert_list;
+ ret.images = images_list;
+ ret.header_digest = header_digest;
+ ret.src_txt_digest = src_txt_digest;
+ }
+ return ret;
}
final char[][] getInsertMarkupSourceContentRawLineArray(
in char[] fn_src_insert,
@@ -240,11 +241,11 @@ template spineRawMarkupContent() {
}
}
struct Inserts {
- alias ContentsAndImages = Tuple!(
- char[][], "insert_contents",
- string[], "images"
- );
- ContentsAndImages scan_subdoc_source(O)(
+ struct ST_contents_and_images {
+ char[][] insert_contents;
+ string[] images;
+ }
+ ST_contents_and_images scan_subdoc_source(O)(
O _opt_action,
char[][] markup_sourcefile_insert_content,
string fn_src
@@ -311,13 +312,14 @@ template spineRawMarkupContent() {
}
}
} // end src subdoc (inserts) loop
- ContentsAndImages t = tuple(
- contents_insert,
- _images
- );
- return t;
+ ST_contents_and_images ret;
+ {
+ ret.insert_contents = contents_insert;
+ ret.images = _images;
+ }
+ return ret;
}
- ContentsInsertsImages scan_master_src_for_insert_files_and_import_content(O)(
+ ST_contents_inserts_images scan_master_src_for_insert_files_and_import_content(O)(
O _opt_action,
char[][] sourcefile_body_content,
string fn_src
@@ -367,14 +369,14 @@ template spineRawMarkupContent() {
);
}
auto ins = Inserts();
- ContentsAndImages contents_insert_tu = ins.scan_subdoc_source(
+ ST_contents_and_images contents_insert_st = ins.scan_subdoc_source(
_opt_action,
markup_sourcefile_insert_content,
fn_src_insert.to!string
);
- contents ~= contents_insert_tu.insert_contents;
+ contents ~= contents_insert_st.insert_contents;
if (_opt_action.source || _opt_action.pod) {
- string[] _image_linelist = _extract_images(contents_insert_tu.images);
+ string[] _image_linelist = _extract_images(contents_insert_st.images);
if (_image_linelist.length > 0) {
_images ~= _image_linelist;
}
@@ -407,12 +409,13 @@ template spineRawMarkupContent() {
writeln(__LINE__);
writeln(contents.length);
}
- ContentsInsertsImages t = tuple(
- contents,
- insert_file_list,
- images
- );
- return t;
+ ST_contents_inserts_images ret;
+ {
+ ret.contents = contents;
+ ret.insert_files = insert_file_list;
+ ret.images = images;
+ }
+ return ret;
}
}
}