Sophie

Sophie

distrib > Mandriva > 9.2 > i586 > by-pkgid > 0453bcaf7bb5ad036996f9b24ca9fa16 > files > 131

gaby-2.0.2-4mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML
><HEAD
><TITLE
>Structures</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Gaby's documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="Functions and structures"
HREF="c517.html"><LINK
REL="PREVIOUS"
TITLE="Functions and structures"
HREF="c517.html"><LINK
REL="NEXT"
TITLE="Views"
HREF="c679.html"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Gaby's documentation</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="c517.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 8. Functions and structures</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="c679.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="AEN570"
>8.2. Structures</A
></H1
><P
>They are defined in <TT
CLASS="FILENAME"
>src/struct.h</TT
>.</P
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN574"
>8.2.1. Basic structures</A
></H2
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN576"
>8.2.1.1. data</A
></H3
><P
>The first basic structure is not a structure, it is an
<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>union</I
></SPAN
> defined as :

<PRE
CLASS="PROGRAMLISTING"
>union data {
        GString *str;
        int i;
        float d;
        GDate *date;
        gboolean b;
        gpointer anything;
};</PRE
></P
><P
>Its main purpose is to hold different fields 'data.</P
><P
><SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>FIXME</I
></SPAN
> : write a table with field types (T_*) and
corresponding field in union data</P
></DIV
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN584"
>8.2.1.2. record</A
></H3
><PRE
CLASS="PROGRAMLISTING"
>typedef struct _record          record;

struct _record {
        int id;
        union data *cont;
        struct location *file_loc;
};</PRE
><P
><P
></P
><UL
><LI
><P
><CODE
CLASS="STRUCTFIELD"
>id</CODE
> is the id of the record (each record has a
different id, 0 means that the record is unavailable (deleted, ...)).</P
></LI
><LI
><P
><CODE
CLASS="STRUCTFIELD"
>cont</CODE
> is an array holding the different's field
(therefore it has a size = number of field in the table)</P
></LI
><LI
><P
><CODE
CLASS="STRUCTFIELD"
>file_loc</CODE
> is used in file operations (loading/saving)</P
></LI
></UL
></P
></DIV
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN598"
>8.2.1.3. table</A
></H3
><PRE
CLASS="PROGRAMLISTING"
>struct _table {
        gchar *name;
        char short_name[5];
        field *fields;
        int nb_fields;
        record **records;
        GList **indexes;
        int max_records;
        GList *locations;
};</PRE
><P
><P
></P
><UL
><LI
><P
><CODE
CLASS="STRUCTFIELD"
>name</CODE
> and <CODE
CLASS="STRUCTFIELD"
>short_name</CODE
> are
the name (and its short version) of the table </P
></LI
><LI
><P
><CODE
CLASS="STRUCTFIELD"
>fields</CODE
> is an array of size
<CODE
CLASS="STRUCTFIELD"
>nb_fields</CODE
> filled with <CODE
CLASS="STRUCTNAME"
>field</CODE
>
structures (see below).</P
></LI
><LI
><P
><CODE
CLASS="STRUCTFIELD"
>records</CODE
> is an array of pointer to
<CODE
CLASS="STRUCTNAME"
>record</CODE
> structures, the highest array position is given
by <CODE
CLASS="STRUCTFIELD"
>max_records</CODE
> but there may be NULL pointers in
this array (as well as records where id equals 0)</P
></LI
><LI
><P
><CODE
CLASS="STRUCTFIELD"
>indexes</CODE
> and <CODE
CLASS="STRUCTFIELD"
>locations</CODE
>
shouldn't be used in plug-ins</P
></LI
></UL
></P
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN621"
>8.2.1.1. field</A
></H3
><PRE
CLASS="PROGRAMLISTING"
>struct _field {
        gchar *name;
        gchar *i18n_name;
        field_type type;
        property **properties;
        GList *ok_if;

};</PRE
><P
><P
></P
><UL
><LI
><P
><CODE
CLASS="STRUCTFIELD"
>name</CODE
> and <CODE
CLASS="STRUCTFIELD"
>i18n_name</CODE
> hold
the name (and its translation in the user favorite language) of the field</P
></LI
><LI
><P
><CODE
CLASS="STRUCTFIELD"
>type</CODE
> holds the type of the field; given by 
<PRE
CLASS="PROGRAMLISTING"
>enum _field_type {
        T_STRING  = 0,
        T_STRINGS = 1,
        T_INTEGER = 2,
        T_REAL    = 3,
        T_DATE    = 4,
        T_BOOLEAN = 5,
        T_RECORD  = 6,
        T_RECORDS = 7,
        T_MULTIMEDIA = 8
};</PRE
></P
></LI
><LI
><P
><CODE
CLASS="STRUCTFIELD"
>properties</CODE
> and <CODE
CLASS="STRUCTFIELD"
>ok_if</CODE
>
aren't useful :)</P
></LI
></UL
></P
></DIV
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN638"
>8.2.1.2. subtable</A
></H3
><PRE
CLASS="PROGRAMLISTING"
>struct _subtable {
        gchar *name;
        gchar *i18n_name;
        table *table;
        st_field *fields;
        int nb_fields;
        condition *cond;
};</PRE
><P
><P
></P
><UL
><LI
><P
><CODE
CLASS="STRUCTFIELD"
>name</CODE
> and <CODE
CLASS="STRUCTFIELD"
>i18n_name</CODE
> have
the same meaning as for fields</P
></LI
><LI
><P
><CODE
CLASS="STRUCTFIELD"
>table</CODE
> holds the table from which the subtable is
derived</P
></LI
><LI
><P
><CODE
CLASS="STRUCTFIELD"
>fields</CODE
> holds an array (of size
<CODE
CLASS="STRUCTFIELD"
>nb_fields</CODE
>) filled with
<CODE
CLASS="STRUCTNAME"
>st_field</CODE
> (see below).</P
></LI
><LI
><P
><CODE
CLASS="STRUCTFIELD"
>cond</CODE
> isn't really for you</P
></LI
></UL
></P
></DIV
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN658"
>8.2.1.3. st_field</A
></H3
><PRE
CLASS="PROGRAMLISTING"
>struct _st_field {
        gchar *name;
        gchar *i18n_name;
        int no;
        field_type type;
        GList *link_format;
        view *v;

};</PRE
><P
><P
></P
><UL
><LI
><P
><CODE
CLASS="STRUCTFIELD"
>name</CODE
> and <CODE
CLASS="STRUCTFIELD"
>i18n_name</CODE
> have
their usual meaning</P
></LI
><LI
><P
><CODE
CLASS="STRUCTFIELD"
>no</CODE
> holds the index of the field of the table that
this field is derived from (is this clear ?). It may be -1 if
<CODE
CLASS="STRUCTFIELD"
>type</CODE
> is T_RECORDS</P
></LI
><LI
><P
><CODE
CLASS="STRUCTFIELD"
>type</CODE
> has the same meaning as in
<CODE
CLASS="STRUCTNAME"
>field</CODE
> with the extra value T_RECORDS.</P
></LI
><LI
><P
><CODE
CLASS="STRUCTFIELD"
>link_format</CODE
> and <CODE
CLASS="STRUCTFIELD"
>v</CODE
> are
used for relations between tables and you don't need to know anything about
them</P
></LI
></UL
></P
></DIV
></DIV
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="c517.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="c679.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Functions and structures</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="c517.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Views</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>