use crate::{SpaJson};
use glib::{translate::*};
glib::wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct SpaJsonBuilder(Shared<ffi::WpSpaJsonBuilder>);
match fn {
ref => |ptr| ffi::wp_spa_json_builder_ref(ptr),
unref => |ptr| ffi::wp_spa_json_builder_unref(ptr),
type_ => || ffi::wp_spa_json_builder_get_type(),
}
}
impl SpaJsonBuilder {
#[doc(alias = "wp_spa_json_builder_new_array")]
pub fn new_array() -> SpaJsonBuilder {
unsafe {
from_glib_full(ffi::wp_spa_json_builder_new_array())
}
}
#[doc(alias = "wp_spa_json_builder_new_object")]
pub fn new_object() -> SpaJsonBuilder {
unsafe {
from_glib_full(ffi::wp_spa_json_builder_new_object())
}
}
#[doc(alias = "wp_spa_json_builder_add_boolean")]
pub fn add_boolean(&self, value: bool) {
unsafe {
ffi::wp_spa_json_builder_add_boolean(self.to_glib_none().0, value.into_glib());
}
}
#[doc(alias = "wp_spa_json_builder_add_float")]
pub fn add_float(&self, value: f32) {
unsafe {
ffi::wp_spa_json_builder_add_float(self.to_glib_none().0, value);
}
}
#[doc(alias = "wp_spa_json_builder_add_int")]
pub fn add_int(&self, value: i32) {
unsafe {
ffi::wp_spa_json_builder_add_int(self.to_glib_none().0, value);
}
}
#[doc(hidden)]
#[doc(alias = "wp_spa_json_builder_add_json")]
#[doc(alias = "add_json")]
pub fn add_spa_json(&self, json: &SpaJson) {
unsafe {
ffi::wp_spa_json_builder_add_json(self.to_glib_none().0, json.to_glib_none().0);
}
}
#[doc(alias = "wp_spa_json_builder_add_null")]
pub fn add_null(&self) {
unsafe {
ffi::wp_spa_json_builder_add_null(self.to_glib_none().0);
}
}
#[doc(alias = "wp_spa_json_builder_add_property")]
pub fn add_property(&self, key: &str) {
unsafe {
ffi::wp_spa_json_builder_add_property(self.to_glib_none().0, key.to_glib_none().0);
}
}
#[doc(alias = "wp_spa_json_builder_add_string")]
pub fn add_string(&self, value: &str) {
unsafe {
ffi::wp_spa_json_builder_add_string(self.to_glib_none().0, value.to_glib_none().0);
}
}
#[doc(alias = "wp_spa_json_builder_end")]
pub fn end(&self) -> SpaJson {
unsafe {
from_glib_full(ffi::wp_spa_json_builder_end(self.to_glib_none().0))
}
}
}