<?xml?>

<tm2>
  <typedef id="double" lang="c">
    <aqdb_type>AQDB_DataType_String</aqdb_type>
    <identifier>double</identifier>

    <codedefs>

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

      <codedef id="destruct">
        <code>
        </code>
      </codedef>

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

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

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

      <codedef id="toXml">
        <code>
          {
            char numbuf[64];
            
            snprintf(numbuf, sizeof(numbuf)-1, "%f", $(src));
            numbuf[sizeof(numbuf)-1]=0;
            GWEN_XMLNode_SetCharValue($(db), "$(name)", numbuf);
          }
        </code>
      </codedef>


      <codedef id="fromXml">
        <code>
          {
            const char *s;
            
            s=GWEN_XMLNode_GetCharValue($(db), "$(name)", NULL);
            if (s) {
              double v;
              
              if (sscanf(s, "%lf", &amp;v)==1)
                $(dst)=v;
              else
                $(dst)=$(default);
            }
            else
              $(dst)=$(default);
          }
        </code>
      </codedef>

      <codedef id="toDb">
        <code>
          {
            char numbuf[64];
            
            snprintf(numbuf, sizeof(numbuf)-1, "%f", $(src));
            numbuf[sizeof(numbuf)-1]=0;
            $(retval)=GWEN_DB_SetCharValue($(db), 
                                           GWEN_DB_FLAGS_OVERWRITE_VARS, 
                                           "$(name)", 
                                           numbuf);
          }
        </code>
      </codedef>



      <codedef id="fromDb">
        <code>
          {
            const char *s;
            
            s=GWEN_DB_GetCharValue($(db), "$(name)", 0, NULL);
            if (s) {
              double v;
              
              if (sscanf(s, "%lf", &amp;v)==1)
                $(dst)=v;
              else
                $(dst)=$(default);
            }
            else
              $(dst)=$(default);
          }
        </code>
      </codedef>



      <codedef id="toObject">
        <code>
          {
            $(retval)=AQDB_Object_SetFieldDouble($(db), $(fieldId), $(src));
          }
        </code>
      </codedef>



      <codedef id="fromObject">
        <code>
          {
            double v;
            
            $(retval)=AQDB_Object_GetFieldDouble($(db), $(fieldId), &amp;v);
            if ($(retval)&gt;=0)
              $(dst)=v;
          }
        </code>
      </codedef>



      <codedef id="toHashString">
        <code>
          {
            char numbuf[32];
            
            snprintf(numbuf, sizeof(numbuf)-1, "%f", $(src));
            numbuf[sizeof(numbuf)-1]=0;
            GWEN_Buffer_AppendString($(buffer), numbuf);
          }
        </code>
      </codedef>


    </codedefs>

    <defaults>
      <!-- defaults flags etc for member declarations of this type -->
      <default>0.0</default>
      <preset>0.0</preset>
    </defaults>
      
  </typedef>
</tm2>
