aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sisudoc/io_in
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2024-06-29 13:54:28 -0400
committerRalph Amissah <ralph.amissah@gmail.com>2024-06-29 15:39:08 -0400
commit860b894a10f3526e6bd73d53850764c0ad95ab99 (patch)
treee4a997fcacd3b2dcbff876479ebd1ee718230f1e /src/sisudoc/io_in
parentnix minor (diff)
document digests and reduction in use of tuples
Diffstat (limited to 'src/sisudoc/io_in')
-rw-r--r--src/sisudoc/io_in/read_source_files.d54
1 files changed, 38 insertions, 16 deletions
diff --git a/src/sisudoc/io_in/read_source_files.d b/src/sisudoc/io_in/read_source_files.d
index 4ba0b4f..8d814fc 100644
--- a/src/sisudoc/io_in/read_source_files.d
+++ b/src/sisudoc/io_in/read_source_files.d
@@ -56,6 +56,7 @@ module sisudoc.io_in.read_source_files;
@safe:
template spineRawMarkupContent() {
import
+ std.digest.sha,
std.file,
std.path;
import
@@ -67,6 +68,14 @@ 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,7 +95,9 @@ template spineRawMarkupContent() {
char[], "header",
char[][], "src_txt",
string[], "insert_files",
- string[], "images"
+ string[], "images",
+ ubyte[32], "header_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
@@ -100,43 +111,50 @@ template spineRawMarkupContent() {
= raw.markupSourceReadIn(fn_src);
return source_txt_str;
}
- final auto sourceContentSplitIntoHeaderAndBody(O)(
+ final ST_doc_parts sourceContentSplitIntoHeaderAndBody(O)(
O _opt_action,
in string source_txt_str,
in string fn_src=""
) {
auto raw = MarkupRawUnit();
- string[] insert_file_list;
- string[] images_list;
+ 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;
if (fn_src.match(rgx_files.src_fn_master)) { // filename with path needed if master file (.ssm) not otherwise
auto ins = Inserts();
ContentsInsertsImages tu
= 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 = tu.insert_files.dup;
- images_list = tu.images.dup;
+ insert_file_list_get = tu.insert_files.dup;
+ images_list_get = tu.images.dup;
} else if (_opt_action.source || _opt_action.pod) {
auto ins = Inserts();
ContentsInsertsImages tu
= ins.scan_master_src_for_insert_files_and_import_content(_opt_action, sourcefile_body_content, fn_src);
- images_list = tu.images.dup;
+ images_list_get = tu.images.dup;
}
+ ubyte[32] src_txt_digest = sourcefile_body_content.sha256Of;
string header_type = "";
- t = tuple(
- header_raw,
- sourcefile_body_content,
- insert_file_list,
- images_list
- );
- return t;
+ ST_doc_parts ret;
+ {
+ ret.header_raw = t.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.src_txt_digest = sourcefile_body_content.sha256Of;
+ }
+ return ret;
}
}
struct MarkupRawUnit {
- import std.file;
+ import
+ std.digest.sha,
+ std.file;
final private string readInMarkupSource(in char[] fn_src) {
enforce(
exists(fn_src) != 0,
@@ -195,11 +213,15 @@ template spineRawMarkupContent() {
char[] header = hc[0];
char[] source_txt = hc[1];
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
+ images_list,
+ header_digest,
+ src_txt_digest
);
return t;
}