summaryrefslogtreecommitdiffstats
path: root/xsd2c/Enumeration.c
diff options
context:
space:
mode:
Diffstat (limited to 'xsd2c/Enumeration.c')
-rwxr-xr-xxsd2c/Enumeration.c121
1 files changed, 121 insertions, 0 deletions
diff --git a/xsd2c/Enumeration.c b/xsd2c/Enumeration.c
new file mode 100755
index 0000000..e795206
--- /dev/null
+++ b/xsd2c/Enumeration.c
@@ -0,0 +1,121 @@
+/** Generated by xsd2c */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "Enumeration.h"
+
+
+struct Enumeration* Enumeration_Create()
+{
+ struct Enumeration* _res;
+ _res = (struct Enumeration*)malloc(sizeof(struct Enumeration));
+
+ _res->value_head = NULL;
+ _res->value_tail = NULL;
+
+ return _res;
+}
+
+void Enumeration_Free(struct Enumeration* obj)
+{
+ struct Enumeration_value_List* value_cur;
+ struct Enumeration_value_List* value_tmp;
+ if (obj == NULL) return;
+
+ value_cur = obj->value_head;
+ while (value_cur != NULL)
+ {
+ if (value_cur->value) free(value_cur->value);
+ value_tmp = value_cur->next;
+ free(value_cur);
+ value_cur = value_tmp;
+ }
+ free(obj);
+}
+
+void Enumeration_Sax_Serialize(struct Enumeration* obj,
+ const char *root_element_name,
+ void (*OnStartElement)(const char* element_name, int attr_count, char **keys, char **values, void* userData),
+ void (*OnCharacters)(const char* element_name, const char* chars, void* userData),
+ void (*OnEndElement)(const char* element_name, void* userData),
+ void* userData)
+{
+ int attrCount, curCount;
+ char **keys;
+ char **values;
+ char buffer[255];
+
+ struct Enumeration_value_List* value_cur;
+
+ attrCount = 0;
+
+ keys = (char**)malloc(sizeof(char*)*attrCount);
+ values = (char**)malloc(sizeof(char*)*attrCount);
+
+ curCount = 0;
+
+
+ OnStartElement(root_element_name, attrCount, keys, values, userData);
+ value_cur = obj->value_head;
+ while (value_cur != NULL)
+ {
+
+ OnStartElement("value", 0, NULL, NULL, userData);
+ if (value_cur->value != NULL)
+ OnCharacters("value", value_cur->value, userData);
+ OnEndElement("value", userData);
+ value_cur = value_cur->next;
+ }
+
+ OnEndElement(root_element_name, userData);
+}
+
+#ifndef _DESERIALIZER_DISABLED_
+
+struct Enumeration* Enumeration_Deserialize(xmlNodePtr xmlRoot)
+{
+ xmlNodePtr cur;
+ xmlChar *key;
+ struct Enumeration* obj;
+ obj = Enumeration_Create();
+ cur = xmlRoot->xmlChildrenNode;
+ while (cur != NULL) {
+ if (cur->type != XML_ELEMENT_NODE) {
+ cur = cur->next;
+ continue;
+ }
+ if ((!xmlStrcmp(cur->name, (const xmlChar *)"value"))){
+ key = xmlNodeListGetString(cur->doc, cur->xmlChildrenNode, 1);
+ Enumeration_Add_value(obj, (const char*)key);
+/* xmlFree(key);*/
+ }
+ // TODO:
+ cur = cur->next;
+ }
+ return obj;
+}
+
+#endif
+struct Enumeration_value_List* Enumeration_Get_value(struct Enumeration* obj)
+{
+ return obj->value_head;
+}
+
+void Enumeration_Add_value(struct Enumeration* obj, const char* value)
+{
+ struct Enumeration_value_List* value_node;
+ value_node = (struct Enumeration_value_List*)malloc(sizeof(struct Enumeration_value_List));
+ value_node->value = (char*)malloc(strlen(value)+1);
+ strcpy(value_node->value, value);
+ value_node->next = NULL;
+ if (obj->value_tail)
+ {
+ obj->value_tail->next = value_node;
+ }
+ if (obj->value_head == NULL)
+ {
+ obj->value_head = value_node;
+ }
+ obj->value_tail = value_node;
+}
+