<?xml?>

<tm2>

  <typedef id="gwen_date" type="pointer" lang="c" >
    <identifier>GWEN_DATE</identifier>
    <aqdb_type>AQDB_DataType_Date</aqdb_type>


    <codedefs>

      <codedef id="construct">
        <code>
          $(dst)=$(preset);
        </code>
      </codedef>

      <codedef id="destruct">
        <code>
          GWEN_Date_free($(src));
          $(src)=NULL;
        </code>
      </codedef>

      <codedef id="assign">
        <code>
          $(dst)=$(src);
        </code>
      </codedef>

      <codedef id="dup">
        <code>
        $(dst)=GWEN_Date_dup($(src));
        </code>
      </codedef>

      <codedef id="compare">
        <code>
          if ($(dst) &amp;&amp; $(src))
            $(retval)=GWEN_Date_Compare($(src), $(dst));
          else if ($(src))
            $(retval)=1;
          else if ($(dst))
            $(retval)=-1;
          else
            $(retval)=0;
        </code>
      </codedef>

      <codedef id="toXml">
        <!-- !attribute -->
        <memberFlagsMask>  attribute</memberFlagsMask>
        <memberFlagsValue>          </memberFlagsValue>
        <code>
          if ($(src)){
            const char *s=GWEN_Date_GetString($(src));
            GWEN_XMLNode_SetCharValue($(db), "$(name)", s);
          }
        </code>
      </codedef>

      <codedef id="toXml">
        <!-- attribute -->
        <memberFlagsMask>  attribute</memberFlagsMask>
        <memberFlagsValue> attribute</memberFlagsValue>
        <code>
          if ($(src)){
            const char *s=GWEN_Date_GetString($(src));
            GWEN_XMLNode_SetProperty($(db), "$(name)", s);
          }
        </code>
      </codedef>

      <codedef id="fromXml">
        <!-- !attribute -->
        <memberFlagsMask>  attribute</memberFlagsMask>
        <memberFlagsValue>          </memberFlagsValue>
        <code>
          {
            const char *s;
            
            s=GWEN_XMLNode_GetCharValue($(db), "$(name)", NULL);
            if (s && *s)
              $(dst)=GWEN_Date_fromString(s);
          }
        </code>
      </codedef>

      <codedef id="fromXml">
        <!-- enum | attribute -->
        <memberFlagsMask>  attribute</memberFlagsMask>
        <memberFlagsValue> attribute</memberFlagsValue>
        <code>
          {
            const char *s;
            
            s=GWEN_XMLNode_GetProperty($(db), "$(name)", NULL);
            if (s && *s)
              $(dst)=GWEN_Date_fromString(s);
          }
        </code>
      </codedef>



      <codedef id="toDb">
        <code>
          if ($(src)){
            const char *s=GWEN_Date_GetString($(src));
            $(retval)=GWEN_DB_SetCharValue($(db), GWEN_DB_FLAGS_OVERWRITE_VARS, "$(name)", s);
          }
          else {
            GWEN_DB_DeleteVar($(db), "$(name)");
            $(retval)=0;
          }
        </code>
      </codedef>



      <codedef id="fromDb">
        <code>
          {
            const char *s;
            
            s=GWEN_DB_GetCharValue($(db), "$(name)", 0, NULL);
            if (s && *s)
              $(dst)=GWEN_Date_fromString(s);
          }
        </code>
      </codedef>



      <codedef id="toObject">
        <code>
          if ($(src)){
            const char *s=GWEN_Date_GetString($(src));
            $(retval)=AQDB_Object_SetFieldString($(db), $(fieldid), s);
          }
          else {
            $(retval)=AQDB_Object_SetFieldString($(db), $(fieldid), NULL);
          }
        </code>
      </codedef>



      <codedef id="fromObject">
        <code>
          {
            const char *s;
            
            $(retval)=AQDB_Object_GetFieldString($(db), $(fieldid), &s);
            if ($(retval)&gt;=0 && s && *s) {
              $(dst)=GWEN_Date_fromString(s);
              if ($(dst)==NULL)
                $(retval)=GWEN_ERROR_BAD_DATA;
            }
            else
              $(retval)=0;
          }
        </code>
      </codedef>



      <codedef id="toHashString">
        <code>
          if ($(src))
            GWEN_Buffer_AppendString($(buffer), GWEN_Date_GetString($(src)));
        </code>
      </codedef>

    </codedefs>



    <defaults>
      <!-- defaults flags etc for member declarations of this type -->
      <default>NULL</default>
      <preset>NULL</preset>
      <setflags>const dup</setflags>
      <getflags>const</getflags>
      <dupflags>const</dupflags>
    </defaults>
  
  </typedef>

</tm2>
