diff options
author | Kaiden Fey <kookie@spacekookie.de> | 2021-02-21 14:56:11 +0100 |
---|---|---|
committer | Kaiden Fey <kookie@spacekookie.de> | 2021-02-21 14:56:11 +0100 |
commit | f186a7345dfc99347673f46e0daff0cb63ac8492 (patch) | |
tree | 5179ffd4654b80ea11a1656e28ef244439648ba4 /apps/koffice/libko/src/cass/format/gen.rs | |
parent | effbdeed66e8de8e769b8ac069926ad1a9110e62 (diff) |
k-office: initial code dumpk-office/init
Diffstat (limited to 'apps/koffice/libko/src/cass/format/gen.rs')
-rw-r--r-- | apps/koffice/libko/src/cass/format/gen.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/apps/koffice/libko/src/cass/format/gen.rs b/apps/koffice/libko/src/cass/format/gen.rs new file mode 100644 index 000000000000..f77bcdc90e84 --- /dev/null +++ b/apps/koffice/libko/src/cass/format/gen.rs @@ -0,0 +1,32 @@ +//! Cassiopeia line generator +//! +//! This module takes a set of IR lines, and generates strings from +//! them that are in accordance with the way that the parser of the +//! same version expects them. + +use crate::cass::format::ir::{IrItem, IrType}; + +/// Take a line of IR and generate a string to print into a file +pub(crate) fn line(ir: &IrItem) -> String { + let IrItem { tt, lo } = ir; + match tt { + IrType::Ignore => "".into(), + IrType::Header(map) => format!( + "HEADER {}", + map.iter() + .map(|(k, v)| format!("{}={},", k, v)) + .collect::<Vec<_>>() + .join("") + ), + IrType::Start(time) => format!("START {}", time.to_string()), + + // FIXME: find a better way to align the lines here rather + // than having to manually having to pad the 'STOP' commands + IrType::Stop(time) => format!("STOP {}", time.to_string()), + IrType::Invoice(date) => format!("INVOICE {}", date.to_string()), + } +} + +pub(crate) fn head_comment() -> String { + ";; generated by cassiopeia, be careful about editing by hand!".into() +} |