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))
}
}
}