diff options
author | Hugo Hörnquist <hugo@hornquist.se> | 2019-02-11 01:34:40 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2019-02-15 20:03:43 +0100 |
commit | 60c7d789ce21cb77bdf9dd2c8cb22e86232d903f (patch) | |
tree | 45a2995340c1f2c2891369eb3ec5e2c6aae7b87c /vcal.h | |
parent | Replace key_val type with templatized PAIR(T, V). (diff) | |
download | calp-60c7d789ce21cb77bdf9dd2c8cb22e86232d903f.tar.gz calp-60c7d789ce21cb77bdf9dd2c8cb22e86232d903f.tar.xz |
Rewrote content_line, and how parameters are stored.
Diffstat (limited to 'vcal.h')
-rw-r--r-- | vcal.h | 59 |
1 files changed, 45 insertions, 14 deletions
@@ -11,28 +11,60 @@ #undef TYPE #define T strbuf -#define V strbuf -#include "pair.h" + #define V LLIST(strbuf) + #include "pair.h" + /* left := param_name | right := param_values */ + #define param_set PAIR(strbuf, LLIST(strbuf)) + #undef V #undef T -#undef V -#define TYPE PAIR(strbuf, strbuf) +#define TYPE param_set #include "linked_list.h" #undef TYPE -typedef struct { - strbuf key; +#define T strbuf + #define V LLIST(param_set) + #include "pair.h" + /* left := content | right := params */ + #define content_set PAIR(strbuf, LLIST(param_set)) + #undef V +#undef T + +#define TYPE content_set +#include "linked_list.h" +#undef TYPE + +#define T strbuf + #define V LLIST(content_set) + #include "pair.h" + /* left := content | right := params */ + #define content_line PAIR(strbuf, LLIST(content_set)) + #undef V +#undef T + +/* + * Helper macros for accessing fields in + * content_line, content_set, and param_set + * + * TODO find a better way to do this. + */ - LLIST(strbuf) vals; +/* ptr -> ptr */ +#define CLINE_KEY(c) (&(c)->key) +#define CLINE_CUR_CSET(c) (&((c)->val.cur->value)) - LLIST(PAIR(strbuf, strbuf)) params; -} content_line; +/* content_set */ +#define CLINE_CUR(c) ((c)->val.cur->value) +/* strbuf */ +#define CLINE_CUR_VAL(c) (& CLINE_CUR(c)->key) -INIT_F(content_line); -INIT_F(content_line, int keylen, int vallen); -FREE_F(content_line); +/* LLIST(param_set) */ +#define CLINE_CUR_PARAMS(c) (& CLINE_CUR(c)->val) -int content_line_copy (content_line* dest, content_line* src); +/* strbuf */ +#define CLINE_CUR_PARAM_KEY(c) (CLINE_CUR_PARAMS(c)->cur->value->key) +/* strbuf */ +#define CLINE_CUR_PARAM_VAL(c) (CLINE_CUR_PARAMS(c)->cur->value->val.cur->value) /* * Resolves a collision in some form of structure (probably a hash-map @@ -80,7 +112,6 @@ int PUSH(vcomponent)(vcomponent*, vcomponent*); int DEEP_COPY(vcomponent)(vcomponent*, vcomponent*); -FMT_F(content_line); FMT_F(vcomponent); #endif /* VCAL_H */ |