Index: /library/bdm/bdmroot.h
===================================================================
--- /library/bdm/bdmroot.h (revision 769)
+++ /library/bdm/bdmroot.h (revision 789)
@@ -18,6 +18,13 @@
 
 #include "itpp_ext.h"
-#include "base/libconfig/lib/libconfig.h++"
 #include "bdmerror.h"
+
+#ifdef MEX
+	#include "base/libconfig/lib/libconfig.h++"	
+	// TODO DODELAT A NAHRADIT #include "base/libconfig_mex.h"
+#else
+	#include "base/libconfig/lib/libconfig.h++"
+#endif
+
 
 using namespace libconfig;
@@ -26,8 +33,7 @@
 
 namespace bdm {
-
-	
-	//! auxiliary function for debugging
-	void UI_DBG (const Setting &S, const string &spc, ostream &out );
+	
+//! auxiliary function for debugging
+void UI_DBG (const Setting &S, const string &spc, ostream &out );
 	
 //forward declaration
@@ -54,16 +60,82 @@
 	int log_level;
 
-	//! It is necessary to allow calling of from_setting and to_setting within the user_info class
+	//! It is necessary to allow calling of from_setting and to_setting within the UI class
 	friend class UI;
 
-	//! Read instance properties according the data stored in the Setting structure
-	//! 
-	//! It has to be called only through user_info class, therefore it is protected 
+	/*!	
+	\brief Read instance properties according the data stored in the Setting structure.
+	It has to be called only through UI class, therefore it is protected 
+
+	At the begining of this method, it is obligatory to call
+	the corresponding base::from_setting method. Sometimes, there can be 
+	an exception from this rule. If so, the programmer is encouraged 
+	to describe the reasons for this exception in the documentation in detail.
+	
+	Then, all the configuration	components should be read through the UI mechanism. 
+	Those with UI::SettingPresence set to optional shoud have their defaults fulfilled 
+	within the body of this method.
+
+	For instance, declaring a class \c trunk derived from our #root class, 
+	the implementation of the from_setting method should look like this
+
+	\code
+
+	public trunk : public root {
+
+		anytype xxx, yyy;
+
+		virtual void from_setting ( const Setting &set ) {
+			root::from_setting( set );
+			
+			UI::get ( xxx, set, "xxx", UI::compulsory );
+
+			if ( !UI::get ( yyy, set, "yyy", UI::optional ) ) {
+				... // here, it is necessary to set the default of attribute yyy						
+			}
+
+			... // another stuff related to trunk class
+		}
+
+		... // other members of this class
+	};
+
+	\endcode
+	*/
 	virtual void from_setting ( const Setting &set ) {
 	}
 
-	//! Save all the instance properties into the Setting structure
-	//!
-	//! It has to be called only through user_info class, therefore it is protected 
+	/*!	
+	\brief 	Save all the instance properties into the Setting structure.
+	It has to be called only through UI class, therefore it is protected 
+
+	The only obligatory rule concerning the body of this method is to call
+	the corresponding base::to_setting method first. 	Sometimes, there can 
+	be an exception from this rule. If so, the programmer is encouraged 
+	to describe the reasons for this exception in the documentation in detail.
+	
+	For instance, declaring
+	a class \c trunk derived from our #root class, the implementation of 
+	the to_setting method should look like this
+
+	\code
+	public trunk : public root {
+
+		anytype xxx;
+
+		virtual void to_setting ( const Setting &set ) {
+			root::to_setting( set );
+
+			UI::save ( xxx, set, "xxx" );
+			
+			... // another stuff related directly to trunk class
+
+		}
+
+		... // other members of this class
+
+	};
+
+	\endcode
+	*/
 	virtual void to_setting ( Setting &set ) const {
 	}
@@ -101,5 +173,36 @@
 	}
 
-	//! Check that all internal structures has been correctly set-up. Called at the end of from_setting.
+	/*!	
+	\brief 	This method checks that all internal structures has been set up correctly.
+
+	It is called automatically after the call of the #from_setting method by the mechanism of the UI class. 
+	However, it can be called in any other situation to assure the correctness of an instance.
+	
+	The only obligatory rule concerning the body of this method is to call
+	the corresponding base::validate method first. Sometimes, there can be 
+	an exception from this rule. If so, the programmer is encouraged 
+	to describe the reasons for this exception in the documentation in detail.	
+	
+	Then, only those checks which are not implemented in the base method 
+	are implemented here. For instance, declaring a class \c trunk derived from our 
+	#root class, the implementation of the method validate should 
+	look like this
+
+	\code
+	public trunk : public root {
+
+		virtual void validate ( ) {
+			root::validate( );
+
+			... // checks related directly to trunk class
+		}
+
+		... // other members of this class
+
+	};
+
+	\endcode
+
+	*/
 	virtual void validate() {
 	}
@@ -108,10 +211,8 @@
 	virtual root* _copy() const NOT_IMPLEMENTED(NULL);
 	
-
 	//! access function
 	int _log_level() const {
 		return log_level;
 	}
-
 };
 
Index: /library/bdm/base/user_info.h
===================================================================
--- /library/bdm/base/user_info.h (revision 771)
+++ /library/bdm/base/user_info.h (revision 789)
@@ -22,9 +22,7 @@
 #include <stdexcept>
 
-#include "libconfig/lib/libconfig.h++"
 #include "../bdmroot.h"
 #include "../shared_ptr.h"
 #include "itpp/itbase.h"
-
 
 using std::string;
Index: /library/bdm/base/libconfig_mex.cpp
===================================================================
--- /library/bdm/base/libconfig_mex.cpp (revision 789)
+++ /library/bdm/base/libconfig_mex.cpp (revision 789)
@@ -0,0 +1,4482 @@
+/* ----------------------------------------------------------------------------
+
+	THE FILE IS UNDER THE CONSTRUCTION!
+
+   This file is a mex clone of libconfigcpp.cc originally found 
+   in the libconfig library which was desgigned by Mark A Lindner.
+   
+   ----------------------------------------------------------------------------
+*/
+
+
+#include "libconfig_mex.h"
+
+#ifdef _MSC_VER
+#pragma warning (disable: 4996)
+#endif
+
+//#include "wincompat.h"
+
+#include <cstring>
+#include <cstdlib>
+#include <sstream>
+
+namespace libconfig {
+
+	/*
+// ---------------------------------------------------------------------------
+
+ParseException::ParseException(const char *file, int line, const char *error)
+  : _file(strdup(file)), _line(line), _error(error)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+ParseException::~ParseException() throw()
+{
+  free((void *)_file);
+}
+
+// ---------------------------------------------------------------------------
+
+const char *ParseException::what() const throw()
+{
+  return("ParseException");
+}
+
+// ---------------------------------------------------------------------------
+
+static int __toTypeCode(Setting::Type type)
+{
+  int typecode;
+
+  switch(type)
+  {
+    case Setting::TypeGroup:
+      typecode = CONFIG_TYPE_GROUP;
+      break;
+
+    case Setting::TypeInt:
+      typecode = CONFIG_TYPE_INT;
+      break;
+
+    case Setting::TypeInt64:
+      typecode = CONFIG_TYPE_INT64;
+      break;
+
+    case Setting::TypeFloat:
+      typecode = CONFIG_TYPE_FLOAT;
+      break;
+
+    case Setting::TypeString:
+      typecode = CONFIG_TYPE_STRING;
+      break;
+
+    case Setting::TypeBoolean:
+      typecode = CONFIG_TYPE_BOOL;
+      break;
+
+    case Setting::TypeArray:
+      typecode = CONFIG_TYPE_ARRAY;
+      break;
+
+    case Setting::TypeList:
+      typecode = CONFIG_TYPE_LIST;
+      break;
+
+    default:
+      typecode = CONFIG_TYPE_NONE;
+  }
+
+  return(typecode);
+}
+
+// ---------------------------------------------------------------------------
+
+static void __constructPath(const Setting &setting,
+                            std::stringstream &path)
+{
+  // head recursion to print path from root to target
+
+  if(! setting.isRoot())
+  {
+    __constructPath(setting.getParent(), path);
+    if(path.tellp() > 0)
+      path << '.';
+
+    const char *name = setting.getName();
+    if(name)
+      path << name;
+    else
+      path << '[' << setting.getIndex() << ']';
+  }
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException::SettingException(const Setting &setting)
+{
+  std::stringstream sstr;
+  __constructPath(setting, sstr);
+
+  _path = ::strdup(sstr.str().c_str());
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException::SettingException(const Setting &setting, int idx)
+{
+  std::stringstream sstr;
+  __constructPath(setting, sstr);
+  sstr << ".[" << idx << "]";
+
+  _path = ::strdup(sstr.str().c_str());
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException::SettingException(const Setting &setting, const char *name)
+{
+  std::stringstream sstr;
+  __constructPath(setting, sstr);
+  sstr << '.' << name;
+
+  _path = ::strdup(sstr.str().c_str());
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException::SettingException(const char *path)
+{
+  _path = ::strdup(path);
+}
+
+// ---------------------------------------------------------------------------
+
+const char *SettingException::getPath() const
+{
+  return(_path);
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException::SettingException(const SettingException &other)
+{
+  _path = ::strdup(other._path);
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException &SettingException::operator=(const SettingException &other)
+{
+  ::free(_path);
+  _path = ::strdup(other._path);
+
+  return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+const char *SettingException::what() const throw()
+{
+  return("SettingException");
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException::~SettingException() throw()
+{
+  ::free(_path);
+}
+
+// ---------------------------------------------------------------------------
+
+SettingTypeException::SettingTypeException(const Setting &setting)
+  : SettingException(setting)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+SettingTypeException::SettingTypeException(const Setting &setting, int idx)
+  : SettingException(setting, idx)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+SettingTypeException::SettingTypeException(const Setting &setting,
+                                           const char *name)
+  : SettingException(setting, name)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+const char *SettingTypeException::what() const throw()
+{
+  return("SettingTypeException");
+}
+
+// ---------------------------------------------------------------------------
+
+SettingNotFoundException::SettingNotFoundException(const Setting &setting,
+                                                   int idx)
+  : SettingException(setting, idx)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+SettingNotFoundException::SettingNotFoundException(const Setting &setting,
+                                                   const char *name)
+  : SettingException(setting, name)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+SettingNotFoundException::SettingNotFoundException(const char *path)
+  : SettingException(path)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+const char *SettingNotFoundException::what() const throw()
+{
+  return("SettingNotFoundException");
+}
+
+// ---------------------------------------------------------------------------
+
+SettingNameException::SettingNameException(const Setting &setting,
+                                           const char *name)
+  : SettingException(setting, name)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+const char *SettingNameException::what() const throw()
+{
+  return("SettingNameException");
+}
+
+// ---------------------------------------------------------------------------
+
+const char *FileIOException::what() const throw()
+{
+  return("FileIOException");
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::ConfigDestructor(void *arg)
+{
+  delete reinterpret_cast<Setting *>(arg);
+}
+
+// ---------------------------------------------------------------------------
+
+Config::Config()
+{
+  _config = new config_t;
+  config_init(_config);
+  config_set_destructor(_config, ConfigDestructor);
+}
+
+// ---------------------------------------------------------------------------
+
+Config::~Config()
+{
+  config_destroy(_config);
+  delete _config;
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::setAutoConvert(bool flag)
+{
+  config_set_auto_convert(_config, (flag ? CONFIG_TRUE : CONFIG_FALSE));
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::getAutoConvert() const
+{
+  return(config_get_auto_convert(_config) != CONFIG_FALSE);
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::setTabWidth(unsigned short width) throw()
+{
+  config_set_tab_width(_config, width);
+}
+
+// ---------------------------------------------------------------------------
+
+unsigned short Config::getTabWidth() const throw()
+{
+  return(config_get_tab_width(_config));
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::handleError() const
+{
+  switch(config_error_type(_config))
+  {
+    case CONFIG_ERR_NONE:
+      break;
+    
+    case CONFIG_ERR_PARSE:
+      throw ParseException(config_error_file(_config),
+                           config_error_line(_config),
+                           config_error_text(_config));
+      break;
+
+    case CONFIG_ERR_FILE_IO:
+    default:
+      throw FileIOException();
+  }
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::read(FILE *stream) throw(ParseException)
+{
+  if(! config_read(_config, stream))
+    handleError();
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::readString(const char *str) throw(ParseException)
+{
+  if(! config_read_string(_config, str))
+    handleError();
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::write(FILE *stream) const
+{
+  config_write(_config, stream);
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::readFile(const char *filename) throw(FileIOException,
+                                                  ParseException)
+{
+  if(! config_read_file(_config, filename))
+    handleError();
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::writeFile(const char *filename) throw(FileIOException)
+{
+  if(! config_write_file(_config, filename))
+    handleError();
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Config::lookup(const char *path) const
+  throw(SettingNotFoundException)
+{
+  config_setting_t *s = config_lookup(_config, path);
+  if(! s)
+    throw SettingNotFoundException(path);
+
+  return(Setting::wrapSetting(s));
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::exists(const char *path) const throw()
+{
+  config_setting_t *s = config_lookup(_config, path);
+
+  return(s != NULL);
+}
+
+// ---------------------------------------------------------------------------
+
+#define CONFIG_LOOKUP_NO_EXCEPTIONS(P, T, V)    \
+  try                                           \
+  {                                             \
+    Setting &s = lookup(P);                     \
+    V = (T)s;                                   \
+    return(true);                               \
+  }                                             \
+  catch(ConfigException)                        \
+  {                                             \
+    return(false);                              \
+  }
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, bool &value) const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, bool, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, int &value) const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, int, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, unsigned int &value) const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, unsigned int, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, long long &value) const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, long long, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, unsigned long long &value)
+  const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, unsigned long long, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, double &value) const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, double, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, float &value) const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, float, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, const char *&value) const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, const char *, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, std::string &value) const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, const char *, value);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Config::getRoot() const
+{
+  return(Setting::wrapSetting(config_root_setting(_config)));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::Setting(config_setting_t *setting)
+  : _setting(setting)
+{
+  switch(config_setting_type(setting))
+  {
+    case CONFIG_TYPE_GROUP:
+      _type = TypeGroup;
+      break;
+
+    case CONFIG_TYPE_INT:
+      _type = TypeInt;
+      break;
+
+    case CONFIG_TYPE_INT64:
+      _type = TypeInt64;
+      break;
+
+    case CONFIG_TYPE_FLOAT:
+      _type = TypeFloat;
+      break;
+
+    case CONFIG_TYPE_STRING:
+      _type = TypeString;
+      break;
+
+    case CONFIG_TYPE_BOOL:
+      _type = TypeBoolean;
+      break;
+
+    case CONFIG_TYPE_ARRAY:
+      _type = TypeArray;
+      break;
+
+    case CONFIG_TYPE_LIST:
+      _type = TypeList;
+      break;
+
+    case CONFIG_TYPE_NONE:
+    default:
+      _type = TypeNone;
+      break;
+  }
+
+  switch(config_setting_get_format(setting))
+  {
+    case CONFIG_FORMAT_HEX:
+      _format = FormatHex;
+      break;
+
+    case CONFIG_FORMAT_DEFAULT:
+    default:
+      _format = FormatDefault;
+      break;
+  }
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::~Setting() throw()
+{
+  _setting = NULL;
+}
+
+// ---------------------------------------------------------------------------
+
+void Setting::setFormat(Format format) throw()
+{
+  if((_type == TypeInt) || (_type == TypeInt64))
+  {
+    if(format == FormatHex)
+      _format = FormatHex;
+    else
+      _format = FormatDefault;
+  }
+  else
+    _format = FormatDefault;
+
+  config_setting_set_format(_setting, static_cast<short>(_format));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator bool() const throw(SettingTypeException) 
+{
+  assertType(TypeBoolean);
+
+  return(config_setting_get_bool(_setting) ? true : false);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator int() const throw(SettingTypeException)
+{
+  assertType(TypeInt);
+
+  return(config_setting_get_int(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator unsigned int() const throw(SettingTypeException)
+{
+  assertType(TypeInt);
+
+  int v = config_setting_get_int(_setting);
+
+  if(v < 0)
+    v = 0;
+
+  return(static_cast<unsigned int>(v));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator long() const throw(SettingTypeException)
+{
+  if(sizeof(long) == sizeof(long long))
+    return operator long long();
+  else
+    return operator int();
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator unsigned long() const throw(SettingTypeException)
+{
+  if(sizeof(long) == sizeof(long long))
+    return operator unsigned long long();
+  else
+    return operator unsigned int();
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator long long() const throw(SettingTypeException)
+{
+  assertType(TypeInt64);
+
+  return(config_setting_get_int64(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator unsigned long long() const throw(SettingTypeException)
+{
+  assertType(TypeInt64);
+
+  long long v = config_setting_get_int64(_setting);
+
+  if(v < INT64_CONST(0))
+    v = INT64_CONST(0);
+
+  return(static_cast<unsigned long long>(v));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator double() const throw(SettingTypeException)
+{
+  assertType(TypeFloat);
+
+  return(config_setting_get_float(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator float() const throw(SettingTypeException)
+{
+  assertType(TypeFloat);
+
+  // may cause loss of precision:
+  return(static_cast<float>(config_setting_get_float(_setting)));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator const char *() const throw(SettingTypeException)
+{
+  assertType(TypeString);
+
+  return(config_setting_get_string(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator std::string() const throw(SettingTypeException)
+{
+  assertType(TypeString);
+
+  const char *s = config_setting_get_string(_setting);
+
+  std::string str;
+  if(s)
+    str = s;
+
+  return(str);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(bool value) throw(SettingTypeException)
+{
+  assertType(TypeBoolean);
+
+  config_setting_set_bool(_setting, value);
+
+  return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(int value) throw(SettingTypeException)
+{
+  assertType(TypeInt);
+
+  config_setting_set_int(_setting, value);
+
+  return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(long value) throw(SettingTypeException)
+{
+  if(sizeof(long) == sizeof(long long))
+    return(operator=(static_cast<long long>(value)));
+  else
+    return(operator=(static_cast<int>(value)));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(const long long &value)
+  throw(SettingTypeException)
+{
+  assertType(TypeInt64);
+
+  config_setting_set_int64(_setting, value);
+
+  return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(const double &value) throw(SettingTypeException)
+{
+  assertType(TypeFloat);
+
+  config_setting_set_float(_setting, value);
+
+  return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(float value) throw(SettingTypeException)
+{
+  assertType(TypeFloat);
+
+  double cvalue = static_cast<double>(value);
+
+  config_setting_set_float(_setting, cvalue);
+
+  return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(const char *value) throw(SettingTypeException)
+{
+  assertType(TypeString);
+
+  config_setting_set_string(_setting, value);
+
+  return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(const std::string &value)
+  throw(SettingTypeException)
+{
+  assertType(TypeString);
+
+  config_setting_set_string(_setting, value.c_str());
+
+  return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator[](int i) const
+  throw(SettingTypeException, SettingNotFoundException)
+{
+  if((_type != TypeArray) && (_type != TypeGroup) && (_type != TypeList))
+    throw SettingTypeException(*this, i);
+
+  config_setting_t *setting = config_setting_get_elem(_setting, i);
+
+  if(! setting)
+    throw SettingNotFoundException(*this, i);
+
+  return(wrapSetting(setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator[](const char *key) const
+  throw(SettingTypeException, SettingNotFoundException)
+{
+  assertType(TypeGroup);
+
+  config_setting_t *setting = config_setting_get_member(_setting, key);
+
+  if(! setting)
+    throw SettingNotFoundException(*this, key);
+
+  return(wrapSetting(setting));
+}
+
+// ---------------------------------------------------------------------------
+
+#define SETTING_LOOKUP_NO_EXCEPTIONS(K, T, V)   \
+  try                                           \
+  {                                             \
+    Setting &s = operator[](K);                 \
+    V = (T)s;                                   \
+    return(true);                               \
+  }                                             \
+  catch(ConfigException)                        \
+  {                                             \
+    return(false);                              \
+  }
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, bool &value) const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, bool, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, int &value) const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, int, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, unsigned int &value)
+  const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, unsigned int, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, long long &value) const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, long long, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, unsigned long long &value)
+  const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, unsigned long long, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, double &value) const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, double, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, float &value) const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, float, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, const char *&value) const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, const char *, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, std::string &value) const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, const char *, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::exists(const char *name) const throw()
+{
+  if(_type != TypeGroup)
+    return(false);
+
+  config_setting_t *setting = config_setting_get_member(_setting, name);
+
+  return(setting != NULL);
+}
+
+// ---------------------------------------------------------------------------
+
+int Setting::getLength() const throw()
+{
+  return(config_setting_length(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+const char * Setting::getName() const throw()
+{
+  return(config_setting_name(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+std::string Setting::getPath() const
+{
+  std::stringstream path;
+
+  __constructPath(*this, path);
+
+  return(path.str());
+}
+
+// ---------------------------------------------------------------------------
+
+const Setting & Setting::getParent() const throw(SettingNotFoundException)
+{
+  config_setting_t *setting = config_setting_parent(_setting);
+
+  if(! setting)
+    throw SettingNotFoundException(NULL);
+
+  return(wrapSetting(setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::getParent() throw(SettingNotFoundException)
+{
+  config_setting_t *setting = config_setting_parent(_setting);
+
+  if(! setting)
+    throw SettingNotFoundException(NULL);
+
+  return(wrapSetting(setting));
+}
+
+// ---------------------------------------------------------------------------
+
+unsigned int Setting::getSourceLine() const throw()
+{
+  return(config_setting_source_line(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+const char *Setting::getSourceFile() const throw()
+{
+  return(config_setting_source_file(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::isRoot() const throw()
+{
+  return(config_setting_is_root(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+int Setting::getIndex() const throw()
+{
+  return(config_setting_index(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+void Setting::remove(const char *name)
+  throw(SettingTypeException, SettingNotFoundException)
+{
+  assertType(TypeGroup);
+
+  if(! config_setting_remove(_setting, name))
+    throw SettingNotFoundException(*this, name);
+}
+
+// ---------------------------------------------------------------------------
+
+void Setting::remove(unsigned int idx)
+  throw(SettingTypeException, SettingNotFoundException)
+{
+  if((_type != TypeArray) && (_type != TypeGroup) && (_type != TypeList))
+    throw SettingTypeException(*this, idx);
+
+  if(! config_setting_remove_elem(_setting, idx))
+    throw SettingNotFoundException(*this, idx);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::add(const char *name, Setting::Type type)
+  throw(SettingNameException, SettingTypeException)
+{
+  assertType(TypeGroup);
+
+  int typecode = __toTypeCode(type);
+
+  if(typecode == CONFIG_TYPE_NONE)
+    throw SettingTypeException(*this, name);
+
+  config_setting_t *setting = config_setting_add(_setting, name, typecode);
+
+  if(! setting)
+    throw SettingNameException(*this, name);
+
+  return(wrapSetting(setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::add(Setting::Type type) throw(SettingTypeException)
+{
+  if((_type != TypeArray) && (_type != TypeList))
+    throw SettingTypeException(*this);
+
+  if(_type == TypeArray)
+  {
+    int idx = getLength();
+
+    if(idx > 0)
+    {
+      Setting::Type atype = operator[](0).getType();
+      if(type != atype)
+        throw SettingTypeException(*this, idx);
+    }
+    else
+    {
+      if((type != TypeInt) && (type != TypeFloat) && (type != TypeString)
+         && (type != TypeBoolean))
+        throw SettingTypeException(*this, idx);
+    }
+  }
+
+  int typecode = __toTypeCode(type);
+  config_setting_t *s = config_setting_add(_setting, NULL, typecode);
+
+  Setting &ns = wrapSetting(s);
+
+  switch(type)
+  {
+    case TypeInt:
+      ns = 0;
+      break;
+
+    case TypeInt64:
+      ns = INT64_CONST(0);
+      break;
+
+    case TypeFloat:
+      ns = 0.0;
+      break;
+
+    case TypeString:
+      ns = (char *)NULL;
+      break;
+
+    case TypeBoolean:
+      ns = false;
+      break;
+
+    default:
+      // won't happen
+      break;
+  }
+
+  return(ns);
+}
+
+// ---------------------------------------------------------------------------
+
+void Setting::assertType(Setting::Type type) const throw(SettingTypeException)
+{
+  if(type != _type)
+  {
+    if(!(isNumber() && config_get_auto_convert(_setting->config)
+         && ((type == TypeInt) || (type == TypeFloat))))
+      throw SettingTypeException(*this);
+  }
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::wrapSetting(config_setting_t *s)
+{
+  Setting *setting = NULL;
+
+  void *hook = config_setting_get_hook(s);
+  if(! hook)
+  {
+    setting = new Setting(s);
+    config_setting_set_hook(s, reinterpret_cast<void *>(setting));
+  }
+  else
+    setting = reinterpret_cast<Setting *>(hook);
+
+  return(*setting);
+}
+
+// ---------------------------------------------------------------------------
+
+*/
+
+}; // namespace libconfig
+
+
+/* ----------------------------------------------------------------------------
+
+   This file is a mex clone of libconfigcpp.cc originally found 
+   in the libconfig library which was desgigned by Mark A Lindner.
+   
+   ----------------------------------------------------------------------------
+*/
+
+
+#include "libconfig_mex.h"
+
+#ifdef _MSC_VER
+#pragma warning (disable: 4996)
+#endif
+
+//#include "wincompat.h"
+
+#include <cstring>
+#include <cstdlib>
+#include <sstream>
+
+namespace libconfig {
+
+	/*
+// ---------------------------------------------------------------------------
+
+ParseException::ParseException(const char *file, int line, const char *error)
+  : _file(strdup(file)), _line(line), _error(error)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+ParseException::~ParseException() throw()
+{
+  free((void *)_file);
+}
+
+// ---------------------------------------------------------------------------
+
+const char *ParseException::what() const throw()
+{
+  return("ParseException");
+}
+
+// ---------------------------------------------------------------------------
+
+static int __toTypeCode(Setting::Type type)
+{
+  int typecode;
+
+  switch(type)
+  {
+    case Setting::TypeGroup:
+      typecode = CONFIG_TYPE_GROUP;
+      break;
+
+    case Setting::TypeInt:
+      typecode = CONFIG_TYPE_INT;
+      break;
+
+    case Setting::TypeInt64:
+      typecode = CONFIG_TYPE_INT64;
+      break;
+
+    case Setting::TypeFloat:
+      typecode = CONFIG_TYPE_FLOAT;
+      break;
+
+    case Setting::TypeString:
+      typecode = CONFIG_TYPE_STRING;
+      break;
+
+    case Setting::TypeBoolean:
+      typecode = CONFIG_TYPE_BOOL;
+      break;
+
+    case Setting::TypeArray:
+      typecode = CONFIG_TYPE_ARRAY;
+      break;
+
+    case Setting::TypeList:
+      typecode = CONFIG_TYPE_LIST;
+      break;
+
+    default:
+      typecode = CONFIG_TYPE_NONE;
+  }
+
+  return(typecode);
+}
+
+// ---------------------------------------------------------------------------
+
+static void __constructPath(const Setting &setting,
+                            std::stringstream &path)
+{
+  // head recursion to print path from root to target
+
+  if(! setting.isRoot())
+  {
+    __constructPath(setting.getParent(), path);
+    if(path.tellp() > 0)
+      path << '.';
+
+    const char *name = setting.getName();
+    if(name)
+      path << name;
+    else
+      path << '[' << setting.getIndex() << ']';
+  }
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException::SettingException(const Setting &setting)
+{
+  std::stringstream sstr;
+  __constructPath(setting, sstr);
+
+  _path = ::strdup(sstr.str().c_str());
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException::SettingException(const Setting &setting, int idx)
+{
+  std::stringstream sstr;
+  __constructPath(setting, sstr);
+  sstr << ".[" << idx << "]";
+
+  _path = ::strdup(sstr.str().c_str());
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException::SettingException(const Setting &setting, const char *name)
+{
+  std::stringstream sstr;
+  __constructPath(setting, sstr);
+  sstr << '.' << name;
+
+  _path = ::strdup(sstr.str().c_str());
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException::SettingException(const char *path)
+{
+  _path = ::strdup(path);
+}
+
+// ---------------------------------------------------------------------------
+
+const char *SettingException::getPath() const
+{
+  return(_path);
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException::SettingException(const SettingException &other)
+{
+  _path = ::strdup(other._path);
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException &SettingException::operator=(const SettingException &other)
+{
+  ::free(_path);
+  _path = ::strdup(other._path);
+
+  return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+const char *SettingException::what() const throw()
+{
+  return("SettingException");
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException::~SettingException() throw()
+{
+  ::free(_path);
+}
+
+// ---------------------------------------------------------------------------
+
+SettingTypeException::SettingTypeException(const Setting &setting)
+  : SettingException(setting)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+SettingTypeException::SettingTypeException(const Setting &setting, int idx)
+  : SettingException(setting, idx)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+SettingTypeException::SettingTypeException(const Setting &setting,
+                                           const char *name)
+  : SettingException(setting, name)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+const char *SettingTypeException::what() const throw()
+{
+  return("SettingTypeException");
+}
+
+// ---------------------------------------------------------------------------
+
+SettingNotFoundException::SettingNotFoundException(const Setting &setting,
+                                                   int idx)
+  : SettingException(setting, idx)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+SettingNotFoundException::SettingNotFoundException(const Setting &setting,
+                                                   const char *name)
+  : SettingException(setting, name)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+SettingNotFoundException::SettingNotFoundException(const char *path)
+  : SettingException(path)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+const char *SettingNotFoundException::what() const throw()
+{
+  return("SettingNotFoundException");
+}
+
+// ---------------------------------------------------------------------------
+
+SettingNameException::SettingNameException(const Setting &setting,
+                                           const char *name)
+  : SettingException(setting, name)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+const char *SettingNameException::what() const throw()
+{
+  return("SettingNameException");
+}
+
+// ---------------------------------------------------------------------------
+
+const char *FileIOException::what() const throw()
+{
+  return("FileIOException");
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::ConfigDestructor(void *arg)
+{
+  delete reinterpret_cast<Setting *>(arg);
+}
+
+// ---------------------------------------------------------------------------
+
+Config::Config()
+{
+  _config = new config_t;
+  config_init(_config);
+  config_set_destructor(_config, ConfigDestructor);
+}
+
+// ---------------------------------------------------------------------------
+
+Config::~Config()
+{
+  config_destroy(_config);
+  delete _config;
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::setAutoConvert(bool flag)
+{
+  config_set_auto_convert(_config, (flag ? CONFIG_TRUE : CONFIG_FALSE));
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::getAutoConvert() const
+{
+  return(config_get_auto_convert(_config) != CONFIG_FALSE);
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::setTabWidth(unsigned short width) throw()
+{
+  config_set_tab_width(_config, width);
+}
+
+// ---------------------------------------------------------------------------
+
+unsigned short Config::getTabWidth() const throw()
+{
+  return(config_get_tab_width(_config));
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::handleError() const
+{
+  switch(config_error_type(_config))
+  {
+    case CONFIG_ERR_NONE:
+      break;
+    
+    case CONFIG_ERR_PARSE:
+      throw ParseException(config_error_file(_config),
+                           config_error_line(_config),
+                           config_error_text(_config));
+      break;
+
+    case CONFIG_ERR_FILE_IO:
+    default:
+      throw FileIOException();
+  }
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::read(FILE *stream) throw(ParseException)
+{
+  if(! config_read(_config, stream))
+    handleError();
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::readString(const char *str) throw(ParseException)
+{
+  if(! config_read_string(_config, str))
+    handleError();
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::write(FILE *stream) const
+{
+  config_write(_config, stream);
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::readFile(const char *filename) throw(FileIOException,
+                                                  ParseException)
+{
+  if(! config_read_file(_config, filename))
+    handleError();
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::writeFile(const char *filename) throw(FileIOException)
+{
+  if(! config_write_file(_config, filename))
+    handleError();
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Config::lookup(const char *path) const
+  throw(SettingNotFoundException)
+{
+  config_setting_t *s = config_lookup(_config, path);
+  if(! s)
+    throw SettingNotFoundException(path);
+
+  return(Setting::wrapSetting(s));
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::exists(const char *path) const throw()
+{
+  config_setting_t *s = config_lookup(_config, path);
+
+  return(s != NULL);
+}
+
+// ---------------------------------------------------------------------------
+
+#define CONFIG_LOOKUP_NO_EXCEPTIONS(P, T, V)    \
+  try                                           \
+  {                                             \
+    Setting &s = lookup(P);                     \
+    V = (T)s;                                   \
+    return(true);                               \
+  }                                             \
+  catch(ConfigException)                        \
+  {                                             \
+    return(false);                              \
+  }
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, bool &value) const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, bool, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, int &value) const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, int, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, unsigned int &value) const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, unsigned int, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, long long &value) const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, long long, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, unsigned long long &value)
+  const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, unsigned long long, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, double &value) const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, double, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, float &value) const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, float, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, const char *&value) const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, const char *, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, std::string &value) const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, const char *, value);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Config::getRoot() const
+{
+  return(Setting::wrapSetting(config_root_setting(_config)));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::Setting(config_setting_t *setting)
+  : _setting(setting)
+{
+  switch(config_setting_type(setting))
+  {
+    case CONFIG_TYPE_GROUP:
+      _type = TypeGroup;
+      break;
+
+    case CONFIG_TYPE_INT:
+      _type = TypeInt;
+      break;
+
+    case CONFIG_TYPE_INT64:
+      _type = TypeInt64;
+      break;
+
+    case CONFIG_TYPE_FLOAT:
+      _type = TypeFloat;
+      break;
+
+    case CONFIG_TYPE_STRING:
+      _type = TypeString;
+      break;
+
+    case CONFIG_TYPE_BOOL:
+      _type = TypeBoolean;
+      break;
+
+    case CONFIG_TYPE_ARRAY:
+      _type = TypeArray;
+      break;
+
+    case CONFIG_TYPE_LIST:
+      _type = TypeList;
+      break;
+
+    case CONFIG_TYPE_NONE:
+    default:
+      _type = TypeNone;
+      break;
+  }
+
+  switch(config_setting_get_format(setting))
+  {
+    case CONFIG_FORMAT_HEX:
+      _format = FormatHex;
+      break;
+
+    case CONFIG_FORMAT_DEFAULT:
+    default:
+      _format = FormatDefault;
+      break;
+  }
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::~Setting() throw()
+{
+  _setting = NULL;
+}
+
+// ---------------------------------------------------------------------------
+
+void Setting::setFormat(Format format) throw()
+{
+  if((_type == TypeInt) || (_type == TypeInt64))
+  {
+    if(format == FormatHex)
+      _format = FormatHex;
+    else
+      _format = FormatDefault;
+  }
+  else
+    _format = FormatDefault;
+
+  config_setting_set_format(_setting, static_cast<short>(_format));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator bool() const throw(SettingTypeException) 
+{
+  assertType(TypeBoolean);
+
+  return(config_setting_get_bool(_setting) ? true : false);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator int() const throw(SettingTypeException)
+{
+  assertType(TypeInt);
+
+  return(config_setting_get_int(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator unsigned int() const throw(SettingTypeException)
+{
+  assertType(TypeInt);
+
+  int v = config_setting_get_int(_setting);
+
+  if(v < 0)
+    v = 0;
+
+  return(static_cast<unsigned int>(v));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator long() const throw(SettingTypeException)
+{
+  if(sizeof(long) == sizeof(long long))
+    return operator long long();
+  else
+    return operator int();
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator unsigned long() const throw(SettingTypeException)
+{
+  if(sizeof(long) == sizeof(long long))
+    return operator unsigned long long();
+  else
+    return operator unsigned int();
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator long long() const throw(SettingTypeException)
+{
+  assertType(TypeInt64);
+
+  return(config_setting_get_int64(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator unsigned long long() const throw(SettingTypeException)
+{
+  assertType(TypeInt64);
+
+  long long v = config_setting_get_int64(_setting);
+
+  if(v < INT64_CONST(0))
+    v = INT64_CONST(0);
+
+  return(static_cast<unsigned long long>(v));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator double() const throw(SettingTypeException)
+{
+  assertType(TypeFloat);
+
+  return(config_setting_get_float(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator float() const throw(SettingTypeException)
+{
+  assertType(TypeFloat);
+
+  // may cause loss of precision:
+  return(static_cast<float>(config_setting_get_float(_setting)));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator const char *() const throw(SettingTypeException)
+{
+  assertType(TypeString);
+
+  return(config_setting_get_string(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator std::string() const throw(SettingTypeException)
+{
+  assertType(TypeString);
+
+  const char *s = config_setting_get_string(_setting);
+
+  std::string str;
+  if(s)
+    str = s;
+
+  return(str);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(bool value) throw(SettingTypeException)
+{
+  assertType(TypeBoolean);
+
+  config_setting_set_bool(_setting, value);
+
+  return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(int value) throw(SettingTypeException)
+{
+  assertType(TypeInt);
+
+  config_setting_set_int(_setting, value);
+
+  return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(long value) throw(SettingTypeException)
+{
+  if(sizeof(long) == sizeof(long long))
+    return(operator=(static_cast<long long>(value)));
+  else
+    return(operator=(static_cast<int>(value)));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(const long long &value)
+  throw(SettingTypeException)
+{
+  assertType(TypeInt64);
+
+  config_setting_set_int64(_setting, value);
+
+  return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(const double &value) throw(SettingTypeException)
+{
+  assertType(TypeFloat);
+
+  config_setting_set_float(_setting, value);
+
+  return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(float value) throw(SettingTypeException)
+{
+  assertType(TypeFloat);
+
+  double cvalue = static_cast<double>(value);
+
+  config_setting_set_float(_setting, cvalue);
+
+  return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(const char *value) throw(SettingTypeException)
+{
+  assertType(TypeString);
+
+  config_setting_set_string(_setting, value);
+
+  return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(const std::string &value)
+  throw(SettingTypeException)
+{
+  assertType(TypeString);
+
+  config_setting_set_string(_setting, value.c_str());
+
+  return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator[](int i) const
+  throw(SettingTypeException, SettingNotFoundException)
+{
+  if((_type != TypeArray) && (_type != TypeGroup) && (_type != TypeList))
+    throw SettingTypeException(*this, i);
+
+  config_setting_t *setting = config_setting_get_elem(_setting, i);
+
+  if(! setting)
+    throw SettingNotFoundException(*this, i);
+
+  return(wrapSetting(setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator[](const char *key) const
+  throw(SettingTypeException, SettingNotFoundException)
+{
+  assertType(TypeGroup);
+
+  config_setting_t *setting = config_setting_get_member(_setting, key);
+
+  if(! setting)
+    throw SettingNotFoundException(*this, key);
+
+  return(wrapSetting(setting));
+}
+
+// ---------------------------------------------------------------------------
+
+#define SETTING_LOOKUP_NO_EXCEPTIONS(K, T, V)   \
+  try                                           \
+  {                                             \
+    Setting &s = operator[](K);                 \
+    V = (T)s;                                   \
+    return(true);                               \
+  }                                             \
+  catch(ConfigException)                        \
+  {                                             \
+    return(false);                              \
+  }
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, bool &value) const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, bool, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, int &value) const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, int, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, unsigned int &value)
+  const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, unsigned int, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, long long &value) const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, long long, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, unsigned long long &value)
+  const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, unsigned long long, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, double &value) const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, double, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, float &value) const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, float, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, const char *&value) const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, const char *, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, std::string &value) const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, const char *, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::exists(const char *name) const throw()
+{
+  if(_type != TypeGroup)
+    return(false);
+
+  config_setting_t *setting = config_setting_get_member(_setting, name);
+
+  return(setting != NULL);
+}
+
+// ---------------------------------------------------------------------------
+
+int Setting::getLength() const throw()
+{
+  return(config_setting_length(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+const char * Setting::getName() const throw()
+{
+  return(config_setting_name(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+std::string Setting::getPath() const
+{
+  std::stringstream path;
+
+  __constructPath(*this, path);
+
+  return(path.str());
+}
+
+// ---------------------------------------------------------------------------
+
+const Setting & Setting::getParent() const throw(SettingNotFoundException)
+{
+  config_setting_t *setting = config_setting_parent(_setting);
+
+  if(! setting)
+    throw SettingNotFoundException(NULL);
+
+  return(wrapSetting(setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::getParent() throw(SettingNotFoundException)
+{
+  config_setting_t *setting = config_setting_parent(_setting);
+
+  if(! setting)
+    throw SettingNotFoundException(NULL);
+
+  return(wrapSetting(setting));
+}
+
+// ---------------------------------------------------------------------------
+
+unsigned int Setting::getSourceLine() const throw()
+{
+  return(config_setting_source_line(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+const char *Setting::getSourceFile() const throw()
+{
+  return(config_setting_source_file(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::isRoot() const throw()
+{
+  return(config_setting_is_root(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+int Setting::getIndex() const throw()
+{
+  return(config_setting_index(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+void Setting::remove(const char *name)
+  throw(SettingTypeException, SettingNotFoundException)
+{
+  assertType(TypeGroup);
+
+  if(! config_setting_remove(_setting, name))
+    throw SettingNotFoundException(*this, name);
+}
+
+// ---------------------------------------------------------------------------
+
+void Setting::remove(unsigned int idx)
+  throw(SettingTypeException, SettingNotFoundException)
+{
+  if((_type != TypeArray) && (_type != TypeGroup) && (_type != TypeList))
+    throw SettingTypeException(*this, idx);
+
+  if(! config_setting_remove_elem(_setting, idx))
+    throw SettingNotFoundException(*this, idx);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::add(const char *name, Setting::Type type)
+  throw(SettingNameException, SettingTypeException)
+{
+  assertType(TypeGroup);
+
+  int typecode = __toTypeCode(type);
+
+  if(typecode == CONFIG_TYPE_NONE)
+    throw SettingTypeException(*this, name);
+
+  config_setting_t *setting = config_setting_add(_setting, name, typecode);
+
+  if(! setting)
+    throw SettingNameException(*this, name);
+
+  return(wrapSetting(setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::add(Setting::Type type) throw(SettingTypeException)
+{
+  if((_type != TypeArray) && (_type != TypeList))
+    throw SettingTypeException(*this);
+
+  if(_type == TypeArray)
+  {
+    int idx = getLength();
+
+    if(idx > 0)
+    {
+      Setting::Type atype = operator[](0).getType();
+      if(type != atype)
+        throw SettingTypeException(*this, idx);
+    }
+    else
+    {
+      if((type != TypeInt) && (type != TypeFloat) && (type != TypeString)
+         && (type != TypeBoolean))
+        throw SettingTypeException(*this, idx);
+    }
+  }
+
+  int typecode = __toTypeCode(type);
+  config_setting_t *s = config_setting_add(_setting, NULL, typecode);
+
+  Setting &ns = wrapSetting(s);
+
+  switch(type)
+  {
+    case TypeInt:
+      ns = 0;
+      break;
+
+    case TypeInt64:
+      ns = INT64_CONST(0);
+      break;
+
+    case TypeFloat:
+      ns = 0.0;
+      break;
+
+    case TypeString:
+      ns = (char *)NULL;
+      break;
+
+    case TypeBoolean:
+      ns = false;
+      break;
+
+    default:
+      // won't happen
+      break;
+  }
+
+  return(ns);
+}
+
+// ---------------------------------------------------------------------------
+
+void Setting::assertType(Setting::Type type) const throw(SettingTypeException)
+{
+  if(type != _type)
+  {
+    if(!(isNumber() && config_get_auto_convert(_setting->config)
+         && ((type == TypeInt) || (type == TypeFloat))))
+      throw SettingTypeException(*this);
+  }
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::wrapSetting(config_setting_t *s)
+{
+  Setting *setting = NULL;
+
+  void *hook = config_setting_get_hook(s);
+  if(! hook)
+  {
+    setting = new Setting(s);
+    config_setting_set_hook(s, reinterpret_cast<void *>(setting));
+  }
+  else
+    setting = reinterpret_cast<Setting *>(hook);
+
+  return(*setting);
+}
+
+// ---------------------------------------------------------------------------
+
+*/
+
+}; // namespace libconfig
+
+
+/* ----------------------------------------------------------------------------
+
+   This file is a mex clone of libconfigcpp.cc originally found 
+   in the libconfig library which was desgigned by Mark A Lindner.
+   
+   ----------------------------------------------------------------------------
+*/
+
+
+#include "libconfig_mex.h"
+
+#ifdef _MSC_VER
+#pragma warning (disable: 4996)
+#endif
+
+//#include "wincompat.h"
+
+#include <cstring>
+#include <cstdlib>
+#include <sstream>
+
+namespace libconfig {
+
+	/*
+// ---------------------------------------------------------------------------
+
+ParseException::ParseException(const char *file, int line, const char *error)
+  : _file(strdup(file)), _line(line), _error(error)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+ParseException::~ParseException() throw()
+{
+  free((void *)_file);
+}
+
+// ---------------------------------------------------------------------------
+
+const char *ParseException::what() const throw()
+{
+  return("ParseException");
+}
+
+// ---------------------------------------------------------------------------
+
+static int __toTypeCode(Setting::Type type)
+{
+  int typecode;
+
+  switch(type)
+  {
+    case Setting::TypeGroup:
+      typecode = CONFIG_TYPE_GROUP;
+      break;
+
+    case Setting::TypeInt:
+      typecode = CONFIG_TYPE_INT;
+      break;
+
+    case Setting::TypeInt64:
+      typecode = CONFIG_TYPE_INT64;
+      break;
+
+    case Setting::TypeFloat:
+      typecode = CONFIG_TYPE_FLOAT;
+      break;
+
+    case Setting::TypeString:
+      typecode = CONFIG_TYPE_STRING;
+      break;
+
+    case Setting::TypeBoolean:
+      typecode = CONFIG_TYPE_BOOL;
+      break;
+
+    case Setting::TypeArray:
+      typecode = CONFIG_TYPE_ARRAY;
+      break;
+
+    case Setting::TypeList:
+      typecode = CONFIG_TYPE_LIST;
+      break;
+
+    default:
+      typecode = CONFIG_TYPE_NONE;
+  }
+
+  return(typecode);
+}
+
+// ---------------------------------------------------------------------------
+
+static void __constructPath(const Setting &setting,
+                            std::stringstream &path)
+{
+  // head recursion to print path from root to target
+
+  if(! setting.isRoot())
+  {
+    __constructPath(setting.getParent(), path);
+    if(path.tellp() > 0)
+      path << '.';
+
+    const char *name = setting.getName();
+    if(name)
+      path << name;
+    else
+      path << '[' << setting.getIndex() << ']';
+  }
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException::SettingException(const Setting &setting)
+{
+  std::stringstream sstr;
+  __constructPath(setting, sstr);
+
+  _path = ::strdup(sstr.str().c_str());
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException::SettingException(const Setting &setting, int idx)
+{
+  std::stringstream sstr;
+  __constructPath(setting, sstr);
+  sstr << ".[" << idx << "]";
+
+  _path = ::strdup(sstr.str().c_str());
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException::SettingException(const Setting &setting, const char *name)
+{
+  std::stringstream sstr;
+  __constructPath(setting, sstr);
+  sstr << '.' << name;
+
+  _path = ::strdup(sstr.str().c_str());
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException::SettingException(const char *path)
+{
+  _path = ::strdup(path);
+}
+
+// ---------------------------------------------------------------------------
+
+const char *SettingException::getPath() const
+{
+  return(_path);
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException::SettingException(const SettingException &other)
+{
+  _path = ::strdup(other._path);
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException &SettingException::operator=(const SettingException &other)
+{
+  ::free(_path);
+  _path = ::strdup(other._path);
+
+  return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+const char *SettingException::what() const throw()
+{
+  return("SettingException");
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException::~SettingException() throw()
+{
+  ::free(_path);
+}
+
+// ---------------------------------------------------------------------------
+
+SettingTypeException::SettingTypeException(const Setting &setting)
+  : SettingException(setting)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+SettingTypeException::SettingTypeException(const Setting &setting, int idx)
+  : SettingException(setting, idx)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+SettingTypeException::SettingTypeException(const Setting &setting,
+                                           const char *name)
+  : SettingException(setting, name)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+const char *SettingTypeException::what() const throw()
+{
+  return("SettingTypeException");
+}
+
+// ---------------------------------------------------------------------------
+
+SettingNotFoundException::SettingNotFoundException(const Setting &setting,
+                                                   int idx)
+  : SettingException(setting, idx)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+SettingNotFoundException::SettingNotFoundException(const Setting &setting,
+                                                   const char *name)
+  : SettingException(setting, name)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+SettingNotFoundException::SettingNotFoundException(const char *path)
+  : SettingException(path)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+const char *SettingNotFoundException::what() const throw()
+{
+  return("SettingNotFoundException");
+}
+
+// ---------------------------------------------------------------------------
+
+SettingNameException::SettingNameException(const Setting &setting,
+                                           const char *name)
+  : SettingException(setting, name)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+const char *SettingNameException::what() const throw()
+{
+  return("SettingNameException");
+}
+
+// ---------------------------------------------------------------------------
+
+const char *FileIOException::what() const throw()
+{
+  return("FileIOException");
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::ConfigDestructor(void *arg)
+{
+  delete reinterpret_cast<Setting *>(arg);
+}
+
+// ---------------------------------------------------------------------------
+
+Config::Config()
+{
+  _config = new config_t;
+  config_init(_config);
+  config_set_destructor(_config, ConfigDestructor);
+}
+
+// ---------------------------------------------------------------------------
+
+Config::~Config()
+{
+  config_destroy(_config);
+  delete _config;
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::setAutoConvert(bool flag)
+{
+  config_set_auto_convert(_config, (flag ? CONFIG_TRUE : CONFIG_FALSE));
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::getAutoConvert() const
+{
+  return(config_get_auto_convert(_config) != CONFIG_FALSE);
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::setTabWidth(unsigned short width) throw()
+{
+  config_set_tab_width(_config, width);
+}
+
+// ---------------------------------------------------------------------------
+
+unsigned short Config::getTabWidth() const throw()
+{
+  return(config_get_tab_width(_config));
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::handleError() const
+{
+  switch(config_error_type(_config))
+  {
+    case CONFIG_ERR_NONE:
+      break;
+    
+    case CONFIG_ERR_PARSE:
+      throw ParseException(config_error_file(_config),
+                           config_error_line(_config),
+                           config_error_text(_config));
+      break;
+
+    case CONFIG_ERR_FILE_IO:
+    default:
+      throw FileIOException();
+  }
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::read(FILE *stream) throw(ParseException)
+{
+  if(! config_read(_config, stream))
+    handleError();
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::readString(const char *str) throw(ParseException)
+{
+  if(! config_read_string(_config, str))
+    handleError();
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::write(FILE *stream) const
+{
+  config_write(_config, stream);
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::readFile(const char *filename) throw(FileIOException,
+                                                  ParseException)
+{
+  if(! config_read_file(_config, filename))
+    handleError();
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::writeFile(const char *filename) throw(FileIOException)
+{
+  if(! config_write_file(_config, filename))
+    handleError();
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Config::lookup(const char *path) const
+  throw(SettingNotFoundException)
+{
+  config_setting_t *s = config_lookup(_config, path);
+  if(! s)
+    throw SettingNotFoundException(path);
+
+  return(Setting::wrapSetting(s));
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::exists(const char *path) const throw()
+{
+  config_setting_t *s = config_lookup(_config, path);
+
+  return(s != NULL);
+}
+
+// ---------------------------------------------------------------------------
+
+#define CONFIG_LOOKUP_NO_EXCEPTIONS(P, T, V)    \
+  try                                           \
+  {                                             \
+    Setting &s = lookup(P);                     \
+    V = (T)s;                                   \
+    return(true);                               \
+  }                                             \
+  catch(ConfigException)                        \
+  {                                             \
+    return(false);                              \
+  }
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, bool &value) const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, bool, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, int &value) const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, int, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, unsigned int &value) const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, unsigned int, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, long long &value) const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, long long, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, unsigned long long &value)
+  const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, unsigned long long, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, double &value) const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, double, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, float &value) const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, float, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, const char *&value) const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, const char *, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, std::string &value) const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, const char *, value);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Config::getRoot() const
+{
+  return(Setting::wrapSetting(config_root_setting(_config)));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::Setting(config_setting_t *setting)
+  : _setting(setting)
+{
+  switch(config_setting_type(setting))
+  {
+    case CONFIG_TYPE_GROUP:
+      _type = TypeGroup;
+      break;
+
+    case CONFIG_TYPE_INT:
+      _type = TypeInt;
+      break;
+
+    case CONFIG_TYPE_INT64:
+      _type = TypeInt64;
+      break;
+
+    case CONFIG_TYPE_FLOAT:
+      _type = TypeFloat;
+      break;
+
+    case CONFIG_TYPE_STRING:
+      _type = TypeString;
+      break;
+
+    case CONFIG_TYPE_BOOL:
+      _type = TypeBoolean;
+      break;
+
+    case CONFIG_TYPE_ARRAY:
+      _type = TypeArray;
+      break;
+
+    case CONFIG_TYPE_LIST:
+      _type = TypeList;
+      break;
+
+    case CONFIG_TYPE_NONE:
+    default:
+      _type = TypeNone;
+      break;
+  }
+
+  switch(config_setting_get_format(setting))
+  {
+    case CONFIG_FORMAT_HEX:
+      _format = FormatHex;
+      break;
+
+    case CONFIG_FORMAT_DEFAULT:
+    default:
+      _format = FormatDefault;
+      break;
+  }
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::~Setting() throw()
+{
+  _setting = NULL;
+}
+
+// ---------------------------------------------------------------------------
+
+void Setting::setFormat(Format format) throw()
+{
+  if((_type == TypeInt) || (_type == TypeInt64))
+  {
+    if(format == FormatHex)
+      _format = FormatHex;
+    else
+      _format = FormatDefault;
+  }
+  else
+    _format = FormatDefault;
+
+  config_setting_set_format(_setting, static_cast<short>(_format));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator bool() const throw(SettingTypeException) 
+{
+  assertType(TypeBoolean);
+
+  return(config_setting_get_bool(_setting) ? true : false);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator int() const throw(SettingTypeException)
+{
+  assertType(TypeInt);
+
+  return(config_setting_get_int(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator unsigned int() const throw(SettingTypeException)
+{
+  assertType(TypeInt);
+
+  int v = config_setting_get_int(_setting);
+
+  if(v < 0)
+    v = 0;
+
+  return(static_cast<unsigned int>(v));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator long() const throw(SettingTypeException)
+{
+  if(sizeof(long) == sizeof(long long))
+    return operator long long();
+  else
+    return operator int();
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator unsigned long() const throw(SettingTypeException)
+{
+  if(sizeof(long) == sizeof(long long))
+    return operator unsigned long long();
+  else
+    return operator unsigned int();
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator long long() const throw(SettingTypeException)
+{
+  assertType(TypeInt64);
+
+  return(config_setting_get_int64(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator unsigned long long() const throw(SettingTypeException)
+{
+  assertType(TypeInt64);
+
+  long long v = config_setting_get_int64(_setting);
+
+  if(v < INT64_CONST(0))
+    v = INT64_CONST(0);
+
+  return(static_cast<unsigned long long>(v));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator double() const throw(SettingTypeException)
+{
+  assertType(TypeFloat);
+
+  return(config_setting_get_float(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator float() const throw(SettingTypeException)
+{
+  assertType(TypeFloat);
+
+  // may cause loss of precision:
+  return(static_cast<float>(config_setting_get_float(_setting)));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator const char *() const throw(SettingTypeException)
+{
+  assertType(TypeString);
+
+  return(config_setting_get_string(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator std::string() const throw(SettingTypeException)
+{
+  assertType(TypeString);
+
+  const char *s = config_setting_get_string(_setting);
+
+  std::string str;
+  if(s)
+    str = s;
+
+  return(str);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(bool value) throw(SettingTypeException)
+{
+  assertType(TypeBoolean);
+
+  config_setting_set_bool(_setting, value);
+
+  return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(int value) throw(SettingTypeException)
+{
+  assertType(TypeInt);
+
+  config_setting_set_int(_setting, value);
+
+  return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(long value) throw(SettingTypeException)
+{
+  if(sizeof(long) == sizeof(long long))
+    return(operator=(static_cast<long long>(value)));
+  else
+    return(operator=(static_cast<int>(value)));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(const long long &value)
+  throw(SettingTypeException)
+{
+  assertType(TypeInt64);
+
+  config_setting_set_int64(_setting, value);
+
+  return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(const double &value) throw(SettingTypeException)
+{
+  assertType(TypeFloat);
+
+  config_setting_set_float(_setting, value);
+
+  return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(float value) throw(SettingTypeException)
+{
+  assertType(TypeFloat);
+
+  double cvalue = static_cast<double>(value);
+
+  config_setting_set_float(_setting, cvalue);
+
+  return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(const char *value) throw(SettingTypeException)
+{
+  assertType(TypeString);
+
+  config_setting_set_string(_setting, value);
+
+  return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(const std::string &value)
+  throw(SettingTypeException)
+{
+  assertType(TypeString);
+
+  config_setting_set_string(_setting, value.c_str());
+
+  return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator[](int i) const
+  throw(SettingTypeException, SettingNotFoundException)
+{
+  if((_type != TypeArray) && (_type != TypeGroup) && (_type != TypeList))
+    throw SettingTypeException(*this, i);
+
+  config_setting_t *setting = config_setting_get_elem(_setting, i);
+
+  if(! setting)
+    throw SettingNotFoundException(*this, i);
+
+  return(wrapSetting(setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator[](const char *key) const
+  throw(SettingTypeException, SettingNotFoundException)
+{
+  assertType(TypeGroup);
+
+  config_setting_t *setting = config_setting_get_member(_setting, key);
+
+  if(! setting)
+    throw SettingNotFoundException(*this, key);
+
+  return(wrapSetting(setting));
+}
+
+// ---------------------------------------------------------------------------
+
+#define SETTING_LOOKUP_NO_EXCEPTIONS(K, T, V)   \
+  try                                           \
+  {                                             \
+    Setting &s = operator[](K);                 \
+    V = (T)s;                                   \
+    return(true);                               \
+  }                                             \
+  catch(ConfigException)                        \
+  {                                             \
+    return(false);                              \
+  }
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, bool &value) const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, bool, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, int &value) const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, int, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, unsigned int &value)
+  const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, unsigned int, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, long long &value) const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, long long, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, unsigned long long &value)
+  const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, unsigned long long, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, double &value) const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, double, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, float &value) const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, float, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, const char *&value) const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, const char *, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, std::string &value) const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, const char *, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::exists(const char *name) const throw()
+{
+  if(_type != TypeGroup)
+    return(false);
+
+  config_setting_t *setting = config_setting_get_member(_setting, name);
+
+  return(setting != NULL);
+}
+
+// ---------------------------------------------------------------------------
+
+int Setting::getLength() const throw()
+{
+  return(config_setting_length(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+const char * Setting::getName() const throw()
+{
+  return(config_setting_name(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+std::string Setting::getPath() const
+{
+  std::stringstream path;
+
+  __constructPath(*this, path);
+
+  return(path.str());
+}
+
+// ---------------------------------------------------------------------------
+
+const Setting & Setting::getParent() const throw(SettingNotFoundException)
+{
+  config_setting_t *setting = config_setting_parent(_setting);
+
+  if(! setting)
+    throw SettingNotFoundException(NULL);
+
+  return(wrapSetting(setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::getParent() throw(SettingNotFoundException)
+{
+  config_setting_t *setting = config_setting_parent(_setting);
+
+  if(! setting)
+    throw SettingNotFoundException(NULL);
+
+  return(wrapSetting(setting));
+}
+
+// ---------------------------------------------------------------------------
+
+unsigned int Setting::getSourceLine() const throw()
+{
+  return(config_setting_source_line(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+const char *Setting::getSourceFile() const throw()
+{
+  return(config_setting_source_file(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::isRoot() const throw()
+{
+  return(config_setting_is_root(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+int Setting::getIndex() const throw()
+{
+  return(config_setting_index(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+void Setting::remove(const char *name)
+  throw(SettingTypeException, SettingNotFoundException)
+{
+  assertType(TypeGroup);
+
+  if(! config_setting_remove(_setting, name))
+    throw SettingNotFoundException(*this, name);
+}
+
+// ---------------------------------------------------------------------------
+
+void Setting::remove(unsigned int idx)
+  throw(SettingTypeException, SettingNotFoundException)
+{
+  if((_type != TypeArray) && (_type != TypeGroup) && (_type != TypeList))
+    throw SettingTypeException(*this, idx);
+
+  if(! config_setting_remove_elem(_setting, idx))
+    throw SettingNotFoundException(*this, idx);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::add(const char *name, Setting::Type type)
+  throw(SettingNameException, SettingTypeException)
+{
+  assertType(TypeGroup);
+
+  int typecode = __toTypeCode(type);
+
+  if(typecode == CONFIG_TYPE_NONE)
+    throw SettingTypeException(*this, name);
+
+  config_setting_t *setting = config_setting_add(_setting, name, typecode);
+
+  if(! setting)
+    throw SettingNameException(*this, name);
+
+  return(wrapSetting(setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::add(Setting::Type type) throw(SettingTypeException)
+{
+  if((_type != TypeArray) && (_type != TypeList))
+    throw SettingTypeException(*this);
+
+  if(_type == TypeArray)
+  {
+    int idx = getLength();
+
+    if(idx > 0)
+    {
+      Setting::Type atype = operator[](0).getType();
+      if(type != atype)
+        throw SettingTypeException(*this, idx);
+    }
+    else
+    {
+      if((type != TypeInt) && (type != TypeFloat) && (type != TypeString)
+         && (type != TypeBoolean))
+        throw SettingTypeException(*this, idx);
+    }
+  }
+
+  int typecode = __toTypeCode(type);
+  config_setting_t *s = config_setting_add(_setting, NULL, typecode);
+
+  Setting &ns = wrapSetting(s);
+
+  switch(type)
+  {
+    case TypeInt:
+      ns = 0;
+      break;
+
+    case TypeInt64:
+      ns = INT64_CONST(0);
+      break;
+
+    case TypeFloat:
+      ns = 0.0;
+      break;
+
+    case TypeString:
+      ns = (char *)NULL;
+      break;
+
+    case TypeBoolean:
+      ns = false;
+      break;
+
+    default:
+      // won't happen
+      break;
+  }
+
+  return(ns);
+}
+
+// ---------------------------------------------------------------------------
+
+void Setting::assertType(Setting::Type type) const throw(SettingTypeException)
+{
+  if(type != _type)
+  {
+    if(!(isNumber() && config_get_auto_convert(_setting->config)
+         && ((type == TypeInt) || (type == TypeFloat))))
+      throw SettingTypeException(*this);
+  }
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::wrapSetting(config_setting_t *s)
+{
+  Setting *setting = NULL;
+
+  void *hook = config_setting_get_hook(s);
+  if(! hook)
+  {
+    setting = new Setting(s);
+    config_setting_set_hook(s, reinterpret_cast<void *>(setting));
+  }
+  else
+    setting = reinterpret_cast<Setting *>(hook);
+
+  return(*setting);
+}
+
+// ---------------------------------------------------------------------------
+
+*/
+
+}; // namespace libconfig
+
+
+/* ----------------------------------------------------------------------------
+
+   This file is a mex clone of libconfigcpp.cc originally found 
+   in the libconfig library which was desgigned by Mark A Lindner.
+   
+   ----------------------------------------------------------------------------
+*/
+
+
+#include "libconfig_mex.h"
+
+#ifdef _MSC_VER
+#pragma warning (disable: 4996)
+#endif
+
+//#include "wincompat.h"
+
+#include <cstring>
+#include <cstdlib>
+#include <sstream>
+
+namespace libconfig {
+
+	/*
+// ---------------------------------------------------------------------------
+
+ParseException::ParseException(const char *file, int line, const char *error)
+  : _file(strdup(file)), _line(line), _error(error)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+ParseException::~ParseException() throw()
+{
+  free((void *)_file);
+}
+
+// ---------------------------------------------------------------------------
+
+const char *ParseException::what() const throw()
+{
+  return("ParseException");
+}
+
+// ---------------------------------------------------------------------------
+
+static int __toTypeCode(Setting::Type type)
+{
+  int typecode;
+
+  switch(type)
+  {
+    case Setting::TypeGroup:
+      typecode = CONFIG_TYPE_GROUP;
+      break;
+
+    case Setting::TypeInt:
+      typecode = CONFIG_TYPE_INT;
+      break;
+
+    case Setting::TypeInt64:
+      typecode = CONFIG_TYPE_INT64;
+      break;
+
+    case Setting::TypeFloat:
+      typecode = CONFIG_TYPE_FLOAT;
+      break;
+
+    case Setting::TypeString:
+      typecode = CONFIG_TYPE_STRING;
+      break;
+
+    case Setting::TypeBoolean:
+      typecode = CONFIG_TYPE_BOOL;
+      break;
+
+    case Setting::TypeArray:
+      typecode = CONFIG_TYPE_ARRAY;
+      break;
+
+    case Setting::TypeList:
+      typecode = CONFIG_TYPE_LIST;
+      break;
+
+    default:
+      typecode = CONFIG_TYPE_NONE;
+  }
+
+  return(typecode);
+}
+
+// ---------------------------------------------------------------------------
+
+static void __constructPath(const Setting &setting,
+                            std::stringstream &path)
+{
+  // head recursion to print path from root to target
+
+  if(! setting.isRoot())
+  {
+    __constructPath(setting.getParent(), path);
+    if(path.tellp() > 0)
+      path << '.';
+
+    const char *name = setting.getName();
+    if(name)
+      path << name;
+    else
+      path << '[' << setting.getIndex() << ']';
+  }
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException::SettingException(const Setting &setting)
+{
+  std::stringstream sstr;
+  __constructPath(setting, sstr);
+
+  _path = ::strdup(sstr.str().c_str());
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException::SettingException(const Setting &setting, int idx)
+{
+  std::stringstream sstr;
+  __constructPath(setting, sstr);
+  sstr << ".[" << idx << "]";
+
+  _path = ::strdup(sstr.str().c_str());
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException::SettingException(const Setting &setting, const char *name)
+{
+  std::stringstream sstr;
+  __constructPath(setting, sstr);
+  sstr << '.' << name;
+
+  _path = ::strdup(sstr.str().c_str());
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException::SettingException(const char *path)
+{
+  _path = ::strdup(path);
+}
+
+// ---------------------------------------------------------------------------
+
+const char *SettingException::getPath() const
+{
+  return(_path);
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException::SettingException(const SettingException &other)
+{
+  _path = ::strdup(other._path);
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException &SettingException::operator=(const SettingException &other)
+{
+  ::free(_path);
+  _path = ::strdup(other._path);
+
+  return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+const char *SettingException::what() const throw()
+{
+  return("SettingException");
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException::~SettingException() throw()
+{
+  ::free(_path);
+}
+
+// ---------------------------------------------------------------------------
+
+SettingTypeException::SettingTypeException(const Setting &setting)
+  : SettingException(setting)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+SettingTypeException::SettingTypeException(const Setting &setting, int idx)
+  : SettingException(setting, idx)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+SettingTypeException::SettingTypeException(const Setting &setting,
+                                           const char *name)
+  : SettingException(setting, name)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+const char *SettingTypeException::what() const throw()
+{
+  return("SettingTypeException");
+}
+
+// ---------------------------------------------------------------------------
+
+SettingNotFoundException::SettingNotFoundException(const Setting &setting,
+                                                   int idx)
+  : SettingException(setting, idx)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+SettingNotFoundException::SettingNotFoundException(const Setting &setting,
+                                                   const char *name)
+  : SettingException(setting, name)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+SettingNotFoundException::SettingNotFoundException(const char *path)
+  : SettingException(path)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+const char *SettingNotFoundException::what() const throw()
+{
+  return("SettingNotFoundException");
+}
+
+// ---------------------------------------------------------------------------
+
+SettingNameException::SettingNameException(const Setting &setting,
+                                           const char *name)
+  : SettingException(setting, name)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+const char *SettingNameException::what() const throw()
+{
+  return("SettingNameException");
+}
+
+// ---------------------------------------------------------------------------
+
+const char *FileIOException::what() const throw()
+{
+  return("FileIOException");
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::ConfigDestructor(void *arg)
+{
+  delete reinterpret_cast<Setting *>(arg);
+}
+
+// ---------------------------------------------------------------------------
+
+Config::Config()
+{
+  _config = new config_t;
+  config_init(_config);
+  config_set_destructor(_config, ConfigDestructor);
+}
+
+// ---------------------------------------------------------------------------
+
+Config::~Config()
+{
+  config_destroy(_config);
+  delete _config;
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::setAutoConvert(bool flag)
+{
+  config_set_auto_convert(_config, (flag ? CONFIG_TRUE : CONFIG_FALSE));
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::getAutoConvert() const
+{
+  return(config_get_auto_convert(_config) != CONFIG_FALSE);
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::setTabWidth(unsigned short width) throw()
+{
+  config_set_tab_width(_config, width);
+}
+
+// ---------------------------------------------------------------------------
+
+unsigned short Config::getTabWidth() const throw()
+{
+  return(config_get_tab_width(_config));
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::handleError() const
+{
+  switch(config_error_type(_config))
+  {
+    case CONFIG_ERR_NONE:
+      break;
+    
+    case CONFIG_ERR_PARSE:
+      throw ParseException(config_error_file(_config),
+                           config_error_line(_config),
+                           config_error_text(_config));
+      break;
+
+    case CONFIG_ERR_FILE_IO:
+    default:
+      throw FileIOException();
+  }
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::read(FILE *stream) throw(ParseException)
+{
+  if(! config_read(_config, stream))
+    handleError();
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::readString(const char *str) throw(ParseException)
+{
+  if(! config_read_string(_config, str))
+    handleError();
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::write(FILE *stream) const
+{
+  config_write(_config, stream);
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::readFile(const char *filename) throw(FileIOException,
+                                                  ParseException)
+{
+  if(! config_read_file(_config, filename))
+    handleError();
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::writeFile(const char *filename) throw(FileIOException)
+{
+  if(! config_write_file(_config, filename))
+    handleError();
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Config::lookup(const char *path) const
+  throw(SettingNotFoundException)
+{
+  config_setting_t *s = config_lookup(_config, path);
+  if(! s)
+    throw SettingNotFoundException(path);
+
+  return(Setting::wrapSetting(s));
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::exists(const char *path) const throw()
+{
+  config_setting_t *s = config_lookup(_config, path);
+
+  return(s != NULL);
+}
+
+// ---------------------------------------------------------------------------
+
+#define CONFIG_LOOKUP_NO_EXCEPTIONS(P, T, V)    \
+  try                                           \
+  {                                             \
+    Setting &s = lookup(P);                     \
+    V = (T)s;                                   \
+    return(true);                               \
+  }                                             \
+  catch(ConfigException)                        \
+  {                                             \
+    return(false);                              \
+  }
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, bool &value) const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, bool, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, int &value) const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, int, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, unsigned int &value) const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, unsigned int, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, long long &value) const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, long long, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, unsigned long long &value)
+  const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, unsigned long long, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, double &value) const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, double, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, float &value) const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, float, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, const char *&value) const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, const char *, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, std::string &value) const throw()
+{
+  CONFIG_LOOKUP_NO_EXCEPTIONS(path, const char *, value);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Config::getRoot() const
+{
+  return(Setting::wrapSetting(config_root_setting(_config)));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::Setting(config_setting_t *setting)
+  : _setting(setting)
+{
+  switch(config_setting_type(setting))
+  {
+    case CONFIG_TYPE_GROUP:
+      _type = TypeGroup;
+      break;
+
+    case CONFIG_TYPE_INT:
+      _type = TypeInt;
+      break;
+
+    case CONFIG_TYPE_INT64:
+      _type = TypeInt64;
+      break;
+
+    case CONFIG_TYPE_FLOAT:
+      _type = TypeFloat;
+      break;
+
+    case CONFIG_TYPE_STRING:
+      _type = TypeString;
+      break;
+
+    case CONFIG_TYPE_BOOL:
+      _type = TypeBoolean;
+      break;
+
+    case CONFIG_TYPE_ARRAY:
+      _type = TypeArray;
+      break;
+
+    case CONFIG_TYPE_LIST:
+      _type = TypeList;
+      break;
+
+    case CONFIG_TYPE_NONE:
+    default:
+      _type = TypeNone;
+      break;
+  }
+
+  switch(config_setting_get_format(setting))
+  {
+    case CONFIG_FORMAT_HEX:
+      _format = FormatHex;
+      break;
+
+    case CONFIG_FORMAT_DEFAULT:
+    default:
+      _format = FormatDefault;
+      break;
+  }
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::~Setting() throw()
+{
+  _setting = NULL;
+}
+
+// ---------------------------------------------------------------------------
+
+void Setting::setFormat(Format format) throw()
+{
+  if((_type == TypeInt) || (_type == TypeInt64))
+  {
+    if(format == FormatHex)
+      _format = FormatHex;
+    else
+      _format = FormatDefault;
+  }
+  else
+    _format = FormatDefault;
+
+  config_setting_set_format(_setting, static_cast<short>(_format));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator bool() const throw(SettingTypeException) 
+{
+  assertType(TypeBoolean);
+
+  return(config_setting_get_bool(_setting) ? true : false);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator int() const throw(SettingTypeException)
+{
+  assertType(TypeInt);
+
+  return(config_setting_get_int(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator unsigned int() const throw(SettingTypeException)
+{
+  assertType(TypeInt);
+
+  int v = config_setting_get_int(_setting);
+
+  if(v < 0)
+    v = 0;
+
+  return(static_cast<unsigned int>(v));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator long() const throw(SettingTypeException)
+{
+  if(sizeof(long) == sizeof(long long))
+    return operator long long();
+  else
+    return operator int();
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator unsigned long() const throw(SettingTypeException)
+{
+  if(sizeof(long) == sizeof(long long))
+    return operator unsigned long long();
+  else
+    return operator unsigned int();
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator long long() const throw(SettingTypeException)
+{
+  assertType(TypeInt64);
+
+  return(config_setting_get_int64(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator unsigned long long() const throw(SettingTypeException)
+{
+  assertType(TypeInt64);
+
+  long long v = config_setting_get_int64(_setting);
+
+  if(v < INT64_CONST(0))
+    v = INT64_CONST(0);
+
+  return(static_cast<unsigned long long>(v));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator double() const throw(SettingTypeException)
+{
+  assertType(TypeFloat);
+
+  return(config_setting_get_float(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator float() const throw(SettingTypeException)
+{
+  assertType(TypeFloat);
+
+  // may cause loss of precision:
+  return(static_cast<float>(config_setting_get_float(_setting)));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator const char *() const throw(SettingTypeException)
+{
+  assertType(TypeString);
+
+  return(config_setting_get_string(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator std::string() const throw(SettingTypeException)
+{
+  assertType(TypeString);
+
+  const char *s = config_setting_get_string(_setting);
+
+  std::string str;
+  if(s)
+    str = s;
+
+  return(str);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(bool value) throw(SettingTypeException)
+{
+  assertType(TypeBoolean);
+
+  config_setting_set_bool(_setting, value);
+
+  return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(int value) throw(SettingTypeException)
+{
+  assertType(TypeInt);
+
+  config_setting_set_int(_setting, value);
+
+  return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(long value) throw(SettingTypeException)
+{
+  if(sizeof(long) == sizeof(long long))
+    return(operator=(static_cast<long long>(value)));
+  else
+    return(operator=(static_cast<int>(value)));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(const long long &value)
+  throw(SettingTypeException)
+{
+  assertType(TypeInt64);
+
+  config_setting_set_int64(_setting, value);
+
+  return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(const double &value) throw(SettingTypeException)
+{
+  assertType(TypeFloat);
+
+  config_setting_set_float(_setting, value);
+
+  return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(float value) throw(SettingTypeException)
+{
+  assertType(TypeFloat);
+
+  double cvalue = static_cast<double>(value);
+
+  config_setting_set_float(_setting, cvalue);
+
+  return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(const char *value) throw(SettingTypeException)
+{
+  assertType(TypeString);
+
+  config_setting_set_string(_setting, value);
+
+  return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(const std::string &value)
+  throw(SettingTypeException)
+{
+  assertType(TypeString);
+
+  config_setting_set_string(_setting, value.c_str());
+
+  return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator[](int i) const
+  throw(SettingTypeException, SettingNotFoundException)
+{
+  if((_type != TypeArray) && (_type != TypeGroup) && (_type != TypeList))
+    throw SettingTypeException(*this, i);
+
+  config_setting_t *setting = config_setting_get_elem(_setting, i);
+
+  if(! setting)
+    throw SettingNotFoundException(*this, i);
+
+  return(wrapSetting(setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator[](const char *key) const
+  throw(SettingTypeException, SettingNotFoundException)
+{
+  assertType(TypeGroup);
+
+  config_setting_t *setting = config_setting_get_member(_setting, key);
+
+  if(! setting)
+    throw SettingNotFoundException(*this, key);
+
+  return(wrapSetting(setting));
+}
+
+// ---------------------------------------------------------------------------
+
+#define SETTING_LOOKUP_NO_EXCEPTIONS(K, T, V)   \
+  try                                           \
+  {                                             \
+    Setting &s = operator[](K);                 \
+    V = (T)s;                                   \
+    return(true);                               \
+  }                                             \
+  catch(ConfigException)                        \
+  {                                             \
+    return(false);                              \
+  }
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, bool &value) const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, bool, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, int &value) const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, int, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, unsigned int &value)
+  const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, unsigned int, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, long long &value) const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, long long, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, unsigned long long &value)
+  const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, unsigned long long, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, double &value) const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, double, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, float &value) const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, float, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, const char *&value) const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, const char *, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, std::string &value) const throw()
+{
+  SETTING_LOOKUP_NO_EXCEPTIONS(name, const char *, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::exists(const char *name) const throw()
+{
+  if(_type != TypeGroup)
+    return(false);
+
+  config_setting_t *setting = config_setting_get_member(_setting, name);
+
+  return(setting != NULL);
+}
+
+// ---------------------------------------------------------------------------
+
+int Setting::getLength() const throw()
+{
+  return(config_setting_length(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+const char * Setting::getName() const throw()
+{
+  return(config_setting_name(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+std::string Setting::getPath() const
+{
+  std::stringstream path;
+
+  __constructPath(*this, path);
+
+  return(path.str());
+}
+
+// ---------------------------------------------------------------------------
+
+const Setting & Setting::getParent() const throw(SettingNotFoundException)
+{
+  config_setting_t *setting = config_setting_parent(_setting);
+
+  if(! setting)
+    throw SettingNotFoundException(NULL);
+
+  return(wrapSetting(setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::getParent() throw(SettingNotFoundException)
+{
+  config_setting_t *setting = config_setting_parent(_setting);
+
+  if(! setting)
+    throw SettingNotFoundException(NULL);
+
+  return(wrapSetting(setting));
+}
+
+// ---------------------------------------------------------------------------
+
+unsigned int Setting::getSourceLine() const throw()
+{
+  return(config_setting_source_line(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+const char *Setting::getSourceFile() const throw()
+{
+  return(config_setting_source_file(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::isRoot() const throw()
+{
+  return(config_setting_is_root(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+int Setting::getIndex() const throw()
+{
+  return(config_setting_index(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+void Setting::remove(const char *name)
+  throw(SettingTypeException, SettingNotFoundException)
+{
+  assertType(TypeGroup);
+
+  if(! config_setting_remove(_setting, name))
+    throw SettingNotFoundException(*this, name);
+}
+
+// ---------------------------------------------------------------------------
+
+void Setting::remove(unsigned int idx)
+  throw(SettingTypeException, SettingNotFoundException)
+{
+  if((_type != TypeArray) && (_type != TypeGroup) && (_type != TypeList))
+    throw SettingTypeException(*this, idx);
+
+  if(! config_setting_remove_elem(_setting, idx))
+    throw SettingNotFoundException(*this, idx);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::add(const char *name, Setting::Type type)
+  throw(SettingNameException, SettingTypeException)
+{
+  assertType(TypeGroup);
+
+  int typecode = __toTypeCode(type);
+
+  if(typecode == CONFIG_TYPE_NONE)
+    throw SettingTypeException(*this, name);
+
+  config_setting_t *setting = config_setting_add(_setting, name, typecode);
+
+  if(! setting)
+    throw SettingNameException(*this, name);
+
+  return(wrapSetting(setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::add(Setting::Type type) throw(SettingTypeException)
+{
+  if((_type != TypeArray) && (_type != TypeList))
+    throw SettingTypeException(*this);
+
+  if(_type == TypeArray)
+  {
+    int idx = getLength();
+
+    if(idx > 0)
+    {
+      Setting::Type atype = operator[](0).getType();
+      if(type != atype)
+        throw SettingTypeException(*this, idx);
+    }
+    else
+    {
+      if((type != TypeInt) && (type != TypeFloat) && (type != TypeString)
+         && (type != TypeBoolean))
+        throw SettingTypeException(*this, idx);
+    }
+  }
+
+  int typecode = __toTypeCode(type);
+  config_setting_t *s = config_setting_add(_setting, NULL, typecode);
+
+  Setting &ns = wrapSetting(s);
+
+  switch(type)
+  {
+    case TypeInt:
+      ns = 0;
+      break;
+
+    case TypeInt64:
+      ns = INT64_CONST(0);
+      break;
+
+    case TypeFloat:
+      ns = 0.0;
+      break;
+
+    case TypeString:
+      ns = (char *)NULL;
+      break;
+
+    case TypeBoolean:
+      ns = false;
+      break;
+
+    default:
+      // won't happen
+      break;
+  }
+
+  return(ns);
+}
+
+// ---------------------------------------------------------------------------
+
+void Setting::assertType(Setting::Type type) const throw(SettingTypeException)
+{
+  if(type != _type)
+  {
+    if(!(isNumber() && config_get_auto_convert(_setting->config)
+         && ((type == TypeInt) || (type == TypeFloat))))
+      throw SettingTypeException(*this);
+  }
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::wrapSetting(config_setting_t *s)
+{
+  Setting *setting = NULL;
+
+  void *hook = config_setting_get_hook(s);
+  if(! hook)
+  {
+    setting = new Setting(s);
+    config_setting_set_hook(s, reinterpret_cast<void *>(setting));
+  }
+  else
+    setting = reinterpret_cast<Setting *>(hook);
+
+  return(*setting);
+}
+
+// ---------------------------------------------------------------------------
+
+*/
+
+}; // namespace libconfig
+
+
Index: /library/bdm/base/libconfig_mex.h
===================================================================
--- /library/bdm/base/libconfig_mex.h (revision 789)
+++ /library/bdm/base/libconfig_mex.h (revision 789)
@@ -0,0 +1,419 @@
+/* ----------------------------------------------------------------------------
+
+	THE FILE IS UNDER THE CONSTRUCTION!
+
+   This file is a mex clone of libconfig.h++ originally found 
+   in the libconfig library which was desgigned by Mark A Lindner
+   
+   ----------------------------------------------------------------------------
+*/
+
+#ifndef LIBCONFIG_MEX_H
+#define LIBCONFIG_MEX_H
+
+#include <stdio.h>
+#include <string>
+#include <map>
+
+
+struct config_t; // fwd decl
+struct config_setting_t; // fwd decl
+
+namespace libconfig {
+
+class ConfigException : public std::exception { };
+
+class Setting; // fwd decl
+
+class SettingException : public ConfigException
+{
+  friend class Config;
+
+  public:
+
+  SettingException(const SettingException &other);
+  SettingException& operator=(const SettingException &other);
+
+  virtual ~SettingException() throw();
+
+  const char *getPath() const;
+
+  virtual const char *what() const throw();
+
+  protected:
+
+  SettingException(const Setting &setting);
+  SettingException(const Setting &setting, int idx);
+  SettingException(const Setting &setting, const char *name);
+  SettingException(const char *path);
+
+  private:
+
+  char *_path;
+};
+
+class SettingTypeException : public SettingException
+{
+  friend class Config;
+  friend class Setting;
+
+  public:
+
+  const char *what() const throw();
+
+  private:
+
+  SettingTypeException(const Setting &setting);
+  SettingTypeException(const Setting &setting, int idx);
+  SettingTypeException(const Setting &setting, const char *name);
+};
+
+class SettingNotFoundException : public SettingException
+{
+  friend class Config;
+  friend class Setting;
+
+  public:
+
+  const char *what() const throw();
+
+  private:
+
+  SettingNotFoundException(const Setting &setting, int idx);
+  SettingNotFoundException(const Setting &setting, const char *name);
+  SettingNotFoundException(const char *path);
+};
+
+class SettingNameException : public SettingException
+{
+  friend class Config;
+  friend class Setting;
+
+  public:
+
+  const char *what() const throw();
+
+  private:
+
+  SettingNameException(const Setting &setting, const char *name);
+};
+
+class FileIOException : public ConfigException
+{
+  public:
+
+  const char *what() const throw();
+};
+
+class ParseException : public ConfigException
+{
+  friend class Config;
+
+  public:
+
+  virtual ~ParseException() throw();
+
+  inline const char *getFile() const throw()
+  { return(_file); }
+
+  inline int getLine() const throw()
+  { return(_line); }
+
+  inline const char *getError() const throw()
+  { return(_error); }
+
+  const char *what() const throw();
+
+  private:
+
+  ParseException(const char *file, int line, const char *error);
+
+  const char *_file;
+  int _line;
+  const char *_error;
+};
+
+class Setting
+{
+  friend class Config;
+
+  public:
+
+  enum Type
+  {
+    TypeNone = 0,
+    // scalar types
+    TypeInt,
+    TypeInt64,
+    TypeFloat,
+    TypeString,
+    TypeBoolean,
+    // aggregate types
+    TypeGroup,
+    TypeArray,
+    TypeList
+  };
+
+  enum Format
+  {
+    FormatDefault = 0,
+    FormatHex = 1
+  };
+
+  private:
+
+  config_setting_t *_setting;
+  Type _type;
+  Format _format;
+
+  Setting(config_setting_t *setting);
+
+  void assertType(Type type) const
+    throw(SettingTypeException);
+  static Setting & wrapSetting(config_setting_t *setting);
+
+  Setting(const Setting& other); // not supported
+  Setting& operator=(const Setting& other); // not supported
+
+  public:
+
+  virtual ~Setting() throw();
+
+  inline Type getType() const throw() { return(_type); }
+
+  inline Format getFormat() const throw() { return(_format); }
+  void setFormat(Format format) throw();
+
+  operator bool() const throw(SettingTypeException);
+  operator int() const throw(SettingTypeException);
+  operator unsigned int() const throw(SettingTypeException);
+  operator long() const throw(SettingTypeException);
+  operator unsigned long() const throw(SettingTypeException);
+  operator long long() const throw(SettingTypeException);
+  operator unsigned long long() const throw(SettingTypeException);
+  operator double() const throw(SettingTypeException);
+  operator float() const throw(SettingTypeException);
+  operator const char *() const throw(SettingTypeException);
+  operator std::string() const throw(SettingTypeException);
+
+  Setting & operator=(bool value) throw(SettingTypeException);
+  Setting & operator=(int value) throw(SettingTypeException);
+  Setting & operator=(long value) throw(SettingTypeException);
+  Setting & operator=(const long long &value) throw(SettingTypeException);
+  Setting & operator=(const double &value) throw(SettingTypeException);
+  Setting & operator=(float value) throw(SettingTypeException);
+  Setting & operator=(const char *value) throw(SettingTypeException);
+  Setting & operator=(const std::string &value) throw(SettingTypeException);
+
+  Setting & operator[](const char * key) const
+    throw(SettingTypeException, SettingNotFoundException);
+
+  inline Setting & operator[](const std::string & key) const
+    throw(SettingTypeException, SettingNotFoundException)
+  { return(operator[](key.c_str())); }
+
+  Setting & operator[](int index) const
+    throw(SettingTypeException, SettingNotFoundException);
+
+  bool lookupValue(const char *name, bool &value) const throw();
+  bool lookupValue(const char *name, int &value) const throw();
+  bool lookupValue(const char *name, unsigned int &value) const throw();
+  bool lookupValue(const char *name, long long &value) const throw();
+  bool lookupValue(const char *name, unsigned long long &value)
+    const throw();
+  bool lookupValue(const char *name, double &value) const throw();
+  bool lookupValue(const char *name, float &value) const throw();
+  bool lookupValue(const char *name, const char *&value) const throw();
+  bool lookupValue(const char *name, std::string &value) const throw();
+
+  inline bool lookupValue(const std::string &name, bool &value)
+    const throw()
+  { return(lookupValue(name.c_str(), value)); }
+
+  inline bool lookupValue(const std::string &name, int &value)
+    const throw()
+  { return(lookupValue(name.c_str(), value)); }
+
+  inline bool lookupValue(const std::string &name, unsigned int &value)
+    const throw()
+  { return(lookupValue(name.c_str(), value)); }
+
+  inline bool lookupValue(const std::string &name, long long &value)
+    const throw()
+  { return(lookupValue(name.c_str(), value)); }
+
+  inline bool lookupValue(const std::string &name,
+                          unsigned long long &value) const throw()
+  { return(lookupValue(name.c_str(), value)); }
+
+  inline bool lookupValue(const std::string &name, double &value) const
+    throw()
+  { return(lookupValue(name.c_str(), value)); }
+
+  inline bool lookupValue(const std::string &name, float &value) const
+    throw()
+  { return(lookupValue(name.c_str(), value)); }
+
+  inline bool lookupValue(const std::string &name, const char *&value) const
+    throw()
+  { return(lookupValue(name.c_str(), value)); }
+
+  inline bool lookupValue(const std::string &name, std::string &value) const
+    throw()
+  { return(lookupValue(name.c_str(), value)); }
+
+  void remove(const char *name)
+    throw(SettingTypeException, SettingNotFoundException);
+
+  inline void remove(const std::string & name)
+    throw(SettingTypeException, SettingNotFoundException)
+  { remove(name.c_str()); }
+
+  void remove(unsigned int idx)
+    throw(SettingTypeException, SettingNotFoundException);
+
+  inline Setting & add(const std::string & name, Type type)
+    throw(SettingNameException, SettingTypeException)
+  { return(add(name.c_str(), type)); }
+
+  Setting & add(const char *name, Type type)
+    throw(SettingNameException, SettingTypeException);
+
+  Setting & add(Type type) throw(SettingTypeException);
+
+  inline bool exists(const std::string & name) const throw()
+  { return(exists(name.c_str())); }
+
+  bool exists(const char *name) const throw();
+
+  int getLength() const throw();
+  const char *getName() const throw();
+  std::string getPath() const;
+  int getIndex() const throw();
+
+  const Setting & getParent() const throw(SettingNotFoundException);
+  Setting & getParent() throw(SettingNotFoundException);
+
+  bool isRoot() const throw();
+
+  inline bool isGroup() const throw()
+  { return(_type == TypeGroup); }
+
+  inline bool isArray() const throw()
+  { return(_type == TypeArray); }
+
+  inline bool isList() const throw()
+  { return(_type == TypeList); }
+
+  inline bool isAggregate() const throw()
+  { return(_type >= TypeGroup); }
+
+  inline bool isScalar() const throw()
+  { return((_type > TypeNone) && (_type < TypeGroup)); }
+
+  inline bool isNumber() const throw()
+  { return((_type == TypeInt) || (_type == TypeInt64)
+           || (_type == TypeFloat)); }
+
+  unsigned int getSourceLine() const throw();
+  const char *getSourceFile() const throw();
+};
+
+class Config
+{
+  private:
+
+  config_t *_config;
+
+  static void ConfigDestructor(void *arg);
+  Config(const Config& other); // not supported
+  Config& operator=(const Config& other); // not supported
+
+  public:
+
+  Config();
+  virtual ~Config();
+
+  void setAutoConvert(bool flag);
+  bool getAutoConvert() const;
+
+  void setTabWidth(unsigned short width) throw();
+  unsigned short getTabWidth() const throw();
+
+  void read(FILE *stream) throw(ParseException);
+  void write(FILE *stream) const;
+
+  void readString(const char *str) throw(ParseException);
+  inline void readString(const std::string &str) throw(ParseException)
+  { return(readString(str.c_str())); }
+
+  void readFile(const char *filename) throw(FileIOException, ParseException);
+  void writeFile(const char *filename) throw(FileIOException);
+
+  inline Setting & lookup(const std::string &path) const
+    throw(SettingNotFoundException)
+  { return(lookup(path.c_str())); }
+
+  Setting & lookup(const char *path) const throw(SettingNotFoundException);
+
+  inline bool exists(const std::string & path) const throw()
+  { return(exists(path.c_str())); }
+
+  bool exists(const char *path) const throw();
+
+  bool lookupValue(const char *path, bool &value) const throw();
+  bool lookupValue(const char *path, int &value) const throw();
+  bool lookupValue(const char *path, unsigned int &value) const throw();
+  bool lookupValue(const char *path, long long &value) const throw();
+  bool lookupValue(const char *path, unsigned long long &value)
+    const throw();
+  bool lookupValue(const char *path, double &value) const throw();
+  bool lookupValue(const char *path, float &value) const throw();
+  bool lookupValue(const char *path, const char *&value) const throw();
+  bool lookupValue(const char *path, std::string &value) const throw();
+
+  inline bool lookupValue(const std::string &path, bool &value) const throw()
+  { return(lookupValue(path.c_str(), value)); }
+
+  inline bool lookupValue(const std::string &path, int &value) const throw()
+  { return(lookupValue(path.c_str(), value)); }
+
+  inline bool lookupValue(const std::string &path, unsigned int &value)
+    const throw()
+  { return(lookupValue(path.c_str(), value)); }
+
+  inline bool lookupValue(const std::string &path, long long &value)
+    const throw()
+  { return(lookupValue(path.c_str(), value)); }
+
+  inline bool lookupValue(const std::string &path,
+                          unsigned long long &value) const throw()
+  { return(lookupValue(path.c_str(), value)); }
+
+  inline bool lookupValue(const std::string &path, double &value)
+    const throw()
+  { return(lookupValue(path.c_str(), value)); }
+
+  inline bool lookupValue(const std::string &path, float &value)
+    const throw()
+  { return(lookupValue(path.c_str(), value)); }
+
+  inline bool lookupValue(const std::string &path, const char *&value)
+    const throw()
+  { return(lookupValue(path.c_str(), value)); }
+
+  inline bool lookupValue(const std::string &path, std::string &value)
+    const throw()
+  { return(lookupValue(path.c_str(), value)); }
+
+  Setting & getRoot() const;
+
+  private:
+
+  void handleError() const;
+};
+
+}; // namespace libconfig
+
+
+#endif // LIBCONFIG_MEX_H
Index: /library/bdm/stat/emix.cpp
===================================================================
--- /library/bdm/stat/emix.cpp (revision 784)
+++ /library/bdm/stat/emix.cpp (revision 789)
@@ -31,6 +31,4 @@
 		w = 1.0 / len;
 	}
-
-	validate();
 }
 
Index: /library/bdm/CMakeLists.txt
===================================================================
--- /library/bdm/CMakeLists.txt (revision 693)
+++ /library/bdm/CMakeLists.txt (revision 789)
@@ -8,6 +8,6 @@
 SET(bdm_estim estim/kalman.cpp estim/kalman.h estim/particles.cpp estim/particles.h estim/arx.cpp estim/arx.h estim/arx_straux.cpp estim/mixtures.cpp estim/mixtures.h)
 SET(bdm_ctrl design/ctrlbase.cpp design/ctrlbase.h)
-SET(bdm_user_info base/libconfig/lib/libconfigcpp.cc base/libconfig/lib/grammar.c base/libconfig/lib/libconfig.c 
-	base/libconfig/lib/libconfig.h base/libconfig/lib/libconfig.hh base/libconfig/lib/scanner.c  base/user_info.cpp base/user_info.h  base/libconfig/lib/parsectx.h base/libconfig/lib/scanctx.c base/libconfig/lib/scanctx.h  base/libconfig/lib/strbuf.h 
+SET(bdm_user_info base/libconfig/lib/libconfigcpp.cc base/libconfig/lib/grammar.c base/libconfig/lib/libconfig.c base/libconfig_mex.h base/libconfig_mex.cpp 
+base/libconfig/lib/libconfig.h base/libconfig/lib/libconfig.hh base/libconfig/lib/scanner.c  base/user_info.cpp base/user_info.h  base/libconfig/lib/parsectx.h base/libconfig/lib/scanctx.c base/libconfig/lib/scanctx.h  base/libconfig/lib/strbuf.h 
 base/libconfig/lib/strbuf.c)
 
