From e1ece5b98600727a127b3853cee5e9c76f05749b Mon Sep 17 00:00:00 2001 From: philipp Date: Sat, 4 Nov 2023 12:14:02 +0100 Subject: [PATCH] add draft of structs of laws --- src/law.rs | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main.rs | 1 + 2 files changed, 67 insertions(+) create mode 100644 src/law.rs diff --git a/src/law.rs b/src/law.rs new file mode 100644 index 0000000..48daa04 --- /dev/null +++ b/src/law.rs @@ -0,0 +1,66 @@ +struct Law { + name: String, //ABGB, UrhG + section: Vec
, // § 1, § 2, ... +} + +impl Law { + fn new(name: &str) -> Self { + Self { + name: name.into(), + section: Vec::new(), + } + } + + fn get_classifiers(&self) -> Vec { + let mut ret = Vec::new(); + for sec in &self.section { + if let Some(header) = &sec.header { + for class in header.get_all_classifiers() { + ret.push(class); + } + } + } + ret + } + + fn new_header(&self, name: &str) { + //TODO: continue here + } +} + +struct Section { + symb: String, // §"1", §"2", ... + content: Content, + header: Option
, +} + +struct Header { + classifier: Classifier, // Hauptstück, Theil, Abschnitt, ol + name: String, // 1. Hauptstück, 3. Theil, 7. Abschnitt, li + parent: Option>, +} + +impl Header { + fn get_all_classifiers(&self) -> Vec { + let mut ret = Vec::new(); + ret.push(self.classifier.clone()); + if let Some(parent) = &self.parent { + for a in parent.get_all_classifiers() { + ret.push(a); + } + } + + ret + } +} + +#[derive(Clone)] +struct Classifier { + name: String, // Hauptstück, Theil, Abschnitt, ol +} + +enum Content { + Text(String), //This is my direct law text + Item((String, Box)), //(1) This is general law. (2) This is more specific law + List(Vec>), //1. my first item +} diff --git a/src/main.rs b/src/main.rs index 3a5af58..9c283a9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,6 @@ use std::io; +mod law; mod overview; mod par;