Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Last year, I offered a bounty for information on configuration languages other than XML that provide schema validation for the contents of a configuration file. There were frustratingly few responses, as you can see if you follow this <a href="https://stackoverflow.com/questions/6079692/validating-files-having-tree-based-structures/">link</a>.</p> <p>Therefore, if you want schema validation, then I agree with nfechner that you should look at some schema languages for XML. You can find links to some of the more famous ones in <a href="http://en.wikipedia.org/wiki/XML_schema" rel="nofollow noreferrer">one</a> or <a href="http://en.wikipedia.org/wiki/XML_schema_language_comparison" rel="nofollow noreferrer">two</a> Wikipedia articles.</p> <p><em>If</em> you are not already committed to using XML, then you might want to check out <a href="http://www.config4star.org/" rel="nofollow noreferrer">Config4*</a> (of which I am the maintainer). I mention this because Config4* provides a schema validation language that is at least an order of magnitude easier to use than XML Schema. (The <em>only</em> other non-XML configuration language I discovered that has schema validation is YAML, but that functionality is available only via a Java or Ruby API, which is inconvenient for C/C++ applications.)</p> <p>Config4* provides a C++ API rather than a C API, but I suspect you will find it easy enough to put an <code>extern "C"</code> wrapper around a useful subset of the API.</p> <p>Regarding thread safety... <em>If</em> your applications will read a configuration file during single-threaded initialisation, and only afterwards allow multiple threads to query the configuration object, then I don't think any synchronisation will be required since the multiple threads will be invoking read-only operations. However, I suspect you already know that, and you are asking about thread safety because you expect to have some threads invoking query operations on a configuration object while other threads are concurrently invoking update operations on it. If you could give examples of some multi-threaded use cases you expect to have in your applications, then it might help people to offer advice that is relevant to your thread-safety requirements. As a fall-back technique, you could implement a synchronised delegation wrapper around the API of of whatever configuration library you use. For example (pseudo-code):</p> <pre><code>int config_lookup_int(const char * name) { int result; get_mutex_lock(); result = raw_api_lookup_int(name); release_mutex_lock(); return result; } </code></pre> <p>One last thing. Please elaborate on the <code>notify_config</code> functionality you are seeking.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload