pub mod json_reader;

pub type OverlayDesc = Vec<OverlaySlot>;

const COMMENT_PREFIX:char = '!';

pub struct OverlaySlot {
    pub(super) name:      String,
    pub(super) sections:  Vec<OverlaySection>
}

impl OverlaySlot {
    pub fn new(name: String) -> OverlaySlot {
        OverlaySlot{name, sections: Vec::new()}
    }

    pub fn add_section(&mut self, section: OverlaySection) {
        self.sections.push(section);
    }

    pub fn is_commented_out(&self) -> bool {
        self.name.starts_with(COMMENT_PREFIX)
    }

    pub fn has_sections(&self) -> bool {
        !self.sections.is_empty()
    }
}

pub struct OverlaySection {
    pub(super) name:         String,
    pub(super) file_pattern: Vec<String>
}

impl OverlaySection {
    pub fn new(name: String) -> OverlaySection {
        OverlaySection{name, file_pattern: Vec::new()}
    }

    pub fn add_file_pattern(&mut self, file_pattern: String) {
        self.file_pattern.push(file_pattern);
    }

    pub fn is_commented_out(&self) -> bool {
        self.name.starts_with(COMMENT_PREFIX)
    }
}