Merge remote-tracking branch 'upstream/main'

This commit is contained in:
Blizzard Finnegan 2023-08-08 11:29:38 -04:00
commit aff3520ae2
Signed by: blizzardfinnegan
GPG key ID: 61C1E13067E0018E
2 changed files with 17 additions and 10 deletions

View file

@ -1,6 +1,6 @@
mod oop;
use std::{thread::{self, JoinHandle}, io::Write};
use roxmltree::{self, Document};
use roxmltree;
fn main() {
let args: Vec<String> = std::env::args().collect();
@ -44,7 +44,7 @@ fn main() {
handle.join().expect("Couldn't close thread.");
}
}
fn new_parse(doc:&Document) -> Result<oop::Family,core::fmt::Error>{
fn new_parse(doc:&roxmltree::Document) -> Result<oop::Family,core::fmt::Error>{
let mut wrapped_family:Option<oop::Family> = None;
let mut messages: oop::Messages = oop::Messages::new(Vec::new(), Vec::new(), Vec::new(), Vec::new(), Vec::new());
@ -57,12 +57,10 @@ fn new_parse(doc:&Document) -> Result<oop::Family,core::fmt::Error>{
},
_ => {}
}
if let Some(ref mut family) = wrapped_family{
for child in root.children(){
nested_parse(family, child);
}
}
if let Some(ref mut family) = wrapped_family{
root.children().for_each(|child| nested_parse(family, child));
}
root.children().filter(|outer_child| outer_child.tag_name().name() == "MESSAGES" )
.for_each(|message_group| {
message_group.children().filter(|inner_child| inner_child.tag_name().name() == "MSG")
@ -152,7 +150,8 @@ fn nested_parse(input_family:&mut oop::Family, node: roxmltree::Node) {
node.attribute("name").unwrap().to_string(),
node.attribute("minversion").unwrap().to_string(),
node.attribute("maxversion").unwrap().to_string(),
Vec::new()
Vec::new(),
node.attribute("format").unwrap_or("").to_string()
));
});
});
@ -238,3 +237,4 @@ fn output(family: oop::Family) {
}
}
}

View file

@ -152,11 +152,12 @@ pub struct ObjectMember {
minversion: String,
maxversion: String,
enumerations: Vec<MemberEnumeration>,
format: String,
}
impl ObjectMember {
pub fn new(member_type: String, name: String, minversion: String, maxversion: String, enumerations: Vec<MemberEnumeration>) -> Self {
Self { member_type, name, minversion, maxversion, enumerations }
pub fn new(member_type: String, name: String, minversion: String, maxversion: String, enumerations: Vec<MemberEnumeration>, format: String) -> Self {
Self { member_type, name, minversion, maxversion, enumerations, format }
}
pub fn get_name(&self) -> String{
@ -187,6 +188,12 @@ impl ObjectMember {
pub fn push_member_enumeration(&mut self, enumeration: MemberEnumeration) {
self.enumerations.push(enumeration);
}
#[allow(unused)]
pub fn get_format(&mut self) -> &mut String{
return &mut self.format
}
}
#[derive(Debug, Clone)]