nom_xml/prolog/subset/entity/
entity_declaration.rs

1use crate::Name;
2
3use super::entity_definition::EntityDefinition;
4
5#[derive(Clone, Debug, PartialEq, Eq)]
6pub enum EntityDecl {
7    General(GeneralEntityDeclaration),
8    Parameter(ParameterEntityDeclaration),
9}
10
11#[derive(Clone, PartialEq, Eq)]
12pub struct EntityDeclaration {
13    pub name: Name,
14    pub entity_def: EntityDefinition,
15}
16pub type GeneralEntityDeclaration = EntityDeclaration;
17pub type ParameterEntityDeclaration = EntityDeclaration;
18
19impl EntityDeclaration {
20    pub fn find_name(&self, name: Name) -> Option<&GeneralEntityDeclaration> {
21        if self.name == name {
22            Some(self)
23        } else {
24            None
25        }
26    }
27
28    pub fn get_name(&self) -> &Name {
29        &self.name
30    }
31
32    pub fn get_entity_def(&self) -> &EntityDefinition {
33        &self.entity_def
34    }
35}