1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// This file was generated by gir (https://github.com/gtk-rs/gir)
// DO NOT EDIT

use crate::{SpaJson};
use glib::{translate::*};

glib::wrapper! {
    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
    pub struct SpaJsonParser(Shared<ffi::WpSpaJsonParser>);

    match fn {
        ref => |ptr| ffi::wp_spa_json_parser_ref(ptr),
        unref => |ptr| ffi::wp_spa_json_parser_unref(ptr),
        type_ => || ffi::wp_spa_json_parser_get_type(),
    }
}

impl SpaJsonParser {
    #[doc(alias = "wp_spa_json_parser_new_array")]
    #[doc(alias = "new_array")]
    pub unsafe fn new_array_unchecked(json: &SpaJson) -> SpaJsonParser {
        from_glib_full(ffi::wp_spa_json_parser_new_array(json.to_glib_none().0))
    }

    #[doc(alias = "wp_spa_json_parser_new_object")]
    #[doc(alias = "new_object")]
    pub unsafe fn new_object_unchecked(json: &SpaJson) -> SpaJsonParser {
        from_glib_full(ffi::wp_spa_json_parser_new_object(json.to_glib_none().0))
    }

    #[doc(alias = "wp_spa_json_parser_end")]
    pub fn end(&self) {
        unsafe {
            ffi::wp_spa_json_parser_end(self.to_glib_none().0);
        }
    }

    #[doc(alias = "wp_spa_json_parser_get_boolean")]
    #[doc(alias = "get_boolean")]
    pub fn boolean(&self) -> Option<bool> {
        unsafe {
            let mut value = std::mem::MaybeUninit::uninit();
            let ret = from_glib(ffi::wp_spa_json_parser_get_boolean(self.to_glib_none().0, value.as_mut_ptr()));
            if ret { Some(from_glib(value.assume_init())) } else { None }
        }
    }

    #[doc(alias = "wp_spa_json_parser_get_float")]
    #[doc(alias = "get_float")]
    pub fn float(&self) -> Option<f32> {
        unsafe {
            let mut value = std::mem::MaybeUninit::uninit();
            let ret = from_glib(ffi::wp_spa_json_parser_get_float(self.to_glib_none().0, value.as_mut_ptr()));
            if ret { Some(value.assume_init()) } else { None }
        }
    }

    #[doc(alias = "wp_spa_json_parser_get_int")]
    #[doc(alias = "get_int")]
    pub fn int(&self) -> Option<i32> {
        unsafe {
            let mut value = std::mem::MaybeUninit::uninit();
            let ret = from_glib(ffi::wp_spa_json_parser_get_int(self.to_glib_none().0, value.as_mut_ptr()));
            if ret { Some(value.assume_init()) } else { None }
        }
    }

    #[doc(alias = "wp_spa_json_parser_get_null")]
    #[doc(alias = "get_null")]
    pub fn null(&self) -> bool {
        unsafe {
            from_glib(ffi::wp_spa_json_parser_get_null(self.to_glib_none().0))
        }
    }

    #[doc(alias = "wp_spa_json_parser_get_string")]
    #[doc(alias = "get_string")]
    pub fn string(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_full(ffi::wp_spa_json_parser_get_string(self.to_glib_none().0))
        }
    }
}