# GdaXmlDatabase

## Name

GdaXmlDatabase -- XML database representation (used for import/export and in the default provider)

## Synopsis

    struct      GdaXmlDatabasePrivate;
    GdaXmlDatabase* gda_xml_database_new        (void);
    GdaXmlDatabase* gda_xml_database_new_from_uri
                                                (const gchar *uri);
    const gchar* gda_xml_database_get_name      (GdaXmlDatabase *xmldb);
    void        gda_xml_database_set_name       (GdaXmlDatabase *xmldb,
                                                 const gchar *name);
    const gchar* gda_xml_database_get_uri       (GdaXmlDatabase *xmldb);
    void        gda_xml_database_set_uri        (GdaXmlDatabase *xmldb,
                                                 const gchar *uri);
    void        gda_xml_database_changed        (GdaXmlDatabase *xmldb);
    void        gda_xml_database_reload         (GdaXmlDatabase *xmldb);
    gboolean    gda_xml_database_save           (GdaXmlDatabase *xmldb,
                                                 const gchar *uri);
    gchar*      gda_xml_database_to_string      (GdaXmlDatabase *xmldb);
    GList*      gda_xml_database_get_tables     (GdaXmlDatabase *xmldb);
    void        gda_xml_database_free_table_list
                                                (GList *list);
    GdaTable*   gda_xml_database_find_table     (GdaXmlDatabase *xmldb,
                                                 const gchar *name);
    GdaTable*   gda_xml_database_new_table      (GdaXmlDatabase *xmldb,
                                                 const gchar *name);
    GdaTable*   gda_xml_database_new_table_from_model
                                                (GdaXmlDatabase *xmldb,
                                                 const gchar *name,
                                                 const GdaDataModel *model,
                                                 gboolean add_data);
    GdaTable*   gda_xml_database_new_table_from_node
                                                (GdaXmlDatabase *xmldb,
                                                 xmlNodePtr xmlnode);

## Description

## Details

### struct GdaXmlDatabasePrivate

    struct GdaXmlDatabasePrivate;

### gda_xml_database_new ()

    GdaXmlDatabase* gda_xml_database_new        (void);

Creates a new GdaXmlDatabase object, which can be used to describe a database which will then be loaded by a provider to create its defined structure

Returns : |

### gda_xml_database_new_from_uri ()

    GdaXmlDatabase* gda_xml_database_new_from_uri
                                                (const gchar *uri);

`uri` : |
Returns : |

### gda_xml_database_get_name ()

    const gchar* gda_xml_database_get_name      (GdaXmlDatabase *xmldb);

Return the name of the given XML database.

`xmldb` : | XML database.
Returns : | the name of the database.

### gda_xml_database_set_name ()

    void        gda_xml_database_set_name       (GdaXmlDatabase *xmldb,
                                                 const gchar *name);

`xmldb` : |
`name` : |

### gda_xml_database_get_uri ()

    const gchar* gda_xml_database_get_uri       (GdaXmlDatabase *xmldb);

Return the URI associated with the given XML database. This URI will be used when saving the XML database (gda_xml_database_save) and no URI is given.

`xmldb` : | XML database.
Returns : | the URI for the XML database.

### gda_xml_database_set_uri ()

    void        gda_xml_database_set_uri        (GdaXmlDatabase *xmldb,
                                                 const gchar *uri);

`xmldb` : | XML database.
`uri` : |

### gda_xml_database_changed ()

    void        gda_xml_database_changed        (GdaXmlDatabase *xmldb);

Emit the "changed" signal for the given XML database

`xmldb` : | XML database

### gda_xml_database_reload ()

    void        gda_xml_database_reload         (GdaXmlDatabase *xmldb);

Reload the given XML database from its original place, discarding all changes that may have happened.

`xmldb` : | XML database.

### gda_xml_database_save ()

    gboolean    gda_xml_database_save           (GdaXmlDatabase *xmldb,
                                                 const gchar *uri);

Save the given XML database to disk.

`xmldb` : | XML database.
`uri` : | URI to save the XML database to.
Returns : |

### gda_xml_database_to_string ()

    gchar*      gda_xml_database_to_string      (GdaXmlDatabase *xmldb);

Get the given XML database contents as a XML string.

`xmldb` : | a GdaXmlDatabase object.
Returns : | the XML string representing the structure and contents of the given GdaXmlDatabase object. The returned value must be freed when no longer needed.

### gda_xml_database_get_tables ()

    GList*      gda_xml_database_get_tables     (GdaXmlDatabase *xmldb);

Return a list of all table names present in the given database. You must free the returned GList when you no longer need it, by using the gda_xml_database_free_table_list function.

`xmldb` : | XML database.
Returns : | a GList of strings.

### gda_xml_database_free_table_list ()

    void        gda_xml_database_free_table_list
                                                (GList *list);

Free a GList of strings returned by gda_xml_database_get_tables.

`list` : | list of tables, as returned by gda_xml_database_get_tables.

### gda_xml_database_find_table ()

    GdaTable*   gda_xml_database_find_table     (GdaXmlDatabase *xmldb,
                                                 const gchar *name);

Searches the given XML database for a table named `name`, and returns a pointer to it.

`xmldb` : | XML database.
`name` : | Name for the table to look for.
Returns : | a pointer to the table, or NULL if not found.

### gda_xml_database_new_table ()

    GdaTable*   gda_xml_database_new_table      (GdaXmlDatabase *xmldb,
                                                 const gchar *name);

Create a new empty table in the given XML database.

`xmldb` : | XML database.
`name` : | Name for the new table.
Returns : | a pointer to the newly created in-memory table.

### gda_xml_database_new_table_from_model ()

    GdaTable*   gda_xml_database_new_table_from_model
                                                (GdaXmlDatabase *xmldb,
                                                 const gchar *name,
                                                 const GdaDataModel *model,
                                                 gboolean add_data);

Create a new table in the given XML database from the given GdaDataModel.

`xmldb` : | XML database.
`name` : | Name for the new table.
`model` : | Model to create the table from.
`add_data` : | Whether to add model's data or not.
Returns : | a pointer to the newly created in-memory table.

### gda_xml_database_new_table_from_node ()

    GdaTable*   gda_xml_database_new_table_from_node
                                                (GdaXmlDatabase *xmldb,
                                                 xmlNodePtr xmlnode);

Add a table to the given XML database by parsong the given XML node pointer, which usually is obtained from an already loaded xmlDocPtr.

`xmldb` : | XML Database.
`xmlnode` : |
Returns : | a pointer to the newly created in-memory table.