1 /**
2 * collectd - src/meta_data.h
3 * Copyright (C) 2008-2011 Florian octo Forster
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 *
23 * Authors:
24 * Florian octo Forster <octo at collectd.org>
25 **/
27 #ifndef META_DATA_H
28 #define META_DATA_H
30 #include "collectd.h"
33 /*
34 * Defines
35 */
36 #define MD_TYPE_STRING 1
37 #define MD_TYPE_SIGNED_INT 2
38 #define MD_TYPE_UNSIGNED_INT 3
39 #define MD_TYPE_DOUBLE 4
40 #define MD_TYPE_BOOLEAN 5
42 struct meta_data_s;
43 typedef struct meta_data_s meta_data_t;
45 meta_data_t *meta_data_create (void);
46 meta_data_t *meta_data_clone (meta_data_t *orig);
47 int meta_data_clone_merge (meta_data_t **dest, meta_data_t *orig);
48 void meta_data_destroy (meta_data_t *md);
50 int meta_data_exists (meta_data_t *md, const char *key);
51 int meta_data_type (meta_data_t *md, const char *key);
52 int meta_data_toc (meta_data_t *md, char ***toc);
53 int meta_data_delete (meta_data_t *md, const char *key);
55 int meta_data_add_string (meta_data_t *md,
56 const char *key,
57 const char *value);
58 int meta_data_add_signed_int (meta_data_t *md,
59 const char *key,
60 int64_t value);
61 int meta_data_add_unsigned_int (meta_data_t *md,
62 const char *key,
63 uint64_t value);
64 int meta_data_add_double (meta_data_t *md,
65 const char *key,
66 double value);
67 int meta_data_add_boolean (meta_data_t *md,
68 const char *key,
69 _Bool value);
71 int meta_data_get_string (meta_data_t *md,
72 const char *key,
73 char **value);
74 int meta_data_get_signed_int (meta_data_t *md,
75 const char *key,
76 int64_t *value);
77 int meta_data_get_unsigned_int (meta_data_t *md,
78 const char *key,
79 uint64_t *value);
80 int meta_data_get_double (meta_data_t *md,
81 const char *key,
82 double *value);
83 int meta_data_get_boolean (meta_data_t *md,
84 const char *key,
85 _Bool *value);
87 /* Returns the value as a string, regardless of the type. */
88 int meta_data_as_string (meta_data_t *md,
89 const char *key,
90 char **value);
92 #endif /* META_DATA_H */
93 /* vim: set sw=2 sts=2 et : */