1 | /* |
2 | * << Haru Free PDF Library >> -- hpdf_number.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 | |
21 | |
22 | HPDF_Number |
23 | HPDF_Number_New (HPDF_MMgr mmgr, |
24 | HPDF_INT32 value) |
25 | { |
26 | HPDF_Number obj = HPDF_GetMem (mmgr, sizeof(HPDF_Number_Rec)); |
27 | |
28 | if (obj) { |
29 | HPDF_MemSet (&obj->header, 0, sizeof(HPDF_Obj_Header)); |
30 | obj->header.obj_class = HPDF_OCLASS_NUMBER; |
31 | obj->value = value; |
32 | } |
33 | |
34 | return obj; |
35 | } |
36 | |
37 | |
38 | HPDF_STATUS |
39 | HPDF_Number_Write (HPDF_Number obj, |
40 | HPDF_Stream stream) |
41 | { |
42 | return HPDF_Stream_WriteInt (stream, obj->value); |
43 | } |
44 | |
45 | |
46 | void |
47 | HPDF_Number_SetValue (HPDF_Number obj, |
48 | HPDF_INT32 value) |
49 | { |
50 | obj->value =value; |
51 | } |
52 | |
53 | |