#ifndef _CLASSES #define _CLASSES #include #include //Class definitions for implementation of the SGML track and components /* Data Structure Ideas: #1. We are considering the simple structure of attributed grammars #2. Considering no cross or back referencing #3. Every element has a production list, each of the productions being a concatenation list of elements #4. Every element has a list of attributes #5. At this point, considering all attributes to be static, can be made inherited or synthesized at a later point. #6. Every element has a _name, and a _value. #7. A flag to denote single A or multiple (*)/+ */ /* Query processing ideas: #1. At an element level, a query can only have a form: returnlist(element_name, value) This returns a list of elements at and below the element on which it was called, satisfying the property element._value() = value and element._name() = element_name #2. At this point, we are assuming that the queries involved can be solved using the returnlist function. In order to do this, we need to have a parallel structure with the grammar stored, which would transform a generic query to a series of (or a combination of) returnlist statements. */ class Attribute; class Element_list; extern int pass_no; class Element { public: Element(); // Constructor Element(char *elem_name, char *elem_val); ~Element() {} // Destructor // Structure-based methods // methods to get and set the name char * get_elem_name() {return element_name;} void set_elem_name(char *new_name); // methods to get and set the value char * get_elem_value(){return element_value;} void set_elem_value(char *new_value); // LIST OF CHILDREN ELEMENTS Element *snoc_child(Element *child); // adds a child at the end of the child list Element *car_child(){return child_list;} // first child and subsequent childs Element *cdr_child(){return child_list->get_next_sibling();} Element *get_parent(){return parent;} void set_parent(Element *name) {parent = name;} Element *get_next_sibling(){return next_sibling;}// gets and sets next element void set_next_sibling (Element *new_elem) {next_sibling = new_elem;} // SET OF ATTRIBUTES Attribute *add_attrib(Attribute *new_attrib); void set_attribs(Attribute *att_set){attribute_set = att_set;} Attribute *get_attribs(){return attribute_set;} // Value-based methods Element_list *return_elem_list(char *elem_name, char *elem_value, Element_list *result); Element_list *return_parent_list(char *par_name, char *par_value, Element_list *result); Element_list *return_elem_att(char *att_name, char *att_value, Element_list *result); char *return_attr_value(char *attr_name); void Print(); // Methods to get the pass in which the element was included int get_pass() {return curr_pass;} void set_pass(int pno) {curr_pass = pno;} private: char * element_name; char * element_value; int curr_pass; Element *next_sibling; Attribute* attribute_set; Element* child_list; Element* last_child; //since sibling list (forest) is not implemented Element* parent; }; class Attribute { public: Attribute(); Attribute(char *attr_name, char * attr_val); char *get_attr_name() {return attribute_name;} void set_attr_name(char *attr_name) {attribute_name = attr_name;} char *get_attr_value() {return attribute_value;} void set_attr_value(char *attr_value) {attribute_value = attr_value;} char *get_attr_type() {return attribute_type;} void set_attr_type(char *attr_type) {attribute_type = attr_type;} Attribute *get_next_attribute() {return next_attribute;} void set_next_attribute(Attribute *next_attrib) {next_attribute = next_attrib;} void Print(); private: char * attribute_name; char * attribute_value; char * attribute_type; Attribute *next_attribute; }; class Element_list { public: Element_list(); Element_list(Element *element); ~Element_list() {}; Element *car() {return car_element;} Element_list *cdr() {return cdr_elements;} Element_list *snoc(Element *element); Element_list *combine(Element_list *other); Element_list *map(char *name, char *value, Element_list *result, int func_type); Element_list *last_element() { if (car() == NULL) return NULL; else { if (cdr() == NULL) return this; else return cdr()->last_element(); } } void set_car(Element *element) {car_element = element;} void set_cdr(Element_list *list) {cdr_elements = list;} void Print(); private: Element *car_element; Element_list *cdr_elements; }; #endif