| Midgard2 Reference Manual | ||||
|---|---|---|---|---|
| Top | Description | ||||
#include <midgard/midgard.h>
MgdSchema;
MidgardSchema;
void midgard_schema_init (MidgardSchema *self,
const gchar *path);
gboolean midgard_schema_read_dir (MidgardSchema *self,
const gchar *dirname);
gboolean midgard_schema_type_exists (MidgardSchema *self,
const gchar *classname);
void midgard_schema_read_file (MidgardSchema *self,
const gchar *filename);
MidgardSchema reads MgdSchema files and registers user defined classes in GType system. It's not needed to use this part of API in normal application written in C for example. MidgardConnection API does the magic and initialize MidgardSchema object for you, if such is not yet created. However, there might be some use cases where MidgardSchema must be initiazlied explicitly before any connection is done.
The best example is httpd server with PHP bindings for Midgard. In such case, classes must be registered when main process starts up and new MidgardConnection objects are created for any child process.
In other words, in most cases, there's no need to use MidgardSchema directly.
void midgard_schema_init (MidgardSchema *self, const gchar *path);
Reads xml file which defines very basic and common classes. By default it's `/usr/local/share/midgard/MgdObjects.xml` file.
|
MidgardSchema instance |
|
full path to a xml file with common classes |
gboolean midgard_schema_read_dir (MidgardSchema *self, const gchar *dirname);
This function expects 'schema' subdirectory at least.
'views' subdirectory is optional, and if missed, won't be read.
midgard_schema_read_file() is invoked for every valid xml MgdSchema file
found in 'schema' subdirectory found in given directory.
You can also use explicit NULL instead of directory path. In such case, MIDGARD_ENV_GLOBAL_SHAREDIR environment variable is checked. If it's not set, directory path is determined using prefix set for compile and build time.
|
MidgardSchema instance |
|
a directory with 'schema' and 'views' subdirectories. |
Returns : |
TRUE if files has been read, FALSE otherwise
|
gboolean midgard_schema_type_exists (MidgardSchema *self, const gchar *classname);
|
MidgardSchema instance |
|
GObjectClass derived class name |
Returns : |
TRUE if class is registered as MidgardObjectClass derived, FALSE otherwise
|
void midgard_schema_read_file (MidgardSchema *self, const gchar *filename);
Reads file at given path and initialize all MidgardObjectClass derived classes defined in this file. Also reads all files which are included in this file. Such files are read and parsed when given file is already parsed and all classes defined in given file are already registered in GType system.
|
MidgardSchema instance |
|
full path to a file |