| 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 |
**/ |
| 26 |
|
| 27 |
#ifndef META_DATA_H |
| 28 |
#define META_DATA_H |
| 29 |
|
| 30 |
#include "collectd.h" |
| 31 |
|
| 32 |
/* |
| 33 |
* Defines |
| 34 |
*/ |
| 35 |
#define MD_TYPE_STRING 1 |
| 36 |
#define MD_TYPE_SIGNED_INT 2 |
| 37 |
#define MD_TYPE_UNSIGNED_INT 3 |
| 38 |
#define MD_TYPE_DOUBLE 4 |
| 39 |
#define MD_TYPE_BOOLEAN 5 |
| 40 |
|
| 41 |
struct meta_data_s; |
| 42 |
typedef struct meta_data_s meta_data_t; |
| 43 |
|
| 44 |
meta_data_t *meta_data_create(void); |
| 45 |
meta_data_t *meta_data_clone(meta_data_t *orig); |
| 46 |
int meta_data_clone_merge(meta_data_t **dest, meta_data_t *orig); |
| 47 |
void meta_data_destroy(meta_data_t *md); |
| 48 |
|
| 49 |
int meta_data_exists(meta_data_t *md, const char *key); |
| 50 |
int meta_data_type(meta_data_t *md, const char *key); |
| 51 |
int meta_data_toc(meta_data_t *md, char ***toc); |
| 52 |
int meta_data_delete(meta_data_t *md, const char *key); |
| 53 |
|
| 54 |
int meta_data_add_string(meta_data_t *md, const char *key, const char *value); |
| 55 |
int meta_data_add_signed_int(meta_data_t *md, const char *key, int64_t value); |
| 56 |
int meta_data_add_unsigned_int(meta_data_t *md, const char *key, |
| 57 |
uint64_t value); |
| 58 |
int meta_data_add_double(meta_data_t *md, const char *key, double value); |
| 59 |
int meta_data_add_boolean(meta_data_t *md, const char *key, bool value); |
| 60 |
|
| 61 |
int meta_data_get_string(meta_data_t *md, const char *key, char **value); |
| 62 |
int meta_data_get_signed_int(meta_data_t *md, const char *key, int64_t *value); |
| 63 |
int meta_data_get_unsigned_int(meta_data_t *md, const char *key, |
| 64 |
uint64_t *value); |
| 65 |
int meta_data_get_double(meta_data_t *md, const char *key, double *value); |
| 66 |
int meta_data_get_boolean(meta_data_t *md, const char *key, bool *value); |
| 67 |
|
| 68 |
/* Returns the value as a string, regardless of the type. */ |
| 69 |
int meta_data_as_string(meta_data_t *md, const char *key, char **value); |
| 70 |
|
| 71 |
#endif /* META_DATA_H */ |