asset-tool/rox_compiler/src/common.rs

34 lines
738 B
Rust
Raw Normal View History

2024-07-01 18:18:34 +00:00
#[derive(Clone,Copy,Debug)]
pub enum Style{
Rox,
Rojo,
RoxRojo,
}
#[derive(Default)]
pub(crate) struct PropertiesOverride{
pub name:Option<String>,
pub class:Option<String>,
}
impl PropertiesOverride{
pub fn is_some(&self)->bool{
self.name.is_some()
||self.class.is_some()
}
}
impl std::fmt::Display for PropertiesOverride{
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
if let Some(name)=self.name.as_deref(){
writeln!(f,"-- Properties.Name = \"{}\"",name)?;
2024-07-01 18:18:34 +00:00
}
if let Some(class)=self.class.as_deref(){
writeln!(f,"-- Properties.ClassName = \"{}\"",class)?;
2024-07-01 18:18:34 +00:00
}
Ok(())
}
}
2024-07-19 18:34:51 +00:00
pub(crate) fn sanitize(s:&str)->std::borrow::Cow<'_,str>{
lazy_regex::regex!(r"[^A-Za-z0-9.-]").replace_all(s,"_")
2024-07-01 18:18:34 +00:00
}