diff options
Diffstat (limited to 'vcal.c')
-rw-r--r-- | vcal.c | 102 |
1 files changed, 17 insertions, 85 deletions
@@ -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) { |