1/*
2 * << Haru Free PDF Library >> -- hpdf_boolean.c
3 *
4 * URL: http://libharu.org
5 *
6 * Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
7 * Copyright (c) 2007-2009 Antony Dovgal <tony@daylessday.org>
8 *
9 * Permission to use, copy, modify, distribute and sell this software
10 * and its documentation for any purpose is hereby granted without fee,
11 * provided that the above copyright notice appear in all copies and
12 * that both that copyright notice and this permission notice appear
13 * in supporting documentation.
14 * It is provided "as is" without express or implied warranty.
15 *
16 */
17
18#include "hpdf_utils.h"
19#include "hpdf_objects.h"
20
21HPDF_Boolean
22HPDF_Boolean_New (HPDF_MMgr mmgr,
23 HPDF_BOOL value)
24{
25 HPDF_Boolean obj = HPDF_GetMem (mmgr, sizeof(HPDF_Boolean_Rec));
26
27 if (obj) {
28 HPDF_MemSet(&obj->header, 0, sizeof(HPDF_Obj_Header));
29 obj->header.obj_class = HPDF_OCLASS_BOOLEAN;
30 obj->value = value;
31 }
32
33 return obj;
34}
35
36
37HPDF_STATUS
38HPDF_Boolean_Write (HPDF_Boolean obj,
39 HPDF_Stream stream)
40{
41 HPDF_STATUS ret;
42
43 if (obj->value)
44 ret = HPDF_Stream_WriteStr (stream, "true");
45 else
46 ret = HPDF_Stream_WriteStr (stream, "false");
47
48 return ret;
49}
50
51