/**********************************************************
 * This file has been automatically created by "typemaker2"
 * from the file "tm_enum.xml".
 * Please do not edit this file, all changes will be lost.
 * Better edit the mentioned source file instead.
 **********************************************************/

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include "tm_enum_p.h"

#include <gwenhywfar/misc.h>
#include <gwenhywfar/debug.h>

/* code headers */

/* macro functions */
GWEN_LIST_FUNCTIONS(TYPEMAKER2_ENUM, Typemaker2_Enum)


TYPEMAKER2_ENUM *Typemaker2_Enum_new(void) {
  TYPEMAKER2_ENUM *p_struct;

  GWEN_NEW_OBJECT(TYPEMAKER2_ENUM, p_struct)
  GWEN_LIST_INIT(TYPEMAKER2_ENUM, p_struct)
  /* members */
  p_struct->id=NULL;
  p_struct->prefix=NULL;
  p_struct->type=NULL;
  p_struct->items=Typemaker2_Item_List_new();
  p_struct->toStringFn=NULL;
  p_struct->fromStringFn=NULL;
  /* virtual functions */

  return p_struct;
}

void Typemaker2_Enum_free(TYPEMAKER2_ENUM *p_struct) {
  if (p_struct) {
    GWEN_LIST_FINI(TYPEMAKER2_ENUM, p_struct)
  /* members */
    free(p_struct->id);
    free(p_struct->prefix);
    free(p_struct->type);
    Typemaker2_Item_List_free(p_struct->items);
    free(p_struct->toStringFn);
    free(p_struct->fromStringFn);
    GWEN_FREE_OBJECT(p_struct);
  }
}

TYPEMAKER2_ENUM *Typemaker2_Enum_dup(const TYPEMAKER2_ENUM *p_src) {
  TYPEMAKER2_ENUM *p_struct;

  assert(p_src);
  p_struct=Typemaker2_Enum_new();
  /* member "id" */
  if (p_struct->id) {
    free(p_struct->id);
    p_struct->id=NULL;
  }
  if (p_src->id) {
    p_struct->id=strdup(p_src->id);
  }

  /* member "prefix" */
  if (p_struct->prefix) {
    free(p_struct->prefix);
    p_struct->prefix=NULL;
  }
  if (p_src->prefix) {
    p_struct->prefix=strdup(p_src->prefix);
  }

  /* member "type" */
  if (p_struct->type) {
    free(p_struct->type);
    p_struct->type=NULL;
  }
  if (p_src->type) {
    p_struct->type=strdup(p_src->type);
  }

  /* member "items" */
  if (p_struct->items) {
    Typemaker2_Item_List_free(p_struct->items);
    p_struct->items=NULL;
  }
  if (p_src->items) {
    p_struct->items=Typemaker2_Item_List_dup(p_src->items);
  }

  /* member "toStringFn" */
  if (p_struct->toStringFn) {
    free(p_struct->toStringFn);
    p_struct->toStringFn=NULL;
  }
  if (p_src->toStringFn) {
    p_struct->toStringFn=strdup(p_src->toStringFn);
  }

  /* member "fromStringFn" */
  if (p_struct->fromStringFn) {
    free(p_struct->fromStringFn);
    p_struct->fromStringFn=NULL;
  }
  if (p_src->fromStringFn) {
    p_struct->fromStringFn=strdup(p_src->fromStringFn);
  }

  return p_struct;
}

TYPEMAKER2_ENUM *Typemaker2_Enum_copy(TYPEMAKER2_ENUM *p_struct, const TYPEMAKER2_ENUM *p_src) {
    assert(p_struct);
  assert(p_src);
  /* member "id" */
  if (p_struct->id) {
    free(p_struct->id);
    p_struct->id=NULL;
  }
  if (p_src->id) {
    p_struct->id=strdup(p_src->id);
  }

  /* member "prefix" */
  if (p_struct->prefix) {
    free(p_struct->prefix);
    p_struct->prefix=NULL;
  }
  if (p_src->prefix) {
    p_struct->prefix=strdup(p_src->prefix);
  }

  /* member "type" */
  if (p_struct->type) {
    free(p_struct->type);
    p_struct->type=NULL;
  }
  if (p_src->type) {
    p_struct->type=strdup(p_src->type);
  }

  /* member "items" */
  if (p_struct->items) {
    Typemaker2_Item_List_free(p_struct->items);
    p_struct->items=NULL;
  }
  if (p_src->items) {
    p_struct->items=Typemaker2_Item_List_dup(p_src->items);
  }

  /* member "toStringFn" */
  if (p_struct->toStringFn) {
    free(p_struct->toStringFn);
    p_struct->toStringFn=NULL;
  }
  if (p_src->toStringFn) {
    p_struct->toStringFn=strdup(p_src->toStringFn);
  }

  /* member "fromStringFn" */
  if (p_struct->fromStringFn) {
    free(p_struct->fromStringFn);
    p_struct->fromStringFn=NULL;
  }
  if (p_src->fromStringFn) {
    p_struct->fromStringFn=strdup(p_src->fromStringFn);
  }

  return p_struct;
}

const char *Typemaker2_Enum_GetId(const TYPEMAKER2_ENUM *p_struct) {
  assert(p_struct);
  return p_struct->id;
}

const char *Typemaker2_Enum_GetPrefix(const TYPEMAKER2_ENUM *p_struct) {
  assert(p_struct);
  return p_struct->prefix;
}

const char *Typemaker2_Enum_GetType(const TYPEMAKER2_ENUM *p_struct) {
  assert(p_struct);
  return p_struct->type;
}

TYPEMAKER2_ITEM_LIST *Typemaker2_Enum_GetItems(const TYPEMAKER2_ENUM *p_struct) {
  assert(p_struct);
  return p_struct->items;
}

const char *Typemaker2_Enum_GetToStringFn(const TYPEMAKER2_ENUM *p_struct) {
  assert(p_struct);
  return p_struct->toStringFn;
}

const char *Typemaker2_Enum_GetFromStringFn(const TYPEMAKER2_ENUM *p_struct) {
  assert(p_struct);
  return p_struct->fromStringFn;
}

void Typemaker2_Enum_SetId(TYPEMAKER2_ENUM *p_struct, const char *p_src) {
  assert(p_struct);
  if (p_struct->id) {
    free(p_struct->id);
  }
  if (p_src) {
    p_struct->id=strdup(p_src);
  }
  else {
    p_struct->id=NULL;
  }
}

void Typemaker2_Enum_SetPrefix(TYPEMAKER2_ENUM *p_struct, const char *p_src) {
  assert(p_struct);
  if (p_struct->prefix) {
    free(p_struct->prefix);
  }
  if (p_src) {
    p_struct->prefix=strdup(p_src);
  }
  else {
    p_struct->prefix=NULL;
  }
}

void Typemaker2_Enum_SetType(TYPEMAKER2_ENUM *p_struct, const char *p_src) {
  assert(p_struct);
  if (p_struct->type) {
    free(p_struct->type);
  }
  if (p_src) {
    p_struct->type=strdup(p_src);
  }
  else {
    p_struct->type=NULL;
  }
}

void Typemaker2_Enum_SetItems(TYPEMAKER2_ENUM *p_struct, const TYPEMAKER2_ITEM_LIST *p_src) {
  assert(p_struct);
  if (p_struct->items) {
    Typemaker2_Item_List_free(p_struct->items);
  }
  if (p_src) {
    p_struct->items=Typemaker2_Item_List_dup(p_src);
  }
  else {
    p_struct->items=Typemaker2_Item_List_new();
  }
}

void Typemaker2_Enum_SetToStringFn(TYPEMAKER2_ENUM *p_struct, const char *p_src) {
  assert(p_struct);
  if (p_struct->toStringFn) {
    free(p_struct->toStringFn);
  }
  if (p_src) {
    p_struct->toStringFn=strdup(p_src);
  }
  else {
    p_struct->toStringFn=NULL;
  }
}

void Typemaker2_Enum_SetFromStringFn(TYPEMAKER2_ENUM *p_struct, const char *p_src) {
  assert(p_struct);
  if (p_struct->fromStringFn) {
    free(p_struct->fromStringFn);
  }
  if (p_src) {
    p_struct->fromStringFn=strdup(p_src);
  }
  else {
    p_struct->fromStringFn=NULL;
  }
}

TYPEMAKER2_ENUM_LIST *Typemaker2_Enum_List_dup(const TYPEMAKER2_ENUM_LIST *p_src) {
  TYPEMAKER2_ENUM_LIST *p_dest;
  TYPEMAKER2_ENUM *p_elem;

  assert(p_src);
  p_dest=Typemaker2_Enum_List_new();
  p_elem=Typemaker2_Enum_List_First(p_src);
  while(p_elem) {
    TYPEMAKER2_ENUM *p_cpy;

    p_cpy=Typemaker2_Enum_dup(p_elem);
    Typemaker2_Enum_List_Add(p_cpy, p_dest);
    p_elem=Typemaker2_Enum_List_Next(p_elem);
  }

  return p_dest;
}

void Typemaker2_Enum_ReadXml(TYPEMAKER2_ENUM *p_struct, GWEN_XMLNODE *p_db) {
  assert(p_struct);
  /* member "id" */
  if (p_struct->id) {
    free(p_struct->id);
  }
  { const char *s; s=GWEN_XMLNode_GetProperty(p_db, "id", NULL); if (s) p_struct->id=strdup(s); }
  if (p_struct->id==NULL) {  /* member "id" is volatile, just presetting */
  p_struct->id=NULL;
  }

  /* member "prefix" */
  if (p_struct->prefix) {
    free(p_struct->prefix);
  }
  { const char *s; s=GWEN_XMLNode_GetProperty(p_db, "prefix", NULL); if (s) p_struct->prefix=strdup(s); }
  if (p_struct->prefix==NULL) {  /* member "prefix" is volatile, just presetting */
  p_struct->prefix=NULL;
  }

  /* member "type" */
  if (p_struct->type) {
    free(p_struct->type);
  }
  { const char *s; s=GWEN_XMLNode_GetProperty(p_db, "type", NULL); if (s) p_struct->type=strdup(s); }
  if (p_struct->type==NULL) {  /* member "type" is volatile, just presetting */
  p_struct->type=NULL;
  }

  /* member "items" */
  if (p_struct->items) {
    Typemaker2_Item_List_free(p_struct->items);
  }
  /* member "items" is volatile, just presetting */
  p_struct->items=Typemaker2_Item_List_new();

  /* member "toStringFn" */
  if (p_struct->toStringFn) {
    free(p_struct->toStringFn);
  }
  /* member "toStringFn" is volatile, just presetting */
  p_struct->toStringFn=NULL;

  /* member "fromStringFn" */
  if (p_struct->fromStringFn) {
    free(p_struct->fromStringFn);
  }
  /* member "fromStringFn" is volatile, just presetting */
  p_struct->fromStringFn=NULL;

}

void Typemaker2_Enum_WriteXml(const TYPEMAKER2_ENUM *p_struct, GWEN_XMLNODE *p_db) {
  assert(p_struct);
  /* member "id" */
  GWEN_XMLNode_SetProperty(p_db, "id", p_struct->id);

  /* member "prefix" */
  GWEN_XMLNode_SetProperty(p_db, "prefix", p_struct->prefix);

  /* member "type" */
  GWEN_XMLNode_SetProperty(p_db, "type", p_struct->type);

  /* member "items" is volatile, not writing to xml */

  /* member "toStringFn" is volatile, not writing to xml */

  /* member "fromStringFn" is volatile, not writing to xml */

}

void Typemaker2_Enum_toXml(const TYPEMAKER2_ENUM *p_struct, GWEN_XMLNODE *p_db) {
  Typemaker2_Enum_WriteXml(p_struct, p_db);
}

TYPEMAKER2_ENUM *Typemaker2_Enum_fromXml(GWEN_XMLNODE *p_db) {
  TYPEMAKER2_ENUM *p_struct;
  p_struct=Typemaker2_Enum_new();
  Typemaker2_Enum_ReadXml(p_struct, p_db);
  return p_struct;
}


/* code headers */

