« Return to Thread: osync_xmlformat_validate() in format plugins

Re: osync_xmlformat_validate() in format plugins

by Daniel Gollub :: Rate this Message:

Reply to Author | View in Thread

On Thursday 19 June 2008 16:18:02 Bjoern Ricks wrote:
> I started coding to get rid of osync_xml_validate and to have only one
> instance of a xml schema for each objtype. Therefore I tried to reuse
> the oop singleton pattern in C via a static GList. Could you please
> review my first intuition because I am more familiar with C++ than C.

Thanks for looking into this!

The idea of using C++-singleton-like sounds interesting. I wonder if we would
change some more stuff, if this would be still required. For example make all
OSyncXMLFormat "inherit" of OSyncXMLFormatSchema? We just force/require for
all XMLFormats a schema file, by changing osync_xmlformat_new parameter list
to:

osync_xmlformat_new(const char *objtype, OSyncXMLFormatSchema *schema,
OSyncError **error);

And putting an OSyncXMLFormatSchema pointer into the internal struct.

Thoughts?

[...]


>  /**
>   * @brief Validate the xmlformat against its schema in inidivual path
>   * @param xmlformat The pointer to a xmlformat object
> @@ -399,8 +473,9 @@
>  osync_bool osync_xmlformat_validate(OSyncXMLFormat *xmlformat)
>  {
>         osync_assert(xmlformat);
> -
> -       return _osync_xmlformat_validate(xmlformat, NULL);
> +
> +       OSyncXMLFormatSchema * schema =
> osync_xmlformat_schema_get_instance(xmlformat, NULL); +       return
> osync_xmlformat_schema_validate(schema, xmlformat);

We should avoid code which is ignoring the error handling by passing NULL
instead of a OSyncError reference. (I know there is/was some code doing
so ... but we should get rid of those old code. It's just bad/wrong/....).
Feel free to change the paramter list vor the _validate() function to
(OSyncXMLFormat *xmlformat, OSyncError **error). You might set also an error
when osync_xmlformat_schema_validate is false:
osync_error_set(*error, OSYNC_ERROR_GENERIC /*or something different */, "XML
Format validation failed.");

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Opensync-devel mailing list
Opensync-devel@...
https://lists.sourceforge.net/lists/listinfo/opensync-devel

 « Return to Thread: osync_xmlformat_validate() in format plugins