use std::sync::Arc;
use indexmap::IndexMap;
use crate::engine::{AttributeName, TemplateData};
use crate::util::Utf16String;
use super::{
AttributeValueQuotes, ICDATASection, ICloseElementTag, IComment, IDocType, IModel,
IOpenElementTag, IProcessableElementTag, IProcessingInstruction, IStandaloneElementTag,
ITemplateEvent, IText, IXMLDeclaration,
};
pub trait IModelFactory: Send + Sync {
fn create_model(&self) -> Box<dyn IModel>;
fn create_model_with_event(
&self,
event: Arc<dyn ITemplateEvent>,
) -> Result<Box<dyn IModel>, crate::model::IModelError>;
fn parse(
&self,
owner_template: &TemplateData,
template: &Utf16String,
) -> Result<Box<dyn IModel>, crate::exceptions::TemplateProcessingException>;
fn create_cdata_section(
&self,
content: Utf16String,
) -> Result<Arc<dyn ICDATASection>, crate::exceptions::TemplateProcessingException>;
fn create_comment(
&self,
content: Utf16String,
) -> Result<Arc<dyn IComment>, crate::exceptions::TemplateProcessingException>;
fn create_html5_doc_type(
&self,
) -> Result<Arc<dyn IDocType>, crate::exceptions::TemplateProcessingException>;
fn create_doc_type(
&self,
public_id: Option<Utf16String>,
system_id: Option<Utf16String>,
) -> Result<Arc<dyn IDocType>, crate::exceptions::TemplateProcessingException>;
fn create_full_doc_type(
&self,
keyword: Utf16String,
element_name: Utf16String,
public_id: Option<Utf16String>,
system_id: Option<Utf16String>,
internal_subset: Option<Utf16String>,
) -> Result<Arc<dyn IDocType>, crate::exceptions::TemplateProcessingException>;
fn create_processing_instruction(
&self,
target: Utf16String,
content: Utf16String,
) -> Result<Arc<dyn IProcessingInstruction>, crate::exceptions::TemplateProcessingException>;
fn create_text(&self, text: Utf16String) -> Arc<dyn IText>;
fn create_xml_declaration(
&self,
version: Option<Utf16String>,
encoding: Option<Utf16String>,
standalone: Option<Utf16String>,
) -> Result<Arc<dyn IXMLDeclaration>, crate::exceptions::TemplateProcessingException>;
fn create_standalone_element_tag(
&self,
element_name: Utf16String,
attributes: Option<&IndexMap<Utf16String, Option<Utf16String>>>,
attribute_value_quotes: AttributeValueQuotes,
synthetic: bool,
minimized: bool,
) -> Result<Arc<dyn IStandaloneElementTag>, crate::exceptions::TemplateProcessingException>;
fn create_open_element_tag(
&self,
element_name: Utf16String,
attributes: Option<&IndexMap<Utf16String, Option<Utf16String>>>,
attribute_value_quotes: AttributeValueQuotes,
synthetic: bool,
) -> Result<Arc<dyn IOpenElementTag>, crate::exceptions::TemplateProcessingException>;
fn create_close_element_tag(
&self,
element_name: Utf16String,
synthetic: bool,
unmatched: bool,
) -> Result<Arc<dyn ICloseElementTag>, crate::exceptions::TemplateProcessingException>;
fn set_attribute(
&self,
tag: Arc<dyn IProcessableElementTag>,
attribute_name: Utf16String,
attribute_value: Option<Utf16String>,
attribute_value_quotes: Option<AttributeValueQuotes>,
) -> Result<Arc<dyn IProcessableElementTag>, crate::exceptions::TemplateProcessingException>;
fn replace_attribute(
&self,
tag: Arc<dyn IProcessableElementTag>,
old_attribute_name: &AttributeName,
attribute_name: Utf16String,
attribute_value: Option<Utf16String>,
attribute_value_quotes: Option<AttributeValueQuotes>,
) -> Result<Arc<dyn IProcessableElementTag>, crate::exceptions::TemplateProcessingException>;
fn remove_attribute(
&self,
tag: Arc<dyn IProcessableElementTag>,
attribute_name: &AttributeName,
) -> Result<Arc<dyn IProcessableElementTag>, crate::exceptions::TemplateProcessingException>;
}