text: Add va_list variant for GP_Print()
[gfxprim/pasky.git] / demos / c_simple / meta_data.c
bloba2c9a6458fd90cb743232ed82d8904c49a60ceb6
1 /*****************************************************************************
2 * This file is part of gfxprim library. *
3 * *
4 * Gfxprim is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU Lesser General Public *
6 * License as published by the Free Software Foundation; either *
7 * version 2.1 of the License, or (at your option) any later version. *
8 * *
9 * Gfxprim is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12 * Lesser General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU Lesser General Public *
15 * License along with gfxprim; if not, write to the Free Software *
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
17 * Boston, MA 02110-1301 USA *
18 * *
19 * Copyright (C) 2009-2012 Cyril Hrubis <metan@ucw.cz> *
20 * *
21 *****************************************************************************/
25 Meta-data storage operations example.
27 Meta-data storage is used to store image meta-data (if present) such as
28 physical size, creation date, etc...
30 Meta-data storage is basically an typed dictionary.
32 This example shows low-level interface to GP_MetaData structure.
36 #include <stdio.h>
38 #include <GP.h>
40 int main(void)
42 GP_MetaData *data = GP_MetaDataCreate(10);
44 //GP_SetDebugLevel(10);
46 if (data == NULL)
47 return 1;
50 * Create integer
52 * May fail, if there is allready record with id 'dpi' or
53 * if there is no space left.
55 GP_MetaDataCreateInt(data, "dpi", 300);
58 * Create an string.
60 * The last parameter says, if the string should be duplicated
61 * in the metadata storage.
63 GP_MetaDataCreateString(data, "author", "Foo Bar <foo@bar.net>", 0, 1);
64 GP_MetaDataCreateString(data, "comment", "Created in hurry.", 0, 1);
65 GP_MetaDataCreateDouble(data, "pi", 3.141592);
67 const char *ret;
69 ret = GP_MetaDataGetString(data, "comment");
71 if (ret != NULL)
72 printf("Found string 'comment' = '%s'\n", ret);
73 else
74 printf("ERROR: cannot cound string 'comment'\n");
76 printf("\n");
79 * Print all meta-data
81 GP_MetaDataPrint(data);
83 return 0;