1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{translate::*, Error};
6use std::{mem, ptr};
7
8crate::wrapper! {
9 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
10 pub struct MarkupParseContext(Shared<ffi::GMarkupParseContext>);
11
12 match fn {
13 ref => |ptr| ffi::g_markup_parse_context_ref(ptr),
14 unref => |ptr| ffi::g_markup_parse_context_unref(ptr),
15 type_ => || ffi::g_markup_parse_context_get_type(),
16 }
17}
18
19impl MarkupParseContext {
20 //#[doc(alias = "g_markup_parse_context_new")]
21 //pub fn new(parser: /*Ignored*/&MarkupParser, flags: /*Ignored*/MarkupParseFlags, user_data: /*Unimplemented*/Option<Basic: Pointer>) -> MarkupParseContext {
22 // unsafe { TODO: call ffi:g_markup_parse_context_new() }
23 //}
24
25 #[doc(alias = "g_markup_parse_context_end_parse")]
26 pub fn end_parse(&self) -> Result<(), crate::Error> {
27 unsafe {
28 let mut error = ptr::null_mut();
29 let is_ok = ffi::g_markup_parse_context_end_parse(self.to_glib_none().0, &mut error);
30 debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
31 if error.is_null() {
32 Ok(())
33 } else {
34 Err(from_glib_full(error))
35 }
36 }
37 }
38
39 #[doc(alias = "g_markup_parse_context_get_element")]
40 #[doc(alias = "get_element")]
41 pub fn element(&self) -> crate::GString {
42 unsafe {
43 from_glib_none(ffi::g_markup_parse_context_get_element(
44 self.to_glib_none().0,
45 ))
46 }
47 }
48
49 //#[doc(alias = "g_markup_parse_context_get_element_stack")]
50 //#[doc(alias = "get_element_stack")]
51 //pub fn element_stack(&self) -> /*Unimplemented*/Vec<Basic: Pointer> {
52 // unsafe { TODO: call ffi:g_markup_parse_context_get_element_stack() }
53 //}
54
55 #[doc(alias = "g_markup_parse_context_get_position")]
56 #[doc(alias = "get_position")]
57 pub fn position(&self) -> (i32, i32) {
58 unsafe {
59 let mut line_number = mem::MaybeUninit::uninit();
60 let mut char_number = mem::MaybeUninit::uninit();
61 ffi::g_markup_parse_context_get_position(
62 self.to_glib_none().0,
63 line_number.as_mut_ptr(),
64 char_number.as_mut_ptr(),
65 );
66 (line_number.assume_init(), char_number.assume_init())
67 }
68 }
69
70 #[doc(alias = "g_markup_parse_context_parse")]
71 pub fn parse(&self, text: &str) -> Result<(), crate::Error> {
72 let text_len = text.len() as _;
73 unsafe {
74 let mut error = ptr::null_mut();
75 let is_ok = ffi::g_markup_parse_context_parse(
76 self.to_glib_none().0,
77 text.to_glib_none().0,
78 text_len,
79 &mut error,
80 );
81 debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
82 if error.is_null() {
83 Ok(())
84 } else {
85 Err(from_glib_full(error))
86 }
87 }
88 }
89
90 //#[doc(alias = "g_markup_parse_context_pop")]
91 //pub fn pop(&self) -> /*Unimplemented*/Option<Basic: Pointer> {
92 // unsafe { TODO: call ffi:g_markup_parse_context_pop() }
93 //}
94
95 //#[doc(alias = "g_markup_parse_context_push")]
96 //pub fn push(&self, parser: /*Ignored*/&MarkupParser, user_data: /*Unimplemented*/Option<Basic: Pointer>) {
97 // unsafe { TODO: call ffi:g_markup_parse_context_push() }
98 //}
99}
100