aboutsummaryrefslogtreecommitdiff
path: root/vcal.c
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@hornquist.se>2019-02-22 14:39:34 +0100
committerHugo Hörnquist <hugo@hornquist.se>2019-02-22 14:39:34 +0100
commita608b90f8c146430803871e20d043b60a278248b (patch)
tree194e6e80cd5403cc64d1e4915f9be45a462d3918 /vcal.c
parentstrbuf (diff)
downloadcalp-a608b90f8c146430803871e20d043b60a278248b.tar.gz
calp-a608b90f8c146430803871e20d043b60a278248b.tar.xz
rest
Diffstat (limited to 'vcal.c')
-rw-r--r--vcal.c102
1 files changed, 17 insertions, 85 deletions
diff --git a/vcal.c b/vcal.c
index d0bc6626..4399a821 100644
--- a/vcal.c
+++ b/vcal.c
@@ -2,90 +2,22 @@
#include <string.h>
-// #define TYPE strbuf
-// #include "linked_list.inc.h"
-// #undef TYPE
-//
-// #define TYPE param_set
-// #include "linked_list.inc.h"
-// #undef TYPE
-//
-// #define TYPE content_set
-// #include "linked_list.inc.h"
-// #undef TYPE
+// INIT_F(vcomponent, const char* type, const char* filename) {
+vcomponent::vcomponent (const char* type, const char* filename) {
-#if 0
-#define T strbuf
- #define V LLIST(strbuf)
- #include "pair.inc.h"
- #undef V
- #define V LLIST(param_set)
- #include "pair.inc.h"
- #undef V
- #define V LLIST(content_set)
- #include "pair.inc.h"
- #undef V
-#undef T
-#endif
-
-// #define TYPE content_line
-// // #include "hash.inc"
-// #include "trie.inc.h"
-// #undef TYPE
-
-#define TYPE vcomponent
-#include "vector.inc.h"
-#undef TYPE
-
-INIT_F(vcomponent) {
- (void) self;
- ERR("Do not use");
- return 0;
-}
-
-INIT_F(vcomponent, const char* type) {
- return INIT(vcomponent, self, type, NULL);
-}
-
-INIT_F(vcomponent, const char* type, const char* filename) {
-
- // INIT(TRIE(content_line), &self->clines);
- INIT(VECT(vcomponent), &self->components);
+ // INIT(TRIE(content_line), &this->clines);
+ // INIT(VECT(vcomponent), &this->components);
- self->filename = NULL;
+ this->filename = NULL;
if (filename != NULL) {
- self->filename = (char*) calloc(sizeof(*filename), strlen(filename) + 1);
- strcpy(self->filename, filename);
+ this->filename = (char*) calloc(sizeof(*filename), strlen(filename) + 1);
+ strcpy(this->filename, filename);
}
- self->type = (char*) calloc(sizeof(*type), strlen(type) + 1);
- strcpy(self->type, type);
+ this->type = (char*) calloc(sizeof(*type), strlen(type) + 1);
+ strcpy(this->type, type);
- self->parent = NULL;
-
- return 0;
-}
-
-content_line* RESOLVE(content_line)
- (content_line* dest, content_line* new_)
-{
- if (dest == NULL) return new_;
-
- if (strbuf_cmp(dest->key, new_->key) != 0) {
- ERR("Can't resolve between these two types");
- return NULL;
- }
-
- /* This destroys new_->val. */
- // APPEND(LLIST(content_set)) (&dest->val, &new_->val);
- dest->val->append(new_->val);
-
- // FREE(strbuf)(&new_->key);
- // delete new_->key;
- delete new_;
- // free(new_);
-
- return dest;
+ this->parent = NULL;
}
content_line* get_property (vcomponent* ev, const char* key) {
@@ -100,22 +32,22 @@ content_line* get_property (vcomponent* ev, const char* key) {
return ret;
}
-FREE_F(vcomponent) {
- if (self->filename != NULL) free(self->filename);
- free(self->type);
+// FREE_F(vcomponent) {
+vcomponent::~vcomponent () {
+ if (this->filename != NULL) free(this->filename);
+ free(this->type);
// if (FREE(TRIE(content_line))(&self->clines) != 0) {
// fprintf(stderr, "Error freeing vcomponent belonging to file \n %s \n",
// self->filename);
// }
- FREE(VECT(vcomponent))(&self->components);
-
- return 0;
+ // FREE(VECT(vcomponent))(&self->components);
}
int PUSH(vcomponent)(vcomponent* parent, vcomponent* child) {
- return PUSH(VECT(vcomponent))(&parent->components, child);
+ // return PUSH(VECT(vcomponent))(&parent->components, child);
+ return parent->components.push(child);
}
int DEEP_COPY(vcomponent)(vcomponent* a, vcomponent* b) {