use std::{ffi::c_void, rc::Rc, sync::atomic::AtomicPtr};
use crate::{
dom::elementdecl::ElementContent,
globals::{GenericErrorContext, StructuredError},
libxml::sax2::{
xml_sax2_get_column_number, xml_sax2_get_line_number, xml_sax2_get_public_id,
xml_sax2_get_system_id,
},
parser::XmlParserInput,
tree::{
XmlAttributeDefault, XmlAttributeType, XmlElementTypeVal, XmlEntityPtr, XmlEntityType,
XmlEnumeration,
},
};
use super::XmlParserCtxt;
#[repr(C)]
#[derive(Clone, Default)]
pub(crate) struct XmlStartTag {
pub(crate) prefix: Option<Rc<str>>,
pub(crate) uri: Option<Rc<str>>,
pub(crate) line: i32,
pub(crate) ns_nr: i32,
}
#[doc(alias = "xmlSAXLocator")]
#[repr(C)]
pub struct XmlSAXLocator {
pub(crate) get_public_id: fn(&XmlParserCtxt) -> Option<String>,
pub(crate) get_system_id: fn(&XmlParserCtxt) -> Option<String>,
pub(crate) get_line_number: fn(&XmlParserCtxt) -> i32,
pub(crate) get_column_number: fn(&XmlParserCtxt) -> i32,
}
impl Default for XmlSAXLocator {
fn default() -> Self {
Self {
get_public_id: xml_sax2_get_public_id,
get_system_id: xml_sax2_get_system_id,
get_line_number: xml_sax2_get_line_number,
get_column_number: xml_sax2_get_column_number,
}
}
}
#[doc(alias = "resolveEntitySAXFunc")]
pub type ResolveEntitySAXFunc =
fn(&mut XmlParserCtxt, Option<&str>, Option<&str>) -> Option<XmlParserInput<'static>>;
#[doc(alias = "internalSubsetSAXFunc")]
pub type InternalSubsetSAXFunc = fn(&mut XmlParserCtxt, Option<&str>, Option<&str>, Option<&str>);
#[doc(alias = "externalSubsetSAXFunc")]
pub type ExternalSubsetSAXFunc = fn(&mut XmlParserCtxt, Option<&str>, Option<&str>, Option<&str>);
#[doc(alias = "getEntitySAXFunc")]
pub type GetEntitySAXFunc = fn(&mut XmlParserCtxt, &str) -> Option<XmlEntityPtr>;
#[doc(alias = "getParameterEntitySAXFunc")]
pub type GetParameterEntitySAXFunc = fn(&mut XmlParserCtxt, &str) -> Option<XmlEntityPtr>;
#[doc(alias = "entityDeclSAXFunc")]
pub type EntityDeclSAXFunc =
fn(&mut XmlParserCtxt, &str, XmlEntityType, Option<&str>, Option<&str>, Option<&str>);
#[doc(alias = "notationDeclSAXFunc")]
pub type NotationDeclSAXFunc = fn(&mut XmlParserCtxt, &str, Option<&str>, Option<&str>);
#[doc(alias = "attributeDeclSAXFunc")]
pub type AttributeDeclSAXFunc = fn(
&mut XmlParserCtxt,
&str,
&str,
XmlAttributeType,
XmlAttributeDefault,
Option<&str>,
Option<Box<XmlEnumeration>>,
);
#[doc(alias = "elementDeclSAXFunc")]
pub type ElementDeclSAXFunc =
fn(&mut XmlParserCtxt, &str, Option<XmlElementTypeVal>, Option<Rc<ElementContent>>);
#[doc(alias = "unparsedEntityDeclSAXFunc")]
pub type UnparsedEntityDeclSAXFunc =
fn(&mut XmlParserCtxt, &str, Option<&str>, Option<&str>, Option<&str>);
#[doc(alias = "setDocumentLocatorSAXFunc")]
pub type SetDocumentLocatorSAXFunc = fn(&mut XmlParserCtxt, XmlSAXLocator);
#[doc(alias = "startDocumentSAXFunc")]
pub type StartDocumentSAXFunc = fn(&mut XmlParserCtxt);
#[doc(alias = "endDocumentSAXFunc")]
pub type EndDocumentSAXFunc = fn(&mut XmlParserCtxt);
#[doc(alias = "startElementSAXFunc")]
pub type StartElementSAXFunc = fn(&mut XmlParserCtxt, &str, &[(String, Option<String>)]);
#[doc(alias = "endElementSAXFunc")]
pub type EndElementSAXFunc = fn(&mut XmlParserCtxt, &str);
#[doc(alias = "attributeSAXFunc")]
pub type AttributeSAXFunc = fn(&mut XmlParserCtxt, &str, &str);
#[doc(alias = "referenceSAXFunc")]
pub type ReferenceSAXFunc = fn(&mut XmlParserCtxt, &str);
#[doc(alias = "charactersSAXFunc")]
pub type CharactersSAXFunc = fn(&mut XmlParserCtxt, &str);
#[doc(alias = "ignorableWhitespaceSAXFunc")]
pub type IgnorableWhitespaceSAXFunc = fn(&mut XmlParserCtxt, &str);
#[doc(alias = "processingInstructionSAXFunc")]
pub type ProcessingInstructionSAXFunc = fn(&mut XmlParserCtxt, &str, Option<&str>);
#[doc(alias = "commentSAXFunc")]
pub type CommentSAXFunc = fn(&mut XmlParserCtxt, &str);
#[doc(alias = "cdataBlockSAXFunc")]
pub type CDATABlockSAXFunc = fn(&mut XmlParserCtxt, &str);
#[doc(alias = "warningSAXFunc")]
pub type WarningSAXFunc = fn(ctx: Option<GenericErrorContext>, msg: &str);
#[doc(alias = "errorSAXFunc")]
pub type ErrorSAXFunc = fn(ctx: Option<GenericErrorContext>, msg: &str);
#[doc(alias = "fatalErrorSAXFunc")]
pub type FatalErrorSAXFunc = fn(ctx: Option<GenericErrorContext>, msg: &str);
#[doc(alias = "isStandaloneSAXFunc")]
pub type IsStandaloneSAXFunc = fn(&mut XmlParserCtxt) -> i32;
#[doc(alias = "hasInternalSubsetSAXFunc")]
pub type HasInternalSubsetSAXFunc = fn(&mut XmlParserCtxt) -> i32;
#[doc(alias = "hasExternalSubsetSAXFunc")]
pub type HasExternalSubsetSAXFunc = fn(&mut XmlParserCtxt) -> i32;
#[doc(alias = "startElementNsSAX2Func")]
pub type StartElementNsSAX2Func = fn(
&mut XmlParserCtxt,
&str,
Option<&str>,
Option<&str>,
&[(Option<String>, String)],
usize,
&[(String, Option<String>, Option<String>, String)],
);
#[doc(alias = "endElementNsSAX2Func")]
pub type EndElementNsSAX2Func = fn(&mut XmlParserCtxt, &str, Option<&str>, Option<&str>);
#[doc(alias = "xmlSAXHandler")]
#[repr(C)]
#[derive(Debug, Default)]
pub struct XmlSAXHandler {
pub internal_subset: Option<InternalSubsetSAXFunc>,
pub is_standalone: Option<IsStandaloneSAXFunc>,
pub has_internal_subset: Option<HasInternalSubsetSAXFunc>,
pub has_external_subset: Option<HasExternalSubsetSAXFunc>,
pub resolve_entity: Option<ResolveEntitySAXFunc>,
pub get_entity: Option<GetEntitySAXFunc>,
pub entity_decl: Option<EntityDeclSAXFunc>,
pub notation_decl: Option<NotationDeclSAXFunc>,
pub attribute_decl: Option<AttributeDeclSAXFunc>,
pub element_decl: Option<ElementDeclSAXFunc>,
pub unparsed_entity_decl: Option<UnparsedEntityDeclSAXFunc>,
pub set_document_locator: Option<SetDocumentLocatorSAXFunc>,
pub start_document: Option<StartDocumentSAXFunc>,
pub end_document: Option<EndDocumentSAXFunc>,
pub start_element: Option<StartElementSAXFunc>,
pub end_element: Option<EndElementSAXFunc>,
pub reference: Option<ReferenceSAXFunc>,
pub characters: Option<CharactersSAXFunc>,
pub ignorable_whitespace: Option<IgnorableWhitespaceSAXFunc>,
pub processing_instruction: Option<ProcessingInstructionSAXFunc>,
pub comment: Option<CommentSAXFunc>,
pub warning: Option<WarningSAXFunc>,
pub error: Option<ErrorSAXFunc>,
pub fatal_error: Option<FatalErrorSAXFunc>, pub get_parameter_entity: Option<GetParameterEntitySAXFunc>,
pub cdata_block: Option<CDATABlockSAXFunc>,
pub external_subset: Option<ExternalSubsetSAXFunc>,
pub initialized: u32,
pub _private: AtomicPtr<c_void>,
pub start_element_ns: Option<StartElementNsSAX2Func>,
pub end_element_ns: Option<EndElementNsSAX2Func>,
pub serror: Option<StructuredError>,
}