<?xml?>
<!-- not yet finished -->

<tm2>

  <typedef id="gwen_timestamp" type="pointer" lang="c" >
    <identifier>GWEN_TIMESTAMP</identifier>
    <aqdb_type>AQDB_DataType_Int</aqdb_type>


    <codedefs>

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

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

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

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

      <codedef id="compare">
        <code>
          if ($(dst) &amp;&amp; $(src))
            $(retval)=GWEN_Timestamp_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_Timestamp_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_Timestamp_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_Timestamp_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_Timestamp_fromString(s);
          }
        </code>
      </codedef>



      <codedef id="toDb">
        <code>
          if ($(src)){
            const char *s=GWEN_Timestamp_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_Timestamp_fromString(s);
          }
        </code>
      </codedef>



      <codedef id="toObject">
        <code>
          if ($(src)){
            int64_t v;
            
            v=GWEN_Timestamp_toInt64($(src));
            $(retval)=AQDB_Object_SetFieldInt64($(db), $(fieldid), v);
          }
          else {
            $(retval)=AQDB_Object_SetFieldInt64($(db), $(fieldid), 0);
          }
        </code>
      </codedef>



      <codedef id="fromObject">
        <code>
          {
            int64_t v=0;
            
            $(retval)=AQDB_Object_GetFieldInt64($(db), $(fieldid), &v);
            if ($(retval)&gt;=0 && v>0) {
              $(dst)=GWEN_Timestamp_fromInt64(v);
              if ($(dst)==NULL)
                $(retval)=GWEN_ERROR_BAD_DATA;
            }
            else
              $(retval)=0;
          }
        </code>
      </codedef>



      <codedef id="toHashString">
        <code>
          if ($(src))
            GWEN_Buffer_AppendString($(buffer), GWEN_Timestamp_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>
