db_row_t.xml 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
  4. <section id="db_row_t" xmlns:xi="http://www.w3.org/2001/XInclude">
  5. <sectioninfo>
  6. <revhistory>
  7. <revision>
  8. <revnumber>$Revision$</revnumber>
  9. <date>$Date$</date>
  10. </revision>
  11. </revhistory>
  12. </sectioninfo>
  13. <title>Type <type>db_row_t</type></title>
  14. <para>
  15. This type represents one row in a database table. In other words, the
  16. row is an array of <type>db_val_t</type> variables, where each
  17. <type>db_val_t</type> variable represents exactly one cell in the
  18. table.
  19. </para>
  20. <programlisting>
  21. typedef struct db_row {
  22. db_val_t* values; /* Array of values in the row */
  23. int n; /* Number of values in the row */
  24. } db_val_t;
  25. </programlisting>
  26. <itemizedlist>
  27. <listitem>
  28. <para>
  29. <function>ROW_VALUES(row)</function> Macro.
  30. </para>
  31. <para>
  32. Use this macro to get pointer to array of <type>db_val_t</type>
  33. structures.
  34. </para>
  35. <example>
  36. <title>ROW_VALUES Macro</title>
  37. <programlisting>
  38. ...
  39. db_val_t* v = ROW_VALUES(row);
  40. if (VAL_TYPE(v) == DB_INT)
  41. ...
  42. </programlisting>
  43. </example>
  44. </listitem>
  45. <listitem>
  46. <para>
  47. <function>ROW_N(row)</function> Macro.
  48. </para>
  49. <para>
  50. Use this macro to get number of cells in a row.
  51. </para>
  52. <example>
  53. <title>ROW_N Macro</title>
  54. <programlisting>
  55. <![CDATA[
  56. ...
  57. db_val_t* val = ROW_VALUES(row);
  58. for(i = 0; i < ROW_N(row); i++) {
  59. switch(VAL_TYPE(val + i)) {
  60. case DB_INT: ...; break;
  61. case DB_DOUBLE: ...; break;
  62. ...
  63. }
  64. }
  65. ...
  66. ]]>
  67. </programlisting>
  68. </example>
  69. </listitem>
  70. </itemizedlist>
  71. </section>