INGOR
Loading...
Searching...
No Matches
ytKeyValues.h
1/*
2 util/ytKeyValues.{h,c} : Key-value pairs.
3 Copyright (C) 2018, Yoshinori Tamada <tamada A T ytlab.jp>
4 All rights reserved.
5
6 See LICENSE.txt for details of the licensing agreement.
7*/
8
9#ifndef __YTLIB_KEY_VALUES_H
10#define __YTLIB_KEY_VALUES_H
11
12#include "ytStrArray.h"
13#include "ytArray.h"
14#include "ytIntArray.h"
15#include "ytDoubleArray.h"
16
20
25
29
33
37
38#ifdef DOXY
41#define ytKeyValues_ERROR_VALUE
42#else
43#define ytKeyValues_ERROR_VALUE ((size_t) -1)
44#endif
45
46typedef struct ytKeyValues_t ytKeyValues;
47
48
49
50#ifdef YTLIB_MEMCHECK
51ytKeyValues * ytKeyValues_newm(const char * file, int line);
52void ytKeyValues_deletem(ytKeyValues * this, const char * file, int line);
53#define ytKeyValues_new() ytKeyValues_newm(__FILE__,__LINE__)
54#define ytKeyValues_delete(this) ytKeyValues_deletem(this,__FILE__,__LINE__)
55#else
56ytKeyValues * ytKeyValues_new();
57void ytKeyValues_delete(ytKeyValues * this);
58#endif
59
60void ytKeyValues_deleteAll(ytKeyValues * this);
61void ytKeyValues_deleteAllv(void * this);
62ytKeyValues * ytKeyValues_clone(const ytKeyValues * this);
63ytObject * ytKeyValues_cloneI(const ytObject * this);
64ytObject * ytKeyValues_obj(ytKeyValues * kv);
65ytKeyValues * ytKeyValues_from(ytObject * this);
66ytObject * ytKeyValues_pObj(ytKeyValues ** ptr);
67ytKeyValues ** ytKeyValues_objP(ytObject * obj);
68void ytKeyValues_dump(ytKeyValues * this, FILE * fp);
69void ytKeyValues_setPR(ytObject * a, ytKeyValues * v);
70void ytKeyValues_add(ytKeyValues * this,
71 const char * key, ytObject * value);
72void ytKeyValues_add2(ytKeyValues * this,
73 char * key, ytObject * value);
74void ytKeyValues_addInt(ytKeyValues * this,
75 const char * key, int value);
76void ytKeyValues_addString(ytKeyValues * this,
77 const char * key, const char * value);
78void ytKeyValues_addIntArray(ytKeyValues * this,
79 const char * key, ytIntArray * value);
80void ytKeyValues_addDoubleArray(ytKeyValues * this,
81 const char * key, ytDoubleArray * value);
82void ytKeyValues_set(ytKeyValues * this, const char * key, ytObject * value);
83void ytKeyValues_setDelete(ytKeyValues * this, const char * key, ytObject * value);
84ytObject * ytKeyValues_get(const ytKeyValues * this, const char * key);
85int ytKeyValues_getInt(const ytKeyValues * this, const char * key, int def);
86double ytKeyValues_getDouble(const ytKeyValues * this, const char * key, double def);
87char * ytKeyValues_getString(const ytKeyValues * this, const char * key);
88ytIntArray * ytKeyValues_getIntArray(const ytKeyValues * this, const char * key);
89ytStrArray * ytKeyValues_getStrArray(const ytKeyValues * this, const char * key);
90ytObject * ytKeyValues_remove(ytKeyValues * this, const char * key);
91size_t ytKeyValues_size(const ytKeyValues * this);
92const char * ytKeyValues_getKey(const ytKeyValues * this, size_t index);
93ytObject * ytKeyValues_getValue(const ytKeyValues * this, size_t index);
94int ytKeyValues_getKeyIndex(const ytKeyValues * this, const char * key);
95ytKeyValues * ytKeyValues_parse(const char * str);
96ytStrArray * ytKeyValues_getKeys(const ytKeyValues * this, ytStrArray * ar);
97void ytKeyValues_print(const ytKeyValues * this, FILE * fp);
98void ytKeyValues_printI(const ytObject * this, FILE * fp);
99size_t ytKeyValues_memorySize(const ytKeyValues * this);
100ytByte * ytKeyValues_serialize(const ytKeyValues * this, ytByte ** pptr);
101ytKeyValues * ytKeyValues_deserialize(ytByte ** const pptr);
102ytByte * ytKeyValues_serializeI(const ytObject * obj, ytByte ** pptr);
103ytObject * ytKeyValues_deserializeI(ytByte ** const pptr);
104
105
106#define ytKV(str) ytKeyValues_parse(str)
107
108int ytKeyValues_test(int argc, char * argv[]);
109
110#ifdef USE_MPI
111#include <mpi.h>
112void ytKeyValues_MPI_Bcast(ytKeyValues ** pObject, int root, MPI_Comm comm);
113#endif /* USE_MPI */
114
115
116#endif /* __YTLIB_KEY_VALUES_H */
Expandable array.
Expandable array.
key-value pairs.
int * ytKeyValues_DEFAULT_VALUE_OFF
Value representing OFF.
Definition ytKeyValues.h:36
char * ytKeyValues_DEFAULT_KEY
Value representing the default key, that is, the key used for values without keys.
Definition ytKeyValues.h:24
int * ytKeyValues_DEFAULT_VALUE_ON
Value representing ON.
Definition ytKeyValues.h:32
char * ytKeyValues_ERROR_KEY
Value representing error key.
Definition ytKeyValues.h:28
char * ytKeyValues_DEFAULT_VALUE
Value used as a default value for no argument keys.
Definition ytKeyValues.h:19
The basis class.
Expandable array.