use crate::com::{SafeDispatch, SafeVariant};
use crate::errors::SageResult;
use windows::Win32::System::Com::IDispatch;
pub struct SoucheInterne {
pub(crate) dispatch: IDispatch,
}
impl SoucheInterne {
fn dispatch(&self) -> SafeDispatch<'_> {
SafeDispatch::new(&self.dispatch)
}
pub fn cbmarq(&self) -> SageResult<i32> {
self.dispatch().call_method_by_name("cbMarq", &[])?.to_i32()
}
pub fn intitule(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("Intitule", &[])?
.to_string()
}
pub fn n_numero(&self) -> SageResult<i32> {
self.dispatch()
.call_method_by_name("nNumero", &[])?
.to_i32()
}
pub fn prefixe(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("Prefixe", &[])?
.to_string()
}
pub fn suffixe(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("Suffixe", &[])?
.to_string()
}
pub fn compteur(&self) -> SageResult<i32> {
self.dispatch()
.call_method_by_name("Compteur", &[])?
.to_i32()
}
pub fn longueur(&self) -> SageResult<i16> {
self.dispatch()
.call_method_by_name("Longueur", &[])?
.to_short()
}
pub fn raz_annuelle(&self) -> SageResult<bool> {
self.dispatch()
.call_method_by_name("RAZAnnuelle", &[])?
.to_bool()
}
pub fn set_intitule(&self, value: &str) -> SageResult<()> {
let param = SafeVariant::from_string(value);
self.dispatch().call_property_put("Intitule", &[param])?;
Ok(())
}
pub fn set_n_numero(&self, value: i32) -> SageResult<()> {
let param = SafeVariant::I4(value);
self.dispatch().call_property_put("nNumero", &[param])?;
Ok(())
}
pub fn set_prefixe(&self, prefixe: &str) -> SageResult<()> {
let param = SafeVariant::from_string(prefixe);
self.dispatch().call_property_put("Prefixe", &[param])?;
Ok(())
}
pub fn set_compteur(&self, compteur: i32) -> SageResult<()> {
let param = SafeVariant::I4(compteur);
self.dispatch().call_property_put("Compteur", &[param])?;
Ok(())
}
pub fn write(&self) -> SageResult<()> {
self.dispatch().call_method_by_name("Write", &[])?;
Ok(())
}
pub fn write_default(&self) -> SageResult<()> {
self.dispatch().call_method_by_name("WriteDefault", &[])?;
Ok(())
}
}