add draft of structs of laws

This commit is contained in:
philipp 2023-11-04 12:14:02 +01:00
parent 9206714c0c
commit e1ece5b986
2 changed files with 67 additions and 0 deletions

66
src/law.rs Normal file
View File

@ -0,0 +1,66 @@
struct Law {
name: String, //ABGB, UrhG
section: Vec<Section>, // § 1, § 2, ...
}
impl Law {
fn new(name: &str) -> Self {
Self {
name: name.into(),
section: Vec::new(),
}
}
fn get_classifiers(&self) -> Vec<Classifier> {
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<Header>,
}
struct Header {
classifier: Classifier, // Hauptstück, Theil, Abschnitt, ol
name: String, // 1. Hauptstück, 3. Theil, 7. Abschnitt, li
parent: Option<Box<Header>>,
}
impl Header {
fn get_all_classifiers(&self) -> Vec<Classifier> {
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<Content>)), //(1) This is general law. (2) This is more specific law
List(Vec<Box<Content>>), //1. my first item
}

View File

@ -1,5 +1,6 @@
use std::io; use std::io;
mod law;
mod overview; mod overview;
mod par; mod par;