-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement sort() which sorts the elements in an arxml file
- Loading branch information
Showing
5 changed files
with
198 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use autosar_data::*; | ||
use std::env; | ||
|
||
fn main() { | ||
let args: Vec<String> = env::args().collect(); | ||
|
||
if args.len() != 2 { | ||
println!("Usage: {} <arxml filename>", args[0]); | ||
println!(" Output will be written to <input>_sorted.arxml"); | ||
return; | ||
} | ||
let filename = &args[1]; | ||
|
||
// create a project and load the file | ||
let project = AutosarProject::new(); | ||
let arxmlfile = match project.load_arxml_file(filename, false) { | ||
Ok((arxmlfile, warnings)) => { | ||
for warn_msg in warnings { | ||
println!("Warning: {warn_msg}"); | ||
} | ||
arxmlfile | ||
} | ||
Err(err) => { | ||
println!("Error: {err}"); | ||
return; | ||
} | ||
}; | ||
|
||
arxmlfile.sort(); | ||
|
||
// write the sorted file | ||
let filename_prefix = filename.strip_suffix(".arxml").or(Some(filename)).unwrap(); | ||
let new_filename = format!("{filename_prefix}_sorted.arxml"); | ||
arxmlfile.set_filename(&new_filename); | ||
project.write().unwrap(); | ||
println!("Sorted output has been written to \"{new_filename}\""); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters