← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba

 

Paul J. Lucas has proposed merging lp:~paul-lucas/zorba/pjl-misc into lp:zorba.

Commit message:
Major clean-up of properties, zorbacmd, and apitest command-line arguments.

Requested reviews:
  Paul J. Lucas (paul-lucas)

For more details, see:
https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/205515

Major clean-up of properties, zorbacmd, and apitest command-line arguments.
-- 
https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/205515
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'bin/CMakeLists.txt'
--- bin/CMakeLists.txt	2014-01-31 23:27:47 +0000
+++ bin/CMakeLists.txt	2014-02-10 00:46:59 +0000
@@ -44,11 +44,10 @@
 ENDIF (ZORBA_WITH_DEBUGGER)
 
 SET(SRCS
+  zorbacmd_args.cpp
+  zorbacmd_props.cpp
+  timers.cpp
   zorbacmd.cpp
-  zorbacmdproperties_base.cpp
-  zorbacmdproperties.cpp
-  util.cpp
-  path_util.cpp
 )
 
 ZORBA_GENERATE_EXE("zorbacmd" "${SRCS}" "" "zorba" "bin")

=== removed file 'bin/path_util.cpp'
--- bin/path_util.cpp	2013-05-31 03:38:45 +0000
+++ bin/path_util.cpp	1970-01-01 00:00:00 +0000
@@ -1,85 +0,0 @@
-/*
- * Copyright 2006-2008 The FLWOR Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "path_util.h"
-
-#include <cstdlib>
-
-#include <zorba/static_context.h>
-#include <zorba/util/fs_util.h>
-
-#include "util.h"
-#include "zorbacmdproperties.h"
-
-namespace zorba {
-
-namespace PathUtil {
-
-void
-tokenizePath(
-  const std::string&    aPathStr,
-  std::vector<String>&  aResult)
-{
-  std::vector<std::string> lPath;
-#ifdef WIN32
-  Util::tokenize(aPathStr, ";", lPath);
-#else
-  Util::tokenize(aPathStr, ":", lPath);
-#endif
-  for (std::vector<std::string>::iterator lIter = lPath.begin();
-       lIter != lPath.end(); ++lIter) {
-    aResult.push_back(*lIter);
-  }
-}
-
-void
-setPathsOnContext(
-  const ZorbaCMDProperties& aProperties,
-  StaticContext_t& aStaticCtx)
-{
-  std::vector<String> lPath;
-  std::string lPathStr;
-
-  // Compute the current working directory to append to all paths.
-  std::string lCWD( fs::curdir() );
-
-  // setModulePaths() *overwrites* the URI path and lib path, so there's no
-  // sense in calling both. So if --module-path exists, just use it.
-  aProperties.getModulePath(lPathStr);
-  if (lPathStr.length() > 0) {
-    tokenizePath(lPathStr, lPath);
-    lPath.push_back(lCWD);
-    aStaticCtx->setModulePaths(lPath);
-  }
-  else {
-    // Compute and set URI path
-    aProperties.getURIPath(lPathStr);
-    tokenizePath(lPathStr, lPath);
-    lPath.push_back(lCWD);
-    aStaticCtx->setURIPath(lPath);
-    lPath.clear();
-
-    // Compute and set lib path
-    aProperties.getLibPath(lPathStr);
-    tokenizePath(lPathStr, lPath);
-    lPath.push_back(lCWD);
-    aStaticCtx->setLibPath(lPath);
-  }
-}
-
-} /* namespace ModulePath */
-
-} /* namespace zorba */

=== removed file 'bin/path_util.h'
--- bin/path_util.h	2013-02-07 17:24:36 +0000
+++ bin/path_util.h	1970-01-01 00:00:00 +0000
@@ -1,41 +0,0 @@
-/*
- * Copyright 2006-2008 The FLWOR Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef ZORBA_MODULE_PATH_H
-#define ZORBA_MODULE_PATH_H
-
-#include <vector>
-#include <string>
-#include <zorba/api_shared_types.h>
-
-class ZorbaCMDProperties;
-
-namespace zorba {
-
-  class String;
-
-  namespace PathUtil {
-
-    void
-    setPathsOnContext(const ZorbaCMDProperties& aProperties,
-                      zorba::StaticContext_t& aStaticCtx);
-
-    void
-    tokenizePath(const std::string& aPathStr, std::vector<String>&  aResult);
-
-  }
-} /* namespace zorba */
-
-#endif

=== added file 'bin/timers.cpp'
--- bin/timers.cpp	1970-01-01 00:00:00 +0000
+++ bin/timers.cpp	2014-02-10 00:46:59 +0000
@@ -0,0 +1,176 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// local
+#include "timers.h"
+
+using namespace std;
+
+///////////////////////////////////////////////////////////////////////////////
+
+#define INIT_TIMER(KIND)          \
+  elapsed_##KIND##_walltime( 0 ), \
+  elapsed_##KIND##_cputime( 0 )
+
+#define START_TIMER(KIND)                                       \
+  zorba::time::get_current_walltime( start_##KIND##_walltime ); \
+  zorba::time::get_current_cputime( start_##KIND##_cputime )
+
+#define STOP_TIMER(KIND)                                        \
+  zorba::time::get_current_walltime( stop_##KIND##_walltime );  \
+  elapsed_##KIND##_walltime += zorba::time::get_walltime_elapsed( start_##KIND##_walltime, stop_##KIND##_walltime ); \
+  zorba::time::get_current_cputime( stop_##KIND##_cputime );    \
+  elapsed_##KIND##_cputime += zorba::time::get_cputime_elapsed( start_##KIND##_cputime, stop_##KIND##_cputime )
+
+Timers::Timers( unsigned long num_execs ) :
+  num_execs_( num_execs ),
+  INIT_TIMER( init ),
+  INIT_TIMER( deinit ),
+  INIT_TIMER( comp ),
+  INIT_TIMER( exec ),
+  INIT_TIMER( load ),
+  INIT_TIMER( unload ),
+  INIT_TIMER( plan_save ),
+  INIT_TIMER( plan_load ),
+  INIT_TIMER( total )
+{
+}
+
+void Timers::startTimer( kind k, unsigned long iteration ) {
+  if ( iteration == 0 && num_execs_ > 1 )
+    return;
+  switch ( k ) {
+    case init:
+      START_TIMER( init );
+      break;
+    case deinit:
+      START_TIMER( deinit );
+      break;
+    case total:
+      START_TIMER( total );
+      break;
+    case comp:
+      START_TIMER( comp );
+      break;
+    case exec:
+      START_TIMER( exec );
+      break;
+    case unload:
+      START_TIMER( unload );
+      break;
+    case plan_save:
+      START_TIMER( plan_save );
+      break;
+    case plan_load:
+      START_TIMER( plan_load );
+      break;
+  } // switch
+}
+
+void Timers::stopTimer( kind k, unsigned long iteration ) {
+  if ( iteration == 0 && num_execs_ > 1 )
+    return;
+  switch ( k ) {
+    case init:
+      STOP_TIMER( init );
+      break;
+    case deinit:
+      STOP_TIMER( deinit );
+      break;
+    case total:
+      STOP_TIMER( total );
+      break;
+    case comp:
+      STOP_TIMER( comp );
+      break;
+    case exec:
+      STOP_TIMER( exec );
+      break;
+    case unload:
+      STOP_TIMER( unload );
+      break;
+    case plan_save:
+      STOP_TIMER( plan_save );
+      break;
+    case plan_load:
+      STOP_TIMER( plan_load );
+      break;
+  } // switch
+}
+
+ostream& Timers::print( ostream &os, bool serializePlan ) {
+  os.precision( 3 );
+  os.setf( ios::fixed );
+
+  os << "\nNumber of executions = " << num_execs_ << endl;
+
+  unsigned long timeDiv = num_execs_ == 1 ? 1 : (num_execs_ - 1);
+  double cWalltime = elapsed_comp_walltime / timeDiv;
+  double eWalltime = elapsed_exec_walltime / timeDiv;
+  double lWalltime = elapsed_load_walltime / timeDiv;
+  double uWalltime = elapsed_unload_walltime / timeDiv;
+  double psWalltime = elapsed_plan_save_walltime / timeDiv;
+  double plWalltime = elapsed_plan_load_walltime / timeDiv;
+  double tWalltime = elapsed_total_walltime / timeDiv;
+
+  double cCputime = elapsed_comp_cputime / timeDiv;
+  double eCputime = elapsed_exec_cputime / timeDiv;
+  double lCputime = elapsed_load_cputime / timeDiv;
+  double uCputime = elapsed_unload_cputime / timeDiv;
+  double psCputime = elapsed_plan_save_cputime / timeDiv;
+  double plCputime = elapsed_plan_load_cputime / timeDiv;
+  double tCputime = elapsed_total_cputime / timeDiv;
+
+  os << "Engine Startup Time     : " << elapsed_init_walltime
+     << " (user: " << elapsed_init_cputime << ")"
+     << " milliseconds" << endl;
+
+  os << "Average Compilation Time: " << cWalltime
+     << " (user: " << cCputime << ")"
+     << " milliseconds" << endl;
+
+  if ( serializePlan ) {
+    os << "Average Plan Saving Time: " << psWalltime
+       << " (user: " << psCputime << ")"
+       << " milliseconds" << endl;
+    
+    os << "Average Plan Loading Time: " << plWalltime
+       << " (user: " << plCputime << ")"
+       << " milliseconds" << endl;
+  }
+
+  os << "Average Execution Time  : " << eWalltime - lWalltime
+     << " (user: " << eCputime - lCputime  << ")"
+     << " milliseconds" << endl;
+
+  os << "Average Loading Time    : " << lWalltime
+     << " (user: " << lCputime << ")"
+     << " milliseconds" << endl;
+
+  os << "Average Unloading Time  : " << uWalltime
+     << " (user: " << uCputime << ")"
+     << " milliseconds" << endl;
+
+  os << "Average Total Time      : " << tWalltime
+     << " (user: " << tCputime << ")"
+     << " milliseconds" << endl;
+
+  return os;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+/* vim:set et sw=2 ts=2: */

=== added file 'bin/timers.h'
--- bin/timers.h	1970-01-01 00:00:00 +0000
+++ bin/timers.h	2014-02-10 00:46:59 +0000
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ZORBA_CMD_TIMERS_H
+#define ZORBA_CMD_TIMERS_H
+
+// standard
+#include <iostream>
+
+// Zorba
+#include <zorba/util/time.h>
+
+///////////////////////////////////////////////////////////////////////////////
+
+#define DECLARE_TIMER(KIND)                       \
+  zorba::time::walltime start_##KIND##_walltime;  \
+  zorba::time::walltime stop_##KIND##_walltime;   \
+  zorba::time::cputime start_##KIND##_cputime;    \
+  zorba::time::cputime stop_##KIND##_cputime;     \
+  double elapsed_##KIND##_walltime;               \
+  double elapsed_##KIND##_cputime
+
+struct Timers {
+  enum kind {
+    init,
+    deinit,
+    comp,
+    exec,
+    unload,
+    plan_save,
+    plan_load,
+    total
+  };
+
+  unsigned long num_execs_;
+
+  DECLARE_TIMER( init );
+  DECLARE_TIMER( deinit );
+  DECLARE_TIMER( comp );
+  DECLARE_TIMER( exec );
+  DECLARE_TIMER( load );
+  DECLARE_TIMER( unload );
+  DECLARE_TIMER( plan_save );
+  DECLARE_TIMER( plan_load );
+  DECLARE_TIMER( total );
+
+  Timers( unsigned long num_execs );
+
+  void startTimer( kind, unsigned long iteration );
+  void stopTimer( kind, unsigned long iteration );
+
+  std::ostream& print( std::ostream&, bool );
+};
+
+#undef DECLARE_TIMER
+
+///////////////////////////////////////////////////////////////////////////////
+
+#endif /* ZORBA_CMD_TIMERS_H */
+/* vim:set et sw=2 ts=2: */

=== removed file 'bin/util.cpp'
--- bin/util.cpp	2013-02-07 17:24:36 +0000
+++ bin/util.cpp	1970-01-01 00:00:00 +0000
@@ -1,37 +0,0 @@
-/*
- * Copyright 2006-2008 The FLWOR Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "util.h"
-
-namespace zorba {
-
-  void
-  Util::tokenize(const std::string& str,
-                const std::string& delimiters,
-                std::vector<std::string>& tokens)
-  {
-    std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
-        
-    std::string::size_type pos = str.find_first_of(delimiters, lastPos);
-  
-    while (std::string::npos != pos || std::string::npos != lastPos) {
-      tokens.push_back(str.substr(lastPos, pos - lastPos));
-      lastPos = str.find_first_not_of(delimiters, pos);
-      pos = str.find_first_of(delimiters, lastPos);
-    }
-  }
-
-} /* namespace zorba */

=== modified file 'bin/util.h'
--- bin/util.h	2013-02-07 17:24:36 +0000
+++ bin/util.h	2014-02-10 00:46:59 +0000
@@ -13,23 +13,29 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#ifndef ZORBA_UTIL_H
-#define ZORBA_UTIL_H
-
+
+#ifndef ZORBA_CMD_UTIL_H
+#define ZORBA_CMD_UTIL_H
+
+#include <string>
 #include <vector>
-#include <string>
-
-namespace zorba {
-
-  class Util {
-  public:
-    static void
-    tokenize(const std::string& str,
-             const std::string& delimiters,
-             std::vector<std::string>& tokens);
-
-  };
-} /* namespace zorba */
-
-#endif
-
+
+///////////////////////////////////////////////////////////////////////////////
+
+template<class InStringType,class OutStringType>
+void tokenize( InStringType const &s, char delim,
+               std::vector<OutStringType> *tokens ) {
+  typename InStringType::size_type last_pos = s.find_first_not_of( delim, 0 );
+  typename InStringType::size_type pos = s.find_first_of( delim, last_pos );
+
+  while ( pos != InStringType::npos || last_pos != InStringType::npos ) {
+    tokens->push_back( s.substr( last_pos, pos - last_pos ).c_str() );
+    last_pos = s.find_first_not_of( delim, pos );
+    pos = s.find_first_of( delim, last_pos );
+  }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+#endif /* ZORBA_CMD_UTIL_H */
+/* vim:set et sw=2 ts=2: */

=== modified file 'bin/zorbacmd.cpp'
--- bin/zorbacmd.cpp	2013-09-17 21:12:49 +0000
+++ bin/zorbacmd.cpp	2014-02-10 00:46:59 +0000
@@ -14,34 +14,34 @@
  * limitations under the License.
  */
 
-#include "zorbacmdproperties.h"
-
+// standard
+#include <cassert>
+#include <fstream>
 #include <iostream>
-#include <fstream>
 #include <sstream>
+#include <string>
 #include <vector>
-#include <string>
-#include <cassert>
 
 #ifdef WIN32
 #include <windows.h>
-#define sleep(s) Sleep(s*1000)
-#endif
+#endif /* WIN32 */
 
-#include <zorba/zorba.h>
-#include <zorba/zorba_exception.h>
-#include <zorba/xquery_exception.h>
+// Zorba
+#include <zorba/audit.h>
+#include <zorba/audit_scoped.h>
 #include <zorba/document_manager.h>
+#include <zorba/internal/unique_ptr.h>
 #include <zorba/item_sequence.h>
 #include <zorba/iterator.h>
-#include <zorba/xquery_functions.h>
-#include <zorba/uri_resolvers.h>
+#include <zorba/properties.h>
 #include <zorba/serialization_callback.h>
-#include <zorba/audit.h>
-#include <zorba/audit_scoped.h>
 #include <zorba/store_manager.h>
+#include <zorba/uri_resolvers.h>
 #include <zorba/util/fs_util.h>
-#include <zorba/internal/unique_ptr.h>
+#include <zorba/xquery_exception.h>
+#include <zorba/xquery_functions.h>
+#include <zorba/zorba.h>
+#include <zorba/zorba_exception.h>
 
 //#define DO_AUDIT
 
@@ -50,850 +50,464 @@
 #include <zorba/audit_scoped.h>
 #endif
 
+// local
+#include "timers.h"
 #include "util.h"
-#include "path_util.h"
-
-// Timing utilities, including wall-clock timing
-#include <zorba/util/time.h>
+#include "zorbacmd_props.h"
 
 // toggle this to allow configuration via a system properties file
 // (see src/system/properties.*)
 #define ZORBACMD_LOAD_SYSTEM_PROPERTIES 1
 
-#if ZORBACMD_LOAD_SYSTEM_PROPERTIES
-#  include "system/properties.h"
-#endif
-
-//#define DO_AUDIT
-
+using namespace std;
 using namespace zorba;
-namespace zorbatm = zorba::time;
-
-const char *copyright_str =
-  "Copyright 2006-2009 The FLWOR Foundation.\n"
+
+extern char const* get_help_msg();
+extern int  parse_args( int argc, char const *argv[] );
+static void set_paths_on_sctx( StaticContext_t& );
+
+///////////////////////////////////////////////////////////////////////////////
+
+static const char copyright[] =
+  "Copyright 2006-2014 The FLWOR Foundation.\n"
   "License: Apache License 2.0: <http://www.apache.org/licenses/LICENSE-2.0>";
 
 #ifndef ZORBA_NO_FULL_TEXT
-OneToOneURIMapper theStopWordsMapper(EntityData::STOP_WORDS);
-OneToOneURIMapper theThesaurusMapper(EntityData::THESAURUS);
-#endif
-
-
-/*******************************************************************************
-
-********************************************************************************/
-class URIMapperSerializationCallback : public SerializationCallback
-{
+static OneToOneURIMapper stop_words_mapper( EntityData::STOP_WORDS );
+static OneToOneURIMapper thesaurus_mapper( EntityData::THESAURUS );
+#endif /* ZORBA_NO_FULL_TEXT */
+
+class URIMapperSerializationCallback : public SerializationCallback {
+public:
+  void addURIMapper( URIMapper* mapper ) {
+    theURIMappers.push_back( mapper );
+  }
+
+  URIMapper* getURIMapper( size_t i ) const {
+    return theURIMappers[i];
+  }
+
 private:
-  std::vector<URIMapper*>   theURIMappers;
-
-public:
-  void addURIMapper(URIMapper* mapper) { theURIMappers.push_back(mapper); }
-
-  URIMapper* getURIMapper(size_t i) const { return theURIMappers[i]; }
+  vector<URIMapper*> theURIMappers;
 };
 
-
-URIMapperSerializationCallback theSerializationCallback;
-
-/*******************************************************************************
-
-********************************************************************************/
-static void print_exception( ZorbaException const &e,
-                             ZorbaCMDProperties const &props ) {
-  using namespace std;
-
-  if ( props.printErrorsAsXml() )
-    if ( props.indent() )
+URIMapperSerializationCallback serialization_callback;
+
+static void print_exception( ZorbaException const &e ) {
+  ZorbaCmdProperties &zc_props = ZorbaCmdProperties::instance();
+  if ( zc_props.print_errors_as_xml_ )
+    if ( zc_props.indent_ )
       cerr << ZorbaException::format_xml_indented;
     else
       cerr << ZorbaException::format_xml;
   else
     cerr << ZorbaException::format_text;
-
   cerr << e << endl;
 }
 
-/*******************************************************************************
+static void print_help() {
+  cout << "Zorba NoSQL Query Processor\n";
+  cout << "Available options:\n";
+  cout << get_help_msg();
+}
 
-********************************************************************************/
-bool populateStaticContext(
-    Zorba* zorba,
-    zorba::StaticContext_t& sctx,
-    const ZorbaCMDProperties& props)
-{
-  try
-  {
+static bool populateStaticContext( Zorba *zorba, StaticContext_t &sctx ) {
+  ZorbaCmdProperties &zc_props = ZorbaCmdProperties::instance();
+  try {
     // add the following module path to the static context (in this order)
     // 1. command-line properties
     // 2. environment ZORBA_MODULE_PATH
     // 3. current working directory
-    {
-      std::vector<String> lModulePath;
-      PathUtil::setPathsOnContext(props, sctx);
-    }
-
-    if (props.boundarySpace().size() != 0 )
-    {
-      sctx->setBoundarySpacePolicy(props.boundarySpace().compare("preserve") == 0 ?
-                                   preserve_space : 
-                                   strip_space);
-    }
-
-    if (props.constructionMode().size() != 0)
-    {
-      sctx->setConstructionMode(props.boundarySpace().compare("preserve") == 0 ? 
-                                preserve_cons :
-                                strip_cons);
-    }
-
-    if (props.orderingMode().size() != 0 )
-    {
-      sctx->setOrderingMode(props.boundarySpace().compare("ordered") == 0 ?
-                            ordered :
-                            unordered);
-    }
-
-    if (props.baseUri().size() != 0 )
-      sctx->setBaseURI( props.baseUri() );
+    set_paths_on_sctx( sctx );
+
+    if ( !zc_props.boundary_space_.empty() )
+      sctx->setBoundarySpacePolicy(
+        zc_props.boundary_space_ == "preserve" ? preserve_space : strip_space
+      );
+
+    if ( !zc_props.construction_mode_.empty() )
+      sctx->setConstructionMode(
+        zc_props.boundary_space_ == "preserve" ? preserve_cons : strip_cons
+      );
+
+    if ( !zc_props.ordering_mode_.empty() )
+      sctx->setOrderingMode(
+        zc_props.boundary_space_ == "ordered" ? ordered : unordered
+      );
+
+    if ( !zc_props.base_uri_.empty() )
+      sctx->setBaseURI( zc_props.base_uri_ );
   }
-  catch (const zorba::ZorbaException& ze) 
-  {
-    std::cerr << ze << std::endl;
+  catch ( ZorbaException const &ze ) {
+    cerr << ze << endl;
     return false;
   }
 
-  if (props.defaultCollation().size() != 0 )
-  {
-    try 
-    {
-      sctx->addCollation( props.defaultCollation() );
+  if ( !zc_props.default_collation_.empty() ) {
+    try {
+      sctx->addCollation( zc_props.default_collation_ );
     }
-    catch (zorba::ZorbaException const&)
-    {
-      std::cerr << "the given collation {" << props.defaultCollation()
-                << "} is not a valid collation." << std::endl;
+    catch ( ZorbaException const& ) {
+      cerr << "the given collation {" << zc_props.default_collation_
+           << "} is not a valid collation." << endl;
       return false;
     }
-
-    sctx->setDefaultCollation( props.defaultCollation() );
+    sctx->setDefaultCollation( zc_props.default_collation_ );
   }
 
-  ZorbaCMDProperties::Options_t::const_iterator lIter = props.optionsBegin();
-  ZorbaCMDProperties::Options_t::const_iterator end = props.optionsEnd();
-  for (; lIter != end; ++lIter)
-  {
-    try 
-    {
-      Item lQName = zorba->getItemFactory()->createQName(lIter->clark_qname);
-      sctx->declareOption(lQName, lIter->value);
+  sctx_opts::const_iterator i = zc_props.sctx_opts_.begin();
+  sctx_opts::const_iterator const end = zc_props.sctx_opts_.end();
+  for ( ; i != end; ++i ) {
+    try {
+      Item name( zorba->getItemFactory()->createQName( i->clark_qname ) );
+      sctx->declareOption( name, i->value );
     }
-    catch (zorba::ZorbaException const& e)
-    {
-      std::cerr << "unable to set static context option with qname "
-                << lIter->clark_qname << ": " << e.what() << std::endl;
+    catch ( ZorbaException const &e) {
+      cerr << "unable to set static context option with qname "
+           << i->clark_qname << ": " << e.what() << endl;
       return false;
     }
   }
 
 #ifdef DO_AUDIT
-  zorba::audit::Provider* lAuditProvider = zorba->getAuditProvider();
-  zorba::audit::Configuration* config = lAuditProvider->createConfiguration();
-  std::vector<zorba::String> property_names;
-  zorba::audit::Configuration::getPropertyNames(property_names);
+  audit::Provider* lAuditProvider = zorba->getAuditProvider();
+  audit::Configuration* config = lAuditProvider->createConfiguration();
+  vector<String> property_names;
+  audit::Configuration::getPropertyNames(property_names);
 
   bool lIsStatic;
 
-  lIsStatic = zorba::audit::Configuration::
+  lIsStatic = audit::Configuration::
   enableProperty(config, property_names, "xquery/compilation/parse-duration");
   assert(lIsStatic);
 
-  lIsStatic = zorba::audit::Configuration::
+  lIsStatic = audit::Configuration::
   enableProperty(config, property_names, "xquery/compilation/translation-duration");
   assert(lIsStatic);
 
-  lIsStatic = zorba::audit::Configuration::
+  lIsStatic = audit::Configuration::
   enableProperty(config, property_names, "xquery/compilation/optimization-duration");
   assert(lIsStatic);
 
-  lIsStatic = zorba::audit::Configuration::
+  lIsStatic = audit::Configuration::
   enableProperty(config, property_names, "xquery/compilation/codegeneration-duration");
   assert(lIsStatic);
 
-  zorba::audit::Event* event = lAuditProvider->createEvent(config);
+  audit::Event *event = lAuditProvider->createEvent(config);
 
-  sctx->setAuditEvent(event);
-#endif // DO_AUDIT
+  sctx->setAuditEvent( event );
+#endif /* DO_AUDIT */
 
 #ifndef ZORBA_NO_FULL_TEXT
   {
-    ZorbaCMDProperties::FullText_t::const_iterator lIter = props.stopWordsBegin();
-    ZorbaCMDProperties::FullText_t::const_iterator end = props.stopWordsEnd();
-    for (; lIter != end; ++lIter) 
-    {
-      theStopWordsMapper.addMapping(lIter->uri, lIter->value);
-    }
+    ft_mappings::const_iterator i = zc_props.stop_words_mapping_.begin();
+    ft_mappings::const_iterator const end = zc_props.stop_words_mapping_.end();
+    for (; i != end; ++i)
+      stop_words_mapper.addMapping( i->uri, i->value );
 
-    if (props.serializePlan() || props.loadPlan()) 
-    {
-      theSerializationCallback.addURIMapper(&theStopWordsMapper);
-    }
+    if ( zc_props.serialize_plan_ || zc_props.load_plan_ )
+      serialization_callback.addURIMapper( &stop_words_mapper );
     else
-    {
-      sctx->registerURIMapper(&theStopWordsMapper);
-    }
+      sctx->registerURIMapper( &stop_words_mapper );
   }
 
   {
-    ZorbaCMDProperties::FullText_t::const_iterator lIter = props.thesaurusBegin();
-    ZorbaCMDProperties::FullText_t::const_iterator end = props.thesaurusEnd();
-    for (; lIter != end; ++lIter) 
-    {
-      theThesaurusMapper.addMapping(lIter->uri, lIter->value);
-    }
+    ft_mappings::const_iterator i = zc_props.thesaurus_mapping_.begin();
+    ft_mappings::const_iterator const end = zc_props.thesaurus_mapping_.end();
+    for ( ; i != end; ++i )
+      thesaurus_mapper.addMapping( i->uri, i->value );
 
-    if (props.serializePlan() || props.loadPlan())
-    {
-      theSerializationCallback.addURIMapper(&theStopWordsMapper);
-    }
+    if ( zc_props.serialize_plan_ || zc_props.load_plan_ )
+      serialization_callback.addURIMapper( &stop_words_mapper );
     else
-    {
-      sctx->registerURIMapper(&theThesaurusMapper);
-    }
+      sctx->registerURIMapper( &thesaurus_mapper );
   }
 #endif /* ZORBA_NO_FULL_TEXT */
 
   return true;
 }
 
-
-/*******************************************************************************
-
-********************************************************************************/
-bool populateDynamicContext(
-    Zorba* zorba,
-    XmlDataManager* xmlMgr,
-    zorba::DynamicContext* aDynamicContext,
-    const ZorbaCMDProperties& props)
-{
-  if ( props.contextItem().size() != 0 ) 
-  {
-    std::ifstream lInStream(props.contextItem().c_str());
-    Item lDoc = xmlMgr->parseXML(lInStream);
-    aDynamicContext->setContextItem(lDoc);
+bool populateDynamicContext( Zorba *zorba, XmlDataManager *xmlMgr,
+                             DynamicContext *dctx ) {
+  ZorbaCmdProperties const &zc_props = ZorbaCmdProperties::instance();
+
+  if ( !zc_props.ctx_item_.empty() ) {
+    ifstream is( zc_props.ctx_item_.c_str() );
+    Item doc( xmlMgr->parseXML( is ) );
+    dctx->setContextItem( doc );
   }
 
-  ZorbaCMDProperties::ExternalVars_t::const_iterator lIter;
-  ZorbaCMDProperties::ExternalVars_t::const_iterator end = props.externalVarsEnd();
-  for (lIter = props.externalVarsBegin();
-       lIter != end;
-       ++lIter)
-  {
-    try
-    {
-      if ((*lIter).inline_file)
-      {
-        std::ifstream lInStream((*lIter).var_value.c_str());
-        Item lDoc = xmlMgr->parseXML(lInStream);
-        aDynamicContext->setVariable((*lIter).var_name, lDoc);
-      }
-      else
-      {
-        zorba::Item lItem = zorba->getItemFactory()->createString((*lIter).var_value);
-        aDynamicContext->setVariable((*lIter).var_name, lItem);
+  external_vars::const_iterator i = zc_props.external_vars_.begin();
+  external_vars::const_iterator const end = zc_props.external_vars_.end();
+  for ( ; i != end; ++i ) {
+    try {
+      if ( i->inline_file ) {
+        ifstream is( i->var_value.c_str() );
+        Item doc( xmlMgr->parseXML( is ) );
+        dctx->setVariable( i->var_name, doc );
+      } else {
+        Item item( zorba->getItemFactory()->createString( i->var_value ) );
+        dctx->setVariable( i->var_name, item );
       }
     }
-    catch (...)
-    {
+    catch ( ... ) {
       // Let normal exception handling display the error message; here we
       // just want to tell the user what variable binding caused the problem
-      std::cerr << "While binding external variable $"
-                << lIter->var_name << ": ";
+      cerr << "While binding external variable $" << i->var_name << ": ";
       throw;
     }
   }
   return true;
 }
 
-
-/*******************************************************************************
-
-********************************************************************************/
-bool createSerializerOptions(
-    Zorba_SerializerOptions_t& lSerOptions,
-    const ZorbaCMDProperties& props)
-{
-  if ( props.indent() )
-    lSerOptions.indent = ZORBA_INDENT_YES;
-
-  if ( props.omitXmlDeclaration() )
-    lSerOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES;
-
-  if ( props.byteOrderMark() )
-    lSerOptions.byte_order_mark = ZORBA_BYTE_ORDER_MARK_YES;
-
-  if ( props.serializeHtml() )
-    lSerOptions.ser_method = ZORBA_SERIALIZATION_METHOD_HTML;
-  else if ( props.serializeText() )
-    lSerOptions.ser_method = ZORBA_SERIALIZATION_METHOD_TEXT;
-
-  return true;
+static void set_serializer_opts( Zorba_SerializerOptions_t &ser_opts ) {
+  ZorbaCmdProperties &zc_props = ZorbaCmdProperties::instance();
+
+  if ( zc_props.indent_ )
+    ser_opts.indent = ZORBA_INDENT_YES;
+
+  if ( zc_props.omit_xml_declaration_ )
+    ser_opts.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES;
+
+  if ( zc_props.byte_order_mark_ )
+    ser_opts.byte_order_mark = ZORBA_BYTE_ORDER_MARK_YES;
+
+  if ( zc_props.serialize_html_ )
+    ser_opts.ser_method = ZORBA_SERIALIZATION_METHOD_HTML;
+  else if ( zc_props.serialize_text_ )
+    ser_opts.ser_method = ZORBA_SERIALIZATION_METHOD_TEXT;
 }
 
 
-/*******************************************************************************
+/******************************************************************************
   Fullfills the command-line "as-file" (-f) switch, or if not requested, infers
   -f for file:// queries. Returns an URI or the empty string.
-********************************************************************************/
-std::string parseFileURI(bool asPath, const std::string &str)
-{
-  if (asPath)
-    return str;
+ ******************************************************************************/
 
-  // otherwise, the user still might have meant a file
+static string parse_file_uri( string const &uri ) {
 #ifdef WIN32
   // file:///c:/ returns c:<backslash>
   // file://localhost returns \\localhost
   // BUG: it seems that <a>/x returns <a>\x
   static const char *file3 = "file:///";
   static const char *file2 = "file://";
-  std::string fpath;
-  if(str.compare(0, strlen(file3), file3) == 0) {
-    fpath = str.substr(strlen(file3));
-  } else if(str.compare(0, strlen(file2), file2) == 0) {
+  string fpath;
+  if ( uri.compare( 0, strlen( file3 ), file3 ) == 0 ) {
+    fpath = uri.substr( strlen( file3 ) );
+  } else if ( uri.compare( 0, strlen( file2 ), file2 ) == 0 ) {
     fpath = fs::dir_separator;
-    fpath += str.substr(strlen(file2));
+    fpath += uri.substr( strlen( file2 ) );
   }
   // replace all slash with backslash
-  std::string::size_type off=0;
-  while ((off=fpath.find('/', off)) != std::string::npos)
-    fpath.replace(off, 1, 1, fs::dir_separator);
+  string::size_type off=0;
+  while ( (off = fpath.find( '/', off )) != string::npos )
+    fpath.replace( off, 1, 1, fs::dir_separator );
   return fpath;
 
-#else // for UNIX
-
-  static const char *pfx = "file://";
-  static unsigned plen = strlen (pfx);
-  if (str.compare (0, plen, pfx) == 0)
-    return str.substr (plen);
+#else /* for UNIX */
+  static const char pfx[] = "file://";
+  if ( uri.compare( 0, 7, pfx ) == 0 )
+    return uri.substr( 7 );
   else
     return "";
-#endif
-}
-
-
-//
-// Timing utilities and class
-//
-
-#define DECLARE_TIMER(kind)                               \
-  zorbatm::walltime start##kind##Walltime;                    \
-  zorbatm::walltime stop##kind##Walltime;                     \
-  zorbatm::cputime start##kind##Cputime;                    \
-  zorbatm::cputime stop##kind##Cputime;                     \
-  double elapsed##kind##Walltime;                             \
-  double elapsed##kind##Cputime
-
-#define START_TIMER(kind)                             \
-  zorbatm::get_current_walltime(start##kind##Walltime);   \
-  zorbatm::get_current_cputime(start##kind##Cputime);
-
-#define STOP_TIMER(kind)                                                \
-  zorbatm::get_current_walltime(stop##kind##Walltime);                      \
-  elapsed##kind##Walltime += zorbatm::get_walltime_elapsed(start##kind##Walltime, \
-    stop##kind##Walltime);                                                  \
-                                                                        \
-  zorbatm::get_current_cputime(stop##kind##Cputime);                      \
-  elapsed##kind##Cputime += zorbatm::get_cputime_elapsed(start##kind##Cputime, \
-    stop##kind##Cputime);
-
-
-
-struct TimingInfo
-{
-  typedef enum
-  {
-    INIT_TIMER,
-    DEINIT_TIMER,
-    COMP_TIMER,
-    EXEC_TIMER,
-    UNLOAD_TIMER,
-    PLAN_SAVE_TIMER,
-    PLAN_LOAD_TIMER,
-    TOTAL_TIMER
-  } TimerKind;
-
-  unsigned long numExecs;
-
-  DECLARE_TIMER(Init);
-  DECLARE_TIMER(Deinit);
-  DECLARE_TIMER(Comp);
-  DECLARE_TIMER(Exec);
-  DECLARE_TIMER(Load);
-  DECLARE_TIMER(Unload);
-  DECLARE_TIMER(PlanSave);
-  DECLARE_TIMER(PlanLoad);
-  DECLARE_TIMER(Total);
-
-  TimingInfo(unsigned long num)
-    :
-    numExecs(num),
-    elapsedInitWalltime(0),
-    elapsedInitCputime(0),
-    elapsedDeinitWalltime(0),
-    elapsedDeinitCputime(0),
-    elapsedCompWalltime(0),
-    elapsedCompCputime(0),
-    elapsedExecWalltime(0),
-    elapsedExecCputime(0),
-    elapsedLoadWalltime(0),
-    elapsedLoadCputime(0),
-    elapsedUnloadWalltime(0),
-    elapsedUnloadCputime(0),
-
-    elapsedPlanSaveWalltime(0),
-    elapsedPlanSaveCputime(0),
-
-    elapsedPlanLoadWalltime(0),
-    elapsedPlanLoadCputime(0),
-
-    elapsedTotalWalltime(0),
-    elapsedTotalCputime(0)
-  {
-  }
-
-  void startTimer(TimerKind kind, unsigned long iteration);
-  void stopTimer(TimerKind kind, unsigned long iteration);
-
-  std::ostream& print(std::ostream& os, bool);
-};
-
-
-void
-TimingInfo::startTimer(TimerKind kind, unsigned long iteration)
-{
-  if (iteration == 0 && numExecs > 1)
-    return;
-
-  switch (kind)
-  {
-  case INIT_TIMER:
-    START_TIMER(Init);
-    break;
-
-  case DEINIT_TIMER:
-    START_TIMER(Deinit);
-    break;
-
-  case TOTAL_TIMER:
-    START_TIMER(Total);
-    break;
-
-  case COMP_TIMER:
-    START_TIMER(Comp);
-    break;
-
-  case EXEC_TIMER:
-    START_TIMER(Exec);
-    break;
-
-  case UNLOAD_TIMER:
-    START_TIMER(Unload);
-    break;
-
-  case PLAN_SAVE_TIMER:
-    START_TIMER(PlanSave);
-    break;
-
-  case PLAN_LOAD_TIMER:
-    START_TIMER(PlanLoad);
-    break;
-  }
-}
-
-
-void
-TimingInfo::stopTimer(TimerKind kind, unsigned long iteration)
-{
-  if (iteration == 0 && numExecs > 1)
-    return;
-
-  switch (kind)
-  {
-  case INIT_TIMER:
-  {
-    STOP_TIMER(Init);
-    break;
-  }
-  case DEINIT_TIMER:
-  {
-    STOP_TIMER(Deinit);
-    break;
-  }
-  case TOTAL_TIMER:
-  {
-    STOP_TIMER(Total);
-    break;
-  }
-  case COMP_TIMER:
-  {
-    STOP_TIMER(Comp);
-    break;
-  }
-  case EXEC_TIMER:
-  {
-    STOP_TIMER(Exec);
-    break;
-  }
-  case UNLOAD_TIMER:
-  {
-    STOP_TIMER(Unload);
-    break;
-  }
-  case PLAN_SAVE_TIMER:
-  {
-    STOP_TIMER(PlanSave);
-    break;
-  }
-  case PLAN_LOAD_TIMER:
-  {
-    STOP_TIMER(PlanLoad);
-    break;
-  }
-  }
-}
-
-
-std::ostream&
-TimingInfo::print(std::ostream& os, bool serializePlan)
-{
-  os.precision(3);
-  os.setf(std::ios::fixed);
-
-  os << "\nNumber of executions = " << numExecs << std::endl;
-
-  unsigned long timeDiv = numExecs == 1 ? 1 : (numExecs - 1);
-  double cWalltime = elapsedCompWalltime / timeDiv;
-  double eWalltime = elapsedExecWalltime / timeDiv;
-  double lWalltime = elapsedLoadWalltime / timeDiv;
-  double uWalltime = elapsedUnloadWalltime / timeDiv;
-  double psWalltime = elapsedPlanSaveWalltime / timeDiv;
-  double plWalltime = elapsedPlanLoadWalltime / timeDiv;
-  double tWalltime = elapsedTotalWalltime / timeDiv;
-
-  double cCputime = elapsedCompCputime / timeDiv;
-  double eCputime = elapsedExecCputime / timeDiv;
-  double lCputime = elapsedLoadCputime / timeDiv;
-  double uCputime = elapsedUnloadCputime / timeDiv;
-  double psCputime = elapsedPlanSaveCputime / timeDiv;
-  double plCputime = elapsedPlanLoadCputime / timeDiv;
-  double tCputime = elapsedTotalCputime / timeDiv;
-
-  os << "Engine Startup Time     : " << elapsedInitWalltime
-     << " (user: " << elapsedInitCputime << ")"
-     << " milliseconds" << std::endl;
-
-  os << "Average Compilation Time: " << cWalltime
-     << " (user: " << cCputime << ")"
-     << " milliseconds" << std::endl;
-
-  if (serializePlan)
-  {
-    os << "Average Plan Saving Time: " << psWalltime
-       << " (user: " << psCputime << ")"
-       << " milliseconds" << std::endl;
-    
-    os << "Average Plan Loading Time: " << plWalltime
-       << " (user: " << plCputime << ")"
-       << " milliseconds" << std::endl;
-  }
-
-  os << "Average Execution Time  : " << eWalltime - lWalltime
-     << " (user: " << eCputime - lCputime  << ")"
-     << " milliseconds" << std::endl;
-
-  os << "Average Loading Time    : " << lWalltime
-     << " (user: " << lCputime << ")"
-     << " milliseconds" << std::endl;
-
-  os << "Average Unloading Time  : " << uWalltime
-     << " (user: " << uCputime << ")"
-     << " milliseconds" << std::endl;
-
-  os << "Average Total Time      : " << tWalltime
-     << " (user: " << tCputime << ")"
-     << " milliseconds" << std::endl;
-
-  return os;
-}
-
-
-void
-removeOutputFileIfNeeded(const ZorbaCMDProperties& lProperties)
-{
+#endif /* WIN32 */
+}
+
+static void remove_output_file() {
 #ifdef ZORBA_WITH_FILE_ACCESS
-  if ( !lProperties.outputFile().empty() )
-    fs::remove( lProperties.outputFile(), true );
+  ZorbaCmdProperties &zc_props = ZorbaCmdProperties::instance();
+  if ( !zc_props.output_file_.empty() )
+    fs::remove( zc_props.output_file_, true );
 #endif /* ZORBA_WITH_FILE_ACCESS */
 }
 
-
-int
-compileAndExecute(
-    zorba::Zorba* zorbaInstance,
-    zorba::XmlDataManager* xmlDataMgr,
-    const ZorbaCMDProperties& properties,
-    zorba::StaticContext_t& staticContext,
-    const std::string& qfilepath,
-    std::istream& qfile,
-    std::ostream& outputStream,
-    TimingInfo& timing)
-{
-  unsigned long lNumExecutions = properties.multiple();
-  bool doTiming = properties.timing();
-  bool serializePlan = properties.serializePlan();
-  bool savePlan = properties.savePlan();
-  bool loadPlan = properties.loadPlan();
-  std::ostringstream lOut;
-  Zorba_CompilerHints lHints;
-
-  std::unique_ptr<std::fstream> planFile;
-  std::fstream* planFilep = NULL;
-
-  if (qfilepath.rfind(".jq") == qfilepath.size() - 3)
-  {
-    staticContext->setJSONiqVersion(zorba::jsoniq_version_1_0);
-  }
-
-  if (serializePlan)
-  {
-    if (savePlan || loadPlan)
-    {
-      std::cerr << "The --serialize-plan option cannot be used together with the --compile-plan or --execute-plan options" << std::endl;
-      exit(1);
+static int compileAndExecute( Zorba *zorba, XmlDataManager *xmlDataMgr,
+                              StaticContext_t &sctx,
+                              string const &qfilepath,
+                              istream &qstream,
+                              ostream &outputStream,
+                              Timers &timers ) {
+  Properties const &z_props = Properties::instance();
+  ZorbaCmdProperties const &zc_props = ZorbaCmdProperties::instance();
+
+  unsigned long lNumExecutions = zc_props.multiple_;
+  ostringstream lOut;
+  Zorba_CompilerHints hints;
+
+  unique_ptr<fstream> planFile;
+  fstream *planFilep = NULL;
+
+  if ( zc_props.jsoniq_ || fs::extension( qfilepath ) == "jq" )
+    sctx->setJSONiqVersion( jsoniq_version_1_0 );
+
+  if ( zc_props.serialize_plan_ ) {
+    if ( zc_props.load_plan_ || zc_props.save_plan_ ) {
+      cerr << "The --serialize-plan option cannot be used together with the --compile-plan or --execute-plan options" << endl;
+      exit( 1 );
     }
 
-    std::string planFilePath = qfilepath;
+    string planFilePath = qfilepath;
     planFilePath += ".plan";
-    planFile.reset(new std::fstream(planFilePath.c_str(), 
-                                    std::fstream::in | 
-                                    std::fstream::out |
-                                    std::fstream::trunc |
-                                    std::fstream::binary));
+    planFile.reset(
+      new fstream(
+        planFilePath.c_str(), ios::in | ios::out | ios::trunc | ios::binary
+      )
+    );
     planFilep = planFile.get();
     assert(planFilep->good());
   }
 
-  if (savePlan && loadPlan)
-  {
-    std::cerr << "The --compile-plan and --execute-plan options cannot be used together" << std::endl;
-    exit(1);
+  if ( zc_props.save_plan_ && zc_props.load_plan_ ) {
+    cerr << "The --compile-plan and --execute-plan options cannot be used together" << endl;
+    exit( 1 );
   }
 
   // default is O1 in the Zorba_CompilerHints constructor
-  if (properties.optimizationLevel() == "O0") 
-  {
-    lHints.opt_level = ZORBA_OPT_LEVEL_O0;
-  }
-  else if (properties.optimizationLevel() == "O2") 
-  {
-    lHints.opt_level = ZORBA_OPT_LEVEL_O2;
-  }
-
-  lHints.for_serialization_only = true;
-
-#if ZORBACMD_LOAD_SYSTEM_PROPERTIES
-  if (Properties::instance()->serializeOnlyQuery() == 0)
-  {
-    lHints.for_serialization_only = false;
-  }
-#endif
-
-  // default is false
-  if (properties.libModule())
-  {
-    lHints.lib_module = true;
-  }
-
-  Zorba_SerializerOptions lSerOptions;
+  switch ( z_props.getOptimizationLevel() ) {
+    case 0: hints.opt_level = ZORBA_OPT_LEVEL_O0; break;
+    case 2: hints.opt_level = ZORBA_OPT_LEVEL_O2; break;
+  }
+
+  hints.for_serialization_only = zc_props.serialize_only_query_;
+  hints.lib_module = zc_props.lib_module_;
+
+  Zorba_SerializerOptions ser_opts;
   try {
-    lSerOptions.set( properties.getSerializerParameters() );
+    ser_opts.set( zc_props.serialization_params_ );
   }
-  catch ( zorba::ZorbaException const &e ) {
-    std::cerr << e << std::endl;
+  catch ( ZorbaException const &e ) {
+    cerr << e << endl;
     return 11;
   }
-  createSerializerOptions(lSerOptions, properties);
+  set_serializer_opts( ser_opts );
 
-  zorba::XQuery_t query;
+  XQuery_t query;
   DiagnosticHandler diagnosticHandler;
 
-  for (unsigned long i = 0; i < lNumExecutions; ++i)
-  {
-    // start the total timer
-    if (doTiming)
-      timing.startTimer(TimingInfo::TOTAL_TIMER, i);
-    
+  for ( unsigned long exec = 0; exec < lNumExecutions; ++exec ) {
+    if ( zc_props.timing_ )
+      timers.startTimer( Timers::total, exec );
+
     //
     // Compile the query
     // Compilation is done only once, unless timing is needed
     //
-    if (doTiming || i == 0)
-    {
+    if ( zc_props.timing_ || exec == 0 ) {
       // go back to the beginning of the stream
-      qfile.clear();
-      qfile.seekg(0);
-      assert (qfile.tellg() >= 0);
+      qstream.clear();
+      qstream.seekg( 0 );
+      assert( qstream.tellg() >= 0 );
 
-      try
-      {
-        // start the compilation timer
-        if (doTiming)
-          timing.startTimer(TimingInfo::COMP_TIMER, i);
+      try {
+        if ( zc_props.timing_ )
+          timers.startTimer( Timers::comp, exec );
 
         // Create and compile the query
-        query = zorbaInstance->createQuery();
-        query->registerDiagnosticHandler(&diagnosticHandler);
-        query->setFileName(qfilepath);
-
-        if (loadPlan) 
-        {
-          query->loadExecutionPlan(qfile, &theSerializationCallback);
-
-          // stop the compilation timer
-          if (doTiming)
-            timing.stopTimer(TimingInfo::COMP_TIMER, i);
-        }
-        else
-        {
-          query->compile(qfile, staticContext, lHints);
-
-          // stop the compilation timer
-          if (doTiming)
-            timing.stopTimer(TimingInfo::COMP_TIMER, i);
+        query = zorba->createQuery();
+        query->registerDiagnosticHandler( &diagnosticHandler );
+        query->setFileName( qfilepath );
+
+        if ( zc_props.load_plan_ ) {
+          query->loadExecutionPlan( qstream, &serialization_callback );
+          if ( zc_props.timing_ )
+            timers.stopTimer( Timers::comp, exec );
+        } else {
+          query->compile( qstream, sctx, hints );
+
+          if ( zc_props.timing_ )
+            timers.stopTimer( Timers::comp, exec );
 
           // Serialize the execution plan, if requested
-          if (serializePlan) 
-          {
+          if ( zc_props.serialize_plan_ ) {
             planFilep->clear();
-            planFilep->seekp(0);
-
-            // start the plan-save timer
-            if (doTiming)
-              timing.startTimer(TimingInfo::PLAN_SAVE_TIMER, i);
-
-            query->saveExecutionPlan(*planFilep);
-
-            // stop the plan-save timer
-            if (doTiming)
-              timing.stopTimer(TimingInfo::PLAN_SAVE_TIMER, i);
-
+            planFilep->seekp( 0 );
+
+            if ( zc_props.timing_ )
+              timers.startTimer( Timers::plan_save, exec );
+            query->saveExecutionPlan( *planFilep );
+            if ( zc_props.timing_ )
+              timers.stopTimer( Timers::plan_save, exec );
             planFilep->flush();
           }
         }
       }
-      catch (zorba::XQueryException const& qe)
-      {
-        print_exception( qe, properties );
+      catch ( XQueryException const &qe ) {
+        print_exception( qe );
         return 11;
       }
-      catch (zorba::ZorbaException const& ze)
-      {
-        std::cerr << ze << std::endl;
+      catch ( ZorbaException const &ze ) {
+        cerr << ze << endl;
         return 12;
       }
-    } // if (doTiming || i == 0)
+    } // if (zc_props.timing_ || exec == 0)
 
     //
-    // Run the query, unless compileOnly has been requested.
+    // Run the query, unless compile-only has been requested.
     //
-    if ( ! properties.compileOnly() && ! properties.libModule() )
-    {
-      try
-      {
+    if ( !zc_props.compile_only_ && !zc_props.lib_module_ ) {
+      try {
         // load the execution plan, if requested
-        if (serializePlan) 
-        {
-          planFilep->seekg(0);
-          assert(planFilep->good());
-          
-          // start the plan-load timer
-          if (doTiming)
-            timing.startTimer(TimingInfo::PLAN_LOAD_TIMER, i);
-
-          query = zorbaInstance->createQuery();
-          query->loadExecutionPlan(*planFilep, &theSerializationCallback);
-
-          // stop the plan-load timer
-          if (doTiming)
-            timing.stopTimer(TimingInfo::PLAN_LOAD_TIMER, i);
+        if ( zc_props.serialize_plan_ ) {
+          planFilep->seekg( 0 );
+          assert( planFilep->good() );
+
+          if ( zc_props.timing_ )
+            timers.startTimer( Timers::plan_load, exec );
+
+          query = zorba->createQuery();
+          query->loadExecutionPlan( *planFilep, &serialization_callback );
+
+          if ( zc_props.timing_ )
+            timers.stopTimer( Timers::plan_load, exec );
         }
 
-        // start the execution timer
-        if (doTiming)
-          timing.startTimer(TimingInfo::EXEC_TIMER, i);
+        if ( zc_props.timing_ )
+          timers.startTimer( Timers::exec, exec );
 
         // Populate the dynamic context
-        zorba::DynamicContext* lDynamicContext = query->getDynamicContext();
-        try
-        {
-          if ( ! populateDynamicContext(zorbaInstance,
-                                        xmlDataMgr,
-                                        lDynamicContext,
-                                        properties) )
-          {
-            properties.printHelp(std::cout);
+        try {
+          DynamicContext *const dctx = query->getDynamicContext();
+          if ( !populateDynamicContext( zorba, xmlDataMgr, dctx ) ) {
+            print_help();
             return 21;
           }
         }
-        catch (zorba::XQueryException const& qe)
-        {
-          print_exception( qe, properties );
+        catch ( XQueryException const &qe ) {
+          print_exception( qe );
           return 22;
         }
-        catch (zorba::ZorbaException const& ze)
-        {
-          std::cerr << ze << std::endl;
+        catch ( ZorbaException const &ze ) {
+          cerr << ze << endl;
           return 23;
         }
 
         // run the query
-        if (properties.noSerializer())
-        {
+        if ( zc_props.no_serializer_ )
           query->executeSAX();
-        }
-        else if (savePlan)
-        {
-          query->saveExecutionPlan(outputStream);
-        }
+        else if ( zc_props.save_plan_ )
+          query->saveExecutionPlan( outputStream );
         else
-        {
-          query->execute(outputStream, &lSerOptions);
-        }
-
-        if (properties.trailingNl()) 
-          outputStream << std::endl;
- 
+          query->execute( outputStream, &ser_opts );
+
+        if ( zc_props.trailing_nl_ )
+          outputStream << endl;
+
         query->close();
 
-         // stop the execution timer
-        if (doTiming)
-          timing.stopTimer(TimingInfo::EXEC_TIMER, i);
+        if ( zc_props.timing_ )
+          timers.stopTimer( Timers::exec, exec );
 
-        if (i > 0 || lNumExecutions == 1) 
-        {
-          timing.elapsedLoadWalltime += query->getDocLoadingTime();
-          timing.elapsedLoadCputime += query->getDocLoadingUserTime();
+        if ( exec > 0 || lNumExecutions == 1 ) {
+          timers.elapsed_load_walltime += query->getDocLoadingTime();
+          timers.elapsed_load_cputime += query->getDocLoadingUserTime();
         }
       }
-      catch (zorba::XQueryException const& qe)
-      {
-        print_exception( qe, properties );
+      catch ( XQueryException const &qe ) {
+        print_exception( qe );
         return 31;
       }
-      catch (zorba::ZorbaException const& ze)
-      {
-        std::cerr << ze << std::endl;
+      catch ( ZorbaException const &ze ) {
+        cerr << ze << endl;
         return 32;
       }
     }
@@ -901,423 +515,376 @@
     //
     // Delete all loaded docs from the store, if timing has been requested
     //
-    if (doTiming)
-    {
-      timing.startTimer(TimingInfo::UNLOAD_TIMER, i);
+    if ( zc_props.timing_ ) {
+      timers.startTimer( Timers::unload, exec );
 
-      DocumentManager* docMgr = xmlDataMgr->getDocumentManager();
+      DocumentManager *const docMgr = xmlDataMgr->getDocumentManager();
       ItemSequence_t docsSeq = docMgr->availableDocuments();
-      Iterator_t lIter = docsSeq->getIterator();
-      lIter->open();
+      Iterator_t i( docsSeq->getIterator() );
+      i->open();
 
       Item uri;
-      std::vector<Item> docURIs;
-      while (lIter->next(uri)) 
-      {
-        docURIs.push_back(uri);
-      }
-      lIter->close();
-
-      size_t numDocs = docURIs.size();
-
-      for (size_t k = 0; k < numDocs; ++k)
-      {
-        docMgr->remove(docURIs[k].getStringValue());
-      }
-
-      timing.stopTimer(TimingInfo::UNLOAD_TIMER, i);
+      vector<Item> docURIs;
+      while ( i->next( uri ) )
+        docURIs.push_back( uri );
+      i->close();
+
+      for ( vector<Item>::const_iterator
+            i = docURIs.begin(); i != docURIs.end(); ++i ) {
+        docMgr->remove( i->getStringValue() );
+      }
+
+      timers.stopTimer( Timers::unload, exec );
     }
 
-    // stop the total timer
-    if (doTiming)
-      timing.stopTimer(TimingInfo::TOTAL_TIMER, i);
+    if ( zc_props.timing_ )
+      timers.stopTimer( Timers::total, exec );
 
 #ifdef DO_AUDIT
-    audit::Event* event = staticContext->getAuditEvent(); 
-    std::cerr << *event << std::endl;
-#endif
+    cerr << *sctx->getAuditEvent() << endl;
+#endif /* DO_AUDIT */
   } // for each execution
 
   return 0;
 }
 
-/////////////////////////////////////////////////////////////////////////////////
-//                                                                             //
-//  Main                                                                       //
-//                                                                             //
-/////////////////////////////////////////////////////////////////////////////////
+static void set_paths_on_sctx( StaticContext_t &sctx ) {
+  ZorbaCmdProperties &zc_props = ZorbaCmdProperties::instance();
+  vector<String> paths;
+
+  // Compute the current working directory to append to all paths.
+  string const cwd( fs::curdir() );
+
+  // setModulePaths() *overwrites* the URI path and lib path, so there's no
+  // sense in calling both. So if --module-path exists, just use it.
+
+  if ( !zc_props.module_path_.empty() ) {
+    tokenize( zc_props.module_path_, fs::path_separator, &paths );
+    paths.push_back( cwd );
+    sctx->setModulePaths( paths );
+  } else {
+    // Compute and set URI path
+    tokenize( zc_props.uri_path_, fs::path_separator, &paths );
+    paths.push_back( cwd );
+    sctx->setURIPath( paths );
+    paths.clear();
+
+    // Compute and set lib path
+    tokenize( zc_props.lib_path_, fs::path_separator, &paths );
+    paths.push_back( cwd );
+    sctx->setLibPath( paths );
+  }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+//  Main                                                                     //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
 
 #ifndef _WIN32_WCE
-int
-main(int argc, char* argv[])
+int main( int argc, char const *argv[] ) {
 #else
-int
-_tmain(int argc, _TCHAR* argv[])
-#endif
-{
-#if ZORBACMD_LOAD_SYSTEM_PROPERTIES
-  // only configurable via a config file or environment vars
-  zorba::Properties::load(0, NULL);
-#endif
-
-  // parse the command line and/or the properties file
-  ZorbaCMDProperties properties;
-  if (!properties.loadProperties(argc, argv))
-  {
-    return 1;
-  }
-
-  TimingInfo engineTiming(properties.multiple());
-
-  bool doTiming = properties.timing();
-  bool debug = false;
+int _tmain( int argc, _TCHAR const *argv[] ) {
+#endif
+  int const optind = parse_args( argc, argv );
+  argc -= optind;
+  argv += optind;
+
+  Properties const &z_props = Properties::instance();
+  ZorbaCmdProperties const &zc_props = ZorbaCmdProperties::instance();
+
+  Timers timers( zc_props.multiple_ );
+
 #ifdef ZORBA_WITH_DEBUGGER
-  debug = (properties.debug());
+  bool const debug = zc_props.debug_;
+#else
+  bool const debug = false;
 #endif
 
-  // libModule assumes compileOnly even if compileOnly is false
-  bool compileOnly = (properties.compileOnly() || properties.libModule() );
+  // libModule assumes compile-only even if compile-only is false
+  bool const compile_only = zc_props.compile_only_ || zc_props.lib_module_;
 
   // write to file or standard out
-  std::unique_ptr<std::ostream> 
-  lFileStream(
-      #ifdef ZORBA_WITH_FILE_ACCESS
-        properties.outputFile().size() > 0 ?
-          new std::ofstream(properties.outputFile().c_str()) : 0
-      #else /* ZORBA_WITH_FILE_ACCESS */
-        0
-      #endif /* ZORBA_WITH_FILE_ACCESS */
-        );
+  unique_ptr<ostream> out_stream_ptr(
+#ifdef ZORBA_WITH_FILE_ACCESS
+    !zc_props.output_file_.empty() ?
+      new ofstream( zc_props.output_file_.c_str() ) : 0
+#else /* ZORBA_WITH_FILE_ACCESS */
+    0
+#endif /* ZORBA_WITH_FILE_ACCESS */
+  );
 
-  std::ostream* lOutputStream = lFileStream.get();
-  if ( lOutputStream == 0 )
-  {
-    lOutputStream = &std::cout;
-  }
+  ostream *out_stream = out_stream_ptr.get();
+  if ( !out_stream )
+    out_stream = &cout;
 #ifdef ZORBA_WITH_FILE_ACCESS
-  else if ( !lOutputStream->good() )
-  {
-    std::cerr << "could not write to output file {" << properties.outputFile()
-              << "}" << std::endl;
+  else if ( !out_stream->good() ) {
+    cerr << "could not write to output file {" << zc_props.output_file_
+         << '}' << endl;
     return 2;
   }
 #endif /* ZORBA_WITH_FILE_ACCESS */
 
-  if (properties.queriesOrFilesBegin() == properties.queriesOrFilesEnd())
-  {
-    std::cerr << "no queries submitted." << std::endl;
-    properties.printHelp(std::cout);
+  if ( zc_props.queries_or_files_.empty() ) {
+    cerr << "no queries submitted." << endl;
+    print_help();
     return 3;
   }
 
-  // Add command line --classpath option in front of config/env CLASSPATH
-  Properties* globaproperties = Properties::instance();
-  std::string cmdJvmClassPath;
-  properties.getJVMClassPath(cmdJvmClassPath);
-  std::string configJvmClassPath;
-  globaproperties->getJVMClassPath(configJvmClassPath);
-  globaproperties->setJVMClassPath(cmdJvmClassPath +
-      fs::path_separator + configJvmClassPath);
-
   // Start the engine
 
-  engineTiming.startTimer(TimingInfo::INIT_TIMER, 2);
-
-  void* store = zorba::StoreManager::getStore();
-
-  zorba::Zorba* lZorbaInstance = zorba::Zorba::getInstance(store);
-
-  zorba::XmlDataManager_t xmlDataMgr = lZorbaInstance->getXmlDataManager();
+  timers.startTimer( Timers::init, 2 );
+
+  void *const store = StoreManager::getStore();
+  Zorba *const zorba = Zorba::getInstance( store );
+
+  XmlDataManager_t xmlDataMgr = zorba->getXmlDataManager();
 
 #ifdef DO_AUDIT
-  zorba::audit::Provider* lAuditProvider = lZorbaInstance->getAuditProvider();
-
-  zorba::audit::Configuration* config = lAuditProvider->createConfiguration();
-
-  std::vector<zorba::String> property_names;
-  zorba::audit::Configuration::getPropertyNames(property_names);
-
-  zorba::audit::Configuration::
+  audit::Provider* lAuditProvider = zorba->getAuditProvider();
+
+  audit::Configuration* config = lAuditProvider->createConfiguration();
+
+  vector<String> property_names;
+  audit::Configuration::getPropertyNames(property_names);
+
+  audit::Configuration::
   enableProperty(config, property_names, "xquery/compilation/parse-duration");
 
-  zorba::audit::Configuration::
+  audit::Configuration::
   enableProperty(config, property_names, "xquery/compilation/translation-duration");
 
-  zorba::audit::Configuration::
+  audit::Configuration::
   enableProperty(config, property_names, "xquery/compilation/optimization-duration");
 
-  zorba::audit::Configuration::
+  audit::Configuration::
   enableProperty(config, property_names, "xquery/compilation/codegeneration-duration");
 #endif
 
   {
-  engineTiming.stopTimer(TimingInfo::INIT_TIMER, 2);
+  timers.stopTimer( Timers::init, 2 );
 
   // For each query ...
 
-  int queryNo;
-  ZorbaCMDProperties::QueriesOrFiles_t::const_iterator lIter;
-  for (queryNo = 1, lIter = properties.queriesOrFilesBegin();
-       lIter != properties.queriesOrFilesEnd();
-       ++queryNo, ++lIter)
-  {
+  int query_no;
+  vector<string>::const_iterator i;
+  for ( query_no = 1, i = zc_props.queries_or_files_.begin();
+        i != zc_props.queries_or_files_.end(); ++query_no, ++i ) {
     //
     // Read the query (either from a file or given as parameter)
     //
-    std::string fURI = *lIter;
-    std::string fname = parseFileURI (properties.asFiles (), fURI);
-    std::string path( fname );
-    bool asFile = !fname.empty();
-    std::unique_ptr<std::istream> qfile;
+    string const uri( *i );
+    string const fname( zc_props.as_files_ ? uri : parse_file_uri( uri ) );
+    string path( fname );
+    bool const as_file = !fname.empty();
+    unique_ptr<istream> qstream;
 
-    if (asFile)
-    {
+    if ( as_file ) {
       fs::make_absolute( &path );
-      qfile.reset( new std::ifstream( path.c_str() ) );
-    }
-    else
-    {
-      qfile.reset(new std::istringstream(fURI));
+      qstream.reset( new ifstream( path.c_str() ) );
+    } else {
+      qstream.reset( new istringstream( uri ) );
     }
 
-    if (asFile && (!qfile->good() || qfile->eof()))
-    {
-      std::cerr << "file {" << fname << "} not found or not readable." << std::endl;
-      properties.printHelp(std::cout);
+    if ( as_file && (!qstream->good() || qstream->eof()) ) {
+      cerr << "file {" << fname << "} not found or not readable." << endl;
+      print_help();
       return 3;
-    }
-    else if (fURI.empty ())
-    {
-      std::cerr << "empty query." << std::endl;
-      properties.printHelp(std::cout);
+    } else if ( uri.empty() ) {
+      cerr << "empty query." << endl;
+      print_help();
       return 3;
     }
 
     //
     // Print the query if requested
     //
-    if (properties.printQuery()) 
-    {
-      *lOutputStream << "\nQuery number " << queryNo << " :\n";
-      std::copy (std::istreambuf_iterator<char> (*qfile),
-                 std::istreambuf_iterator<char> (),
-                 std::ostreambuf_iterator<char> (*lOutputStream));
-      *lOutputStream << std::endl;
-      // go back to the beginning
-      qfile->seekg(0);
+    if ( zc_props.print_query_ ) {
+      *out_stream << "\nQuery number " << query_no << " :\n";
+      copy(
+        istreambuf_iterator<char>( *qstream ),
+        istreambuf_iterator<char>(),
+        ostreambuf_iterator<char>( *out_stream )
+      );
+      *out_stream << endl;
+      qstream->seekg( 0 );
     }
 
     //
-    // Create the static context and populate it with info taken from the properties
+    // Create the static context and populate it with info taken from the
+    // properties
     //
-    zorba::StaticContext_t lStaticContext = lZorbaInstance->createStaticContext();
+    StaticContext_t sctx = zorba->createStaticContext();
 
-    if (! populateStaticContext(lZorbaInstance, lStaticContext, properties) )
-    {
-      properties.printHelp(std::cout);
+    if ( !populateStaticContext( zorba, sctx ) ) {
+      print_help();
       return 3;
     }
 
 #ifdef DO_AUDIT
-    zorba::audit::Event* event = lAuditProvider->createEvent(config);
-    lStaticContext->setAuditEvent(event);
+    audit::Event *event = lAuditProvider->createEvent( config );
+    sctx->setAuditEvent( event );
 #endif // DO_AUDIT
 
-    if (!asFile && properties.baseUri().size() == 0 )
-    {
+    if ( !as_file && zc_props.base_uri_.empty() ) {
       // No user set base URI. Set the cwd to be used as base-uri in order
       // to make the doc function doc("mydoc.xml") work
-      std::string p( fs::curdir() );
-      std::stringstream lTmp;
-      std::vector<std::string> lTokens;
-      std::string const delim( 1, fs::dir_separator );
-      Util::tokenize(p.c_str(), delim, lTokens);
+      string p( fs::curdir() );
+      stringstream lTmp;
+      vector<string> lTokens;
+      tokenize( p, fs::dir_separator, &lTokens );
 
       lTmp << "file://";
-      for (std::vector<std::string>::const_iterator lIter = lTokens.begin();
-           lIter != lTokens.end(); ++lIter)
-      {
-        zorba::String lTmpString(*lIter);
-        lTmp << '/' << fn::encode_for_uri( lTmpString );
+      for ( vector<string>::const_iterator i = lTokens.begin();
+            i != lTokens.end(); ++i ) {
+        String s( *i );
+        lTmp << '/' << fn::encode_for_uri( s );
       }
 
       lTmp << '/';
-
-      lStaticContext->setBaseURI(lTmp.str());
+      sctx->setBaseURI( lTmp.str() );
     }
 
     // Parse the query
-    if (properties.parseOnly()) 
-    {
-      try 
-      {
-        zorba::XQuery_t lQuery = lZorbaInstance->createQuery();
-        if (asFile)
-        {
-          lQuery->setFileName(path);
-        }
+    if ( zc_props.parse_only_ ) {
+      try {
+        XQuery_t lQuery = zorba->createQuery();
+        if ( as_file )
+          lQuery->setFileName( path );
 
-        lQuery->parse (*qfile);
+        lQuery->parse (*qstream);
       }
-      catch (zorba::ZorbaException const& ze) 
-      {
-        std::cerr << ze << std::endl;
+      catch ( ZorbaException const &ze ) {
+        cerr << ze << endl;
         return 6;
       }
     }
 
     // Compile and run it if necessary.
     // Print timing information if requested.
-    else if (!debug) 
-    {
-      if (compileOnly) 
-      {
-        try 
-        {
-          zorba::XQuery_t aQuery = lZorbaInstance->createQuery();
-          if (asFile) 
-          {
-            aQuery->setFileName(path);
-          }
-
-          aQuery->parse(*qfile);
-
-          qfile->clear();
-          qfile->seekg(0); // go back to the beginning
+    else if ( !debug ) {
+      if ( compile_only ) {
+        try {
+          XQuery_t aQuery = zorba->createQuery();
+          if ( as_file )
+            aQuery->setFileName( path );
+
+          aQuery->parse( *qstream );
+          qstream->clear();
+          qstream->seekg( 0 );
         }
-        catch (zorba::XQueryException const& qe)
-        {
-          print_exception( qe, properties );
+        catch ( XQueryException const &qe ) {
+          print_exception( qe );
           return 6;
         }
       }
 
-      TimingInfo queryTiming(properties.multiple());
+      Timers queryTiming( zc_props.multiple_ );
 
-      int status = compileAndExecute(lZorbaInstance,
+      int status = compileAndExecute(zorba,
                                      xmlDataMgr,
-                                     properties,
-                                     lStaticContext,
+                                     sctx,
                                      path,
-                                     *qfile,
-                                     *lOutputStream,
+                                     *qstream,
+                                     *out_stream,
                                      queryTiming);
-      if (status != 0) 
-      {
+      if ( status != 0 ) {
         // reset the file handler (in case output option was provided)
         // in order to delete the created output file
-        lFileStream.reset();
-        removeOutputFileIfNeeded(properties);
+        out_stream_ptr.reset();
+        remove_output_file();
         return status;
       }
 
-      if (doTiming) 
-      {
-        bool serializePlan = properties.serializePlan();
-        queryTiming.print(std::cout, serializePlan);
-      }
+      if ( zc_props.timing_ )
+        queryTiming.print( cout, zc_props.serialize_plan_ );
     }
 
 #ifdef ZORBA_WITH_DEBUGGER
-    // Debug the query. Do not allow "compileOnly" flags and inline queries
-    else if (debug) 
-    {
-      if (compileOnly) 
-      {
-        std::cerr << "cannot debug a query if the compileOnly option is specified"
-                  << std::endl;
+    // Debug the query. Do not allow "compile_only" flags and inline queries
+    else if ( debug ) {
+      if ( compile_only ) {
+        cerr << "cannot debug a query if the --compile-only option is specified"
+             << endl;
         return 7;
       }
 
-      if (!asFile) 
-      {
-        std::cerr << "Cannot debug inline queries." << std::endl;
+      if ( !as_file ) {
+        cerr << "Cannot debug inline queries." << endl;
         return 8;
       }
 
-      std::unique_ptr<std::istream> lXQ(new std::ifstream(path.c_str()));
-      std::string lFileName(path);
-
-      zorba::XQuery_t lQuery;
-
-      try 
-      {
-        lQuery = lZorbaInstance->createQuery();
-        lQuery->setFileName(lFileName);
-        lQuery->setDebugMode(true);
-
-        Zorba_CompilerHints lHints;
-        lHints.opt_level = ZORBA_OPT_LEVEL_O0;
-
-        lQuery->compile(*lXQ.get(), lHints);
-        zorba::DynamicContext* lDynamicContext = lQuery->getDynamicContext();
-        if (!populateDynamicContext(lZorbaInstance,
+      unique_ptr<istream> lXQ( new ifstream( path.c_str() ) );
+
+      XQuery_t query;
+
+      try {
+        query = zorba->createQuery();
+        query->setFileName( path );
+        query->setDebugMode( true );
+
+        Zorba_CompilerHints hints;
+        hints.opt_level = ZORBA_OPT_LEVEL_O0;
+
+        query->compile( *lXQ.get(), hints );
+        if (!populateDynamicContext(zorba,
                                     xmlDataMgr,
-                                    lDynamicContext,
-                                    properties))
+                                    query->getDynamicContext(),
+                                    zc_props))
         {
           return 9;
         }
 
-        std::string lHost = properties.debugHost();
-        if (lHost == "") {
-          lHost = "127.0.0.1";
-        }
-
-        Zorba_SerializerOptions lSerOptions(properties.getSerializerParameters());
-        createSerializerOptions(lSerOptions, properties);
-
-        if (!properties.hasNoLogo()) 
-        {
-          std::cout << "Zorba XQuery Debugger Server\n" << copyright_str << std::endl;
-        }
-
-        lQuery->debug(*lOutputStream, lSerOptions, lHost, properties.getDebugPort());
+        Zorba_SerializerOptions ser_opts( zc_props.serialization_params_ );
+        set_serializer_opts( ser_opts );
+
+        if ( !zc_props.no_logo_ )
+          cout << "Zorba XQuery Debugger Server\n" << copyright << endl;
+
+        query->debug( *out_stream, ser_opts, zc_props.debug_host_, zc_props.debug_port );
       }
-      catch (zorba::XQueryException const& qe)
-      {
-        print_exception( qe, properties );
+      catch ( XQueryException const &qe ) {
+        print_exception( qe );
         return 5;
       }
-      catch (zorba::ZorbaException const& ze)
-      {
-        std::cerr << ze << std::endl;
+      catch ( ZorbaException const &ze ) {
+        cerr << ze << endl;
         return 6;
       }
     } // else if (debug)
-#endif
+#endif /* ZORBA_WITH_DEBUGGER */
 
 #ifdef DO_AUDIT
-    lAuditProvider->submitEvent(event);
+    lAuditProvider->submitEvent( event );
 #endif
 
   } // for each query
 
   }
 
-  if (doTiming)
-  {
-    engineTiming.startTimer(TimingInfo::DEINIT_TIMER, 2);
-  }
+  if ( zc_props.timing_ )
+    timers.startTimer( Timers::deinit, 2 );
 
 #ifdef DO_AUDIT
   lAuditProvider->destroyConfiguration(config);
-#endif
-
-  xmlDataMgr = NULL;
-
-  lZorbaInstance->shutdown();
-  zorba::StoreManager::shutdownStore(store);
-
-  if (doTiming)
-  {
-    engineTiming.stopTimer(TimingInfo::DEINIT_TIMER, 2);
-
-    std::cout << std::endl << "Engine Shutdown Time     : "
-              << engineTiming.elapsedDeinitWalltime
-              << " (user: " << engineTiming.elapsedDeinitCputime << ")"
-              << " milliseconds" << std::endl;
+#endif /* DO_AUDIT */
+
+  zorba->shutdown();
+  StoreManager::shutdownStore( store );
+
+  if ( zc_props.timing_ ) {
+    timers.stopTimer( Timers::deinit, 2 );
+
+    cout << endl << "Engine Shutdown Time     : "
+         << timers.elapsed_deinit_walltime
+         << " (user: " << timers.elapsed_deinit_cputime << ")"
+         << " milliseconds" << endl;
   }
+
   return 0;
 }
+
+///////////////////////////////////////////////////////////////////////////////
+
 /* vim:set et sw=2 ts=2: */

=== added file 'bin/zorbacmd_args.cpp'
--- bin/zorbacmd_args.cpp	1970-01-01 00:00:00 +0000
+++ bin/zorbacmd_args.cpp	2014-02-10 00:46:59 +0000
@@ -0,0 +1,783 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// standard
+#include <algorithm>
+#include <cstdlib>
+#include <cctype>
+#include <iostream>
+
+// Zorba
+#include <zorba/zorba.h>
+#include <zorba/properties.h>
+
+// local
+#include "zorbacmd_props.h"
+
+using namespace std;
+using namespace zorba;
+
+///////////////////////////////////////////////////////////////////////////////
+
+static char const* check_args() {
+  ZorbaCmdProperties const &zc_props = ZorbaCmdProperties::instance();
+
+  if ( !( zc_props.boundary_space_.empty() ||
+          zc_props.boundary_space_ == "preserve" ||
+          zc_props.boundary_space_ == "strip" ) )
+    return "Only strip and preserve are allowed as values for the option boundary-space";
+
+  if ( !( zc_props.construction_mode_.empty() ||
+          zc_props.construction_mode_ == "preserve" ||
+          zc_props.construction_mode_ == "strip" ) )
+    return "Only strip and preserve are allowed as values for the option construction-mode";
+
+  if ( zc_props.optimization_level_ > 2 )
+    return "only 0, 1 and 2 are allowed as values for the option --optimization-level";
+
+  if ( !( zc_props.ordering_mode_.empty() ||
+          zc_props.ordering_mode_ == "ordered" ||
+          zc_props.ordering_mode_ == "unordered" ) )
+    return "Only ordered and unordered are allowed as values for the option ordering-mode";
+
+  if ( zc_props.queries_or_files_.empty() )
+    return "No queries submitted\nUsage: zorba -q '1 + 1' execute an inline query \n zorba file.xq execute a query from a file";
+
+  return 0;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+#define HELP_OPT(ARG) ARG "\n"
+
+char const* get_help_msg() {
+  return
+
+    ////////// a //////////////////////////////////////////////////////////////
+
+#ifndef NDEBUG
+    HELP_OPT( "--abort" )
+      "Call abort(3) when a ZorbaException is thrown.\n\n"
+#endif /* NDEBUG */
+
+    HELP_OPT( "--as-files, -f" )
+      "Treat all -q arguments as file paths instead of URIs or inline queries. This option is deprecated and will be defaulted to true in the future, so any entry in the command line is going to be treated as files.\n\n"
+
+    ////////// b //////////////////////////////////////////////////////////////
+
+    HELP_OPT( "--base-uri" )
+      "Set the base URI property of the static context.\n\n"
+
+    HELP_OPT( "--boundary-space" )
+      "Set the boundary-space policy ('strip' or 'preserve') in the static context.\n\n"
+
+    HELP_OPT( "--byte-order-mark" )
+      "Set the byte-order-mark for the serializer.\n\n"
+
+    ////////// c //////////////////////////////////////////////////////////////
+
+    HELP_OPT( "--classpath" )
+      "JVM classpath to be used by modules using Java implementations\n\n"
+
+    HELP_OPT( "--compile-only" )
+      "Only compile (don't execute).\n\n"
+
+    HELP_OPT( "--compile-plan," )
+      "Do not execute the query; just compile it and save the execution plan in the file specified with the -o option.\n\n"
+
+    HELP_OPT( "--construction-mode" )
+      "Set the construction mode ('strip' or 'preserve') in the static context.\n\n"
+
+    HELP_OPT( "--context-item" )
+      "Set the context item to the XML document in a given file.\n\n"
+
+    ////////// d //////////////////////////////////////////////////////////////
+
+#ifdef ZORBA_WITH_DEBUGGER
+    HELP_OPT( "--debug, -d" )
+      "Launch the Zorba debugger server and connect to a DBGP-enabled debugger client.\n\n"
+#endif /* ZORBA_WITH_DEBUGGER */
+
+    HELP_OPT( "--debug-file" )
+      "Sets the file to write developer debugging information to.\n\n"
+
+#ifdef ZORBA_WITH_DEBUGGER
+    HELP_OPT( "--debug-host, -h" )
+      "The host where the DBGP-enabled debugger client listens for connections. Defaults to: 127.0.0.1\n\n"
+
+    HELP_OPT( "--debug-port, -p" )
+      "The port on which the DBGP-enabled debugger client listens for connections. Defaults to: 28028\n\n"
+#endif /* ZORBA_WITH_DEBUGGER */
+
+    HELP_OPT( "--default-collation" )
+      "Add the given collation and set the value of the default collation in the static context to the given collation.\n\n"
+
+    HELP_OPT( "--disable-http-resolution" )
+      "Do not use HTTP to resolve URIs.\n\n"
+
+    HELP_OPT( "--dump-lib" )
+      "Dump function library.\n\n"
+
+    ////////// e //////////////////////////////////////////////////////////////
+
+    HELP_OPT( "--execute-plan" )
+      "Do not compile the query; instead load the execution plan from the file specified by the -f -q options (or by any file specified without any other argument), and execute the loaded plan.\n\n"
+
+    HELP_OPT( "--external-variable, -e" )
+      "Provide the value for a variable given a file (name=file) or a value (name:=value)\n\n"
+
+    ////////// f //////////////////////////////////////////////////////////////
+
+    HELP_OPT( "--force-gflwor" )
+      "Force the compiler to generate GFLWOR iterators.\n\n"
+
+    ////////// h //////////////////////////////////////////////////////////////
+
+    HELP_OPT( "--help, -h" )
+      "Print this help message.\n\n"
+
+    ////////// i //////////////////////////////////////////////////////////////
+
+    HELP_OPT( "--indent, -i" )
+      "Indent output.\n\n"
+
+    HELP_OPT( "--infer-joins" )
+      "Infer joins.\n\n"
+
+    HELP_OPT( "--inline-udf" )
+      "Inline user-defined functions.\n\n"
+
+    ////////// j //////////////////////////////////////////////////////////////
+
+    HELP_OPT( "--jsoniq, -j" )
+      "Force queries to be considered JSONiq.\n\n"
+
+    ////////// l //////////////////////////////////////////////////////////////
+
+    HELP_OPT( "--lib-module, -l" )
+      "Query compiler option to treat the query as a library module. If this is set --compile-only option is also set to true.\n\n"
+
+    HELP_OPT( "--lib-path" )
+      "Library path (list of directories) where Zorba will look for dynamic libraries (e.g., module external function implementations.\n\n"
+
+    HELP_OPT( "--loop-hosting" )
+      "Hoist expressions out of loops.\n\n"
+
+    ////////// m //////////////////////////////////////////////////////////////
+
+    HELP_OPT( "--max-udf-call-depth" )
+      "Maximum stack depth of user-defined function calls.\n\n"
+
+    HELP_OPT( "--module-path" )
+      "Path (list of directories) to add to both the URI and Library paths.\n\n"
+
+    HELP_OPT( "--multiple, -m" )
+      "Execute the given queries multiple times.\n\n"
+
+    ////////// n //////////////////////////////////////////////////////////////
+
+    HELP_OPT( "--no-copy-optim" )
+      "Apply the no-copy optimization.\n\n"
+
+    HELP_OPT( "--no-logo" )
+      "Print no logo when starting.\n\n"
+
+    HELP_OPT( "--no-serializer" )
+      "Do not serialize (discard) result.\n\n"
+
+    HELP_OPT( "--no-tree-ids" )
+      "Suppress IDs and locations from compiler tree dumps.\n\n"
+
+    ////////// o //////////////////////////////////////////////////////////////
+
+    HELP_OPT( "--omit-xml-declaration, -r" )
+      "Omit the XML declaration from the result.\n\n"
+
+    HELP_OPT( "--optimization-level, -O" )
+      "Optimization level for the query compiler [0-2], default: 1\n\n"
+
+    HELP_OPT( "--option" )
+      "Set an XQuery option in the static context. The QName of the option is passed as a string in the notation by James Clark (i.e. {namespace}localname). For example, --option {http://zorba.io/}option=value\n\n";
+
+    HELP_OPT( "--ordering-mode" )
+      "Set the ordering mode ('ordered' or 'unordered') in the static context.\n\n"
+
+#ifdef ZORBA_WITH_FILE_ACCESS
+    HELP_OPT( "--output-file, -o" )
+      "Write the result to the given file.\n\n"
+#endif /* ZORBA_WITH_FILE_ACCESS */
+
+    ////////// p //////////////////////////////////////////////////////////////
+
+    HELP_OPT( "--parse-only" )
+      "Stop after parsing the query.\n\n"
+
+    HELP_OPT( "--print-ast" )
+      "Print the abstract syntax tree.\n\n"
+
+    HELP_OPT( "--print-errors-as-xml, -x" )
+      "Print the errors as XML.\n\n"
+
+    HELP_OPT( "--print-intermediate-opt" )
+      "Print intermediate optimizations.\n\n"
+
+    HELP_OPT( "--print-item-flow" )
+      "Print items produced by all iterators.\n\n"
+
+    HELP_OPT( "--print-iterator-tree" )
+      "Print the iterator tree.\n\n"
+
+    HELP_OPT( "--print-locations" )
+      "Print parser locations for compiler expressions.\n\n"
+
+    HELP_OPT( "--print-optimized" )
+      "Print the optimized expression tree.\n\n"
+
+    HELP_OPT( "--print-query" )
+      "Print the queries.\n\n"
+
+    HELP_OPT( "--print-static-types" )
+      "Print static type inference.\n\n"
+
+    HELP_OPT( "--print-translated" )
+      "Print the normalized expression tree.\n\n"
+
+    ////////// q //////////////////////////////////////////////////////////////
+
+    HELP_OPT( "--query, -q" )
+      "Query test or file URI (file://...)\n\n"
+
+    ////////// s //////////////////////////////////////////////////////////////
+
+    HELP_OPT( "--serialization-parameter, -z" )
+      "Set serialization parameter in the form of a parameter=value pair (see http://www.w3.org/TR/xslt-xquery-serialization/#serparam, e.g.: -z method=xhtml -z doctype-system=DTD/xhtml1-strict.dtd -z indent=yes).\n\n"
+
+    HELP_OPT( "--serialize-html" )
+      "Serialize the result as HTML.\n\n"
+
+    HELP_OPT( "--serialize-plan, -s" )
+      "Serialize and then load the query execution plan.\n\n"
+
+    HELP_OPT( "--serialize-only-query" )
+      "Serialize only query.\n\n"
+
+    HELP_OPT( "--serialize-plan, s" )
+      "Serialize and then load the query execution plan.\n\n"
+
+    HELP_OPT( "--serialize-text" )
+      "Serialize the result as text.\n\n"
+
+    HELP_OPT( "--stable-iterator-ids" )
+      "Print the iterator plan with stable IDs.\n\n"
+
+#ifndef ZORBA_NO_FULL_TEXT
+    HELP_OPT( "--stop-words" )
+      "Mapping specifying a stop-words URI to another.\n\n"
+
+    ////////// t //////////////////////////////////////////////////////////////
+
+    HELP_OPT( "--thesaurus" )
+      "Mapping specifying a thesaurus URI to another.\n\n"
+#endif /* ZORBA_NO_FULL_TEXT */
+
+    HELP_OPT( "--timing, -t" )
+      "Print timing information. In case of multiple queries, the timing information is provided per query. Both wallclock time and user time (which excludes I/O, network delays and other kernel waits) are shown.\n\n"
+
+    HELP_OPT( "--timeout" )
+      "Specify a timeout in seconds. After the specified time, the execution of the query will be aborted.\n\n"
+
+    HELP_OPT( "--trace-parsing" )
+      "Trace parsing.\n\n"
+
+    HELP_OPT( "--trace-scanning" )
+      "Trace scanning.\n\n"
+
+#ifndef NDEBUG
+    HELP_OPT( "--trace-codegen" )
+      "Trace code generatio.\n\n"
+
+    HELP_OPT( "--trace-fulltext" )
+      "Trace full-text.\n\n"
+
+    HELP_OPT( "--trace-translator" )
+      "Trace the translator.\n\n"
+#endif /* NDEBUG */
+
+    HELP_OPT( "--trailing-nl" )
+      "Print a trailing newline after the result of the query.\n\n"
+
+    ////////// u //////////////////////////////////////////////////////////////
+
+    HELP_OPT( "--uri-path" )
+      "URI path (list of directories) added to the built-in URI resolver, i.e. where to find modules/schemas to import.\n\n"
+
+    ////////// v //////////////////////////////////////////////////////////////
+
+    HELP_OPT( "--version, -v" )
+      "Print the version number and exit.\n\n"
+
+    ;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+static bool split_key_value( char const *s, char const *split,
+                             string *key, string *value ) {
+  char const *const p = strstr( s, split );
+  size_t const split_len = strlen( split );
+  if ( !p || p == s /* =xxx */ || !p[ split_len ] /* xxx= */ )
+    return false;
+  key->assign( s, 0, p - s );
+  value->assign( p + split_len );
+  return true;
+}
+
+inline char to_lower( char c ) {
+  return tolower( c );
+}
+
+template<class StringType> inline
+typename enable_if<ZORBA_IS_STRING(StringType),void>::type
+to_lower( StringType &s ) {
+  transform(
+    s.begin(), s.end(), s.begin(), static_cast<char (*)(char)>( to_lower )
+  );
+}
+
+static bool bool_of( char const *s ) {
+  string b( s );
+  to_lower( b );
+  if ( b == "t" || b == "true" || b == "y" || b == "yes" || b == "1" )
+    return true;
+  if ( b == "f" || b == "false" || b == "n" || b == "no" || b == "0" )
+    return false;
+  cerr << '"' << s << "\": invalid boolean value" << endl;
+  exit( 1 );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+#define IS_LONG_OPT(OPT)  (strcmp( *argv, (OPT) ) == 0)
+#define IS_SHORT_OPT(OPT) (strncmp( *argv, (OPT), 2 ) == 0)
+#define IS_OPT(LOPT,SOPT) (IS_LONG_OPT(LOPT) || IS_SHORT_OPT(SOPT))
+
+#define PARSE_ARG(ARG)                                                    \
+  int offset = 2;                                                         \
+  if ( (*argv)[1] == '-' || !(*argv)[2] ) { offset = 0; ++argv; }         \
+  if ( !*argv ) { error = "No value given for " #ARG " option"; break; }
+
+#define ARG_VAL (*argv + offset)
+
+template<typename T> inline
+void atoi( char const *s,  T *result, int offset = 0 ) {
+  istringstream iss( s + offset );
+  iss >> *result;
+}
+
+#define SET_ZCPROP(PROP) \
+  atoi( *argv, &zc_props.PROP, offset )
+
+template<class C,typename T> inline
+void atoi( char const *s, C &c, void (C::*f)( T ), int offset = 0 ) {
+  T temp;
+  atoi( s, &temp, offset );
+  (c.*f)( temp );
+}
+
+#define SET_ZPROP(PROP) \
+  atoi( *argv, z_props, &Properties::set##PROP, offset )
+
+int parse_args( int argc, char const *argv[] ) {
+  bool got_as_files = false;
+  char const *error = 0;
+  Properties &z_props = Properties::instance();
+  ZorbaCmdProperties &zc_props = ZorbaCmdProperties::instance();
+
+  char const **const argv_orig = argv;
+  for ( ++argv; *argv; ++argv ) {
+
+    ////////// a //////////////////////////////////////////////////////////////
+
+#ifndef NDEBUG
+    if ( IS_LONG_OPT( "--abort" ) )
+      z_props.setAbort( true );
+    else
+#endif /* NDEBUG */
+    if ( IS_OPT( "--as-files", "-f" ) ) {
+      zc_props.as_files_ = true;
+      got_as_files = true;
+    }
+
+    ////////// b //////////////////////////////////////////////////////////////
+
+    else if ( IS_LONG_OPT( "--base-uri" ) ) {
+      PARSE_ARG( "--base-uri" );
+      zc_props.base_uri_ = ARG_VAL;
+    }
+    else if ( IS_LONG_OPT( "--boundary-space" ) ) {
+      PARSE_ARG( "--boundary-space" );
+      zc_props.boundary_space_ = ARG_VAL;
+    }
+    else if ( IS_LONG_OPT( "--byte-order-mark" ) )
+      zc_props.byte_order_mark_ = true;
+
+    ////////// c //////////////////////////////////////////////////////////////
+
+    else if ( IS_LONG_OPT( "--classpath" ) ) {
+      PARSE_ARG( "--classpath" );
+      z_props.setJVMClassPath( ARG_VAL );
+    }
+    else if ( IS_LONG_OPT( "--compile-only" ) )
+      zc_props.compile_only_ = true;
+    else if ( IS_LONG_OPT( "--compile-plan" ) )
+      zc_props.save_plan_ = true;
+    else if ( IS_LONG_OPT( "--construction-mode" ) ) {
+      PARSE_ARG( "--construction-mode" );
+      zc_props.construction_mode_ = ARG_VAL;
+    }
+    else if ( IS_LONG_OPT( "--context-item" ) ) {
+      PARSE_ARG( "--context-item" );
+      zc_props.ctx_item_ = ARG_VAL;
+    }
+
+    ////////// d //////////////////////////////////////////////////////////////
+
+#ifdef ZORBA_WITH_DEBUGGER
+    else if ( IS_OPT( "--debug", "-d" ) )
+      zc_props->debug_ = true;
+#endif /* ZORBA_WITH_DEBUGGER */
+    else if ( IS_LONG_OPT( "--debug-file" ) ) {
+      PARSE_ARG( "--debug-file" );
+      z_props.setDebugFile( ARG_VAL );
+    }
+#ifdef ZORBA_WITH_DEBUGGER
+    else if ( IS_OPT( "--debug-host", "-h" ) ) {
+      PARSE_ARG( "--debug-host" );
+      zc_props.debugger_host_ = ARG_VAL;
+    }
+    else if ( IS_OPT( "--debug-port", "-p" ) ) {
+      PARSE_ARG( "--debug-port" );
+      SET_ZCPROP( debugger_port_ );
+    }
+#endif /* ZORBA_WITH_DEBUGGER */
+    else if ( IS_LONG_OPT( "--default-collation" ) ) {
+      PARSE_ARG( "--default-collation" );
+      zc_props.default_collation_ = ARG_VAL;
+    }
+    else if ( IS_LONG_OPT( "--disable-http-resolution" ) ) {
+      sctx_opt opt;
+      opt.clark_qname = "{http://zorba.io/options/features}disable";;
+      opt.value = "http-uri-resolution";
+      zc_props.sctx_opts_.push_back( opt );
+    }
+    else if ( IS_LONG_OPT( "--dump-lib" ) )
+      z_props.setDumpLib( true );
+
+    ////////// e //////////////////////////////////////////////////////////////
+
+    else if ( IS_LONG_OPT( "--execute-plan" ) )
+      zc_props.load_plan_ = true;
+    else if ( IS_OPT( "--external-variable", "-e" ) ) {
+      PARSE_ARG( "--external-variable" );
+      string key, value;
+      if ( !split_key_value( ARG_VAL, "=", &key, &value ) ) {
+        error = "--external-variable argument must be of the form name=file or name:=value\n";
+        break;
+      }
+      external_var ev;
+      ev.var_value = value;
+
+      if ( key[0] == ':' ) {
+        error = "--external-variable argument must be of the form name=file or name:=value\n";
+        break;
+      }
+      if ( key[ key.size() - 1 ] == ':' )
+        key.erase( key.size() - 1 );
+      else
+        ev.inline_file = true;
+      ev.var_name = key;
+
+      zc_props.external_vars_.push_back( ev );
+    }
+
+    ////////// f //////////////////////////////////////////////////////////////
+
+    else if ( IS_LONG_OPT( "--force-gflwor" ) )
+      z_props.setForceGFLWOR( true );
+
+    ////////// h //////////////////////////////////////////////////////////////
+
+    else if ( IS_OPT( "--help", "-h" ) ) {
+      cout << "Zorba NoSQL Query Processor, Version: "
+           << Zorba::version() << '\n'
+           << "Available options:\n\n"
+           << get_help_msg();
+      exit( 0 );
+    }
+
+    ////////// i //////////////////////////////////////////////////////////////
+
+    else if ( IS_OPT( "--indent", "-i" ) )
+      zc_props.indent_ = true;
+    else if ( IS_LONG_OPT( "--infer-joins" ) ) {
+      PARSE_ARG( "--infer-joins" );
+      z_props.setInferJoins( bool_of( ARG_VAL ) );
+    }
+    else if ( IS_LONG_OPT( "--inline-udf" ) ) {
+      PARSE_ARG( "--inline-udf" );
+      z_props.setInlineUDF( bool_of( ARG_VAL ) );
+    }
+
+    ////////// j //////////////////////////////////////////////////////////////
+
+    else if ( IS_OPT( "--jsoniq", "-j" ) )
+      zc_props.jsoniq_ = true;
+
+    ////////// l //////////////////////////////////////////////////////////////
+
+    else if ( IS_OPT( "--lib-module", "-l" ) )
+      zc_props.lib_module_ = true;
+    else if ( IS_LONG_OPT( "--lib-path" ) ) {
+      PARSE_ARG( "--lib-path" );
+      zc_props.lib_path_ = ARG_VAL;
+    }
+    else if ( IS_LONG_OPT( "--loop-hoisting" ) ) {
+      PARSE_ARG( "--loop-hoisting" );
+      z_props.setLoopHoisting( bool_of( ARG_VAL ) );
+    }
+
+    ////////// m //////////////////////////////////////////////////////////////
+
+    else if ( IS_LONG_OPT( "--max-udf-call-depth" ) ) {
+      PARSE_ARG( "--max-udf-call-depth" );
+      SET_ZPROP( MaxUDFCallDepth );
+    }
+    else if ( IS_LONG_OPT( "--module-path" ) ) {
+      PARSE_ARG( "--module-path" );
+      zc_props.module_path_ = ARG_VAL;
+    }
+    else if ( IS_OPT( "--multiple", "-m" ) ) {
+      PARSE_ARG( "--multiple" );
+      SET_ZCPROP( multiple_ );
+    }
+
+    ////////// n //////////////////////////////////////////////////////////////
+
+    else if ( IS_LONG_OPT( "--no-copy-optim" ) ) {
+      PARSE_ARG( "--no-copy-optim" );
+      z_props.setNoCopyOptim( bool_of( ARG_VAL ) );
+    }
+    else if ( IS_LONG_OPT( "--no-logo" ) )
+      zc_props.no_logo_ = true;
+    else if ( IS_LONG_OPT( "--no-serializer" ) )
+      zc_props.no_serializer_ = true;
+    else if ( IS_LONG_OPT( "--no-tree-ids" ) )
+      z_props.setNoTreeIDs( true );
+
+    ////////// o //////////////////////////////////////////////////////////////
+
+    else if ( IS_OPT( "--omit-xml-declaration", "-r" ) )
+      zc_props.omit_xml_declaration_ = true;
+    else if ( IS_OPT( "--optimization-level", "-O" ) ) {
+      PARSE_ARG( "--optimization-level" );
+      unsigned opt_level;
+      atoi( ARG_VAL, &opt_level );
+      if ( opt_level > 2 ) {
+        error = "Only 0, 1 and 2 are allowed as values for --optimization-level";
+        break;
+      }
+      z_props.setOptimizationLevel( opt_level );
+    }
+    else if ( IS_LONG_OPT( "--option" ) ) {
+      PARSE_ARG( "--option" );
+      string key, value;
+      if ( !split_key_value( ARG_VAL, "=", &key, &value ) ) {
+        error = "--option argument must be of the form {namespace}localname=value\n";
+        break;
+      }
+      // TODO: check key is of the form {ns}local
+      sctx_opt opt;
+      opt.clark_qname = key;
+      opt.value = value;
+      zc_props.sctx_opts_.push_back( opt );
+    }
+    else if ( IS_LONG_OPT( "--ordering-mode" ) ) {
+      PARSE_ARG( "--ordering-mode" );
+      zc_props.ordering_mode_ = ARG_VAL;
+    }
+#ifdef ZORBA_WITH_FILE_ACCESS
+    else if ( IS_OPT( "--output-file", "-o" ) ) {
+      PARSE_ARG( "--output-file" );
+      zc_props.output_file_ = ARG_VAL;
+    }
+#endif /* ZORBA_WITH_FILE_ACCESS */
+
+    ////////// p //////////////////////////////////////////////////////////////
+
+    else if ( IS_LONG_OPT( "--parse-only" ) )
+      zc_props.parse_only_ = true;
+    else if ( IS_OPT( "--print-ast", "-a" ) )
+      z_props.setPrintAST( true );
+    else if ( IS_OPT( "--print-errors-as-xml", "-x" ) )
+      zc_props.print_errors_as_xml_ = true;
+    else if ( IS_LONG_OPT( "--print-intermediate-opt" ) )
+      z_props.setPrintIntermediateOpt( true );
+    else if ( IS_LONG_OPT( "--print-item-flow" ) )
+      z_props.setPrintItemFlow( true );
+    else if ( IS_LONG_OPT( "--print-iterator-tree" ) )
+      z_props.setPrintIteratorTree( true );
+    else if ( IS_LONG_OPT( "--print-locations" ) )
+      z_props.setPrintLocations( true );
+    else if ( IS_OPT( "--print-optimized", "-P" ) )
+      z_props.setPrintOptimized( true );
+    else if ( IS_LONG_OPT( "--print-query" ) )
+      zc_props.print_query_ = true;
+    else if ( IS_LONG_OPT( "--print-static-types" ) )
+      z_props.setPrintStaticTypes( true );
+    else if ( IS_LONG_OPT( "--print-translated" ) )
+      z_props.setPrintTranslated( true );
+
+    ////////// q //////////////////////////////////////////////////////////////
+
+    else if ( IS_OPT( "--query", "-q" ) ) {
+      if ( !got_as_files )
+        zc_props.as_files_ = false;
+      if ( *(argv+1) && !strncmp( *(argv+1), "-f", 2 ) )
+        break; // is it "-q -f <filename>" perhaps?
+      PARSE_ARG( "--query" );
+      zc_props.queries_or_files_.push_back( ARG_VAL );
+    }
+
+    ////////// s //////////////////////////////////////////////////////////////
+
+    else if ( IS_OPT( "--serialization-parameter", "-z" ) ) {
+      PARSE_ARG( "--serialization-parameter" );
+      string key, value;
+      serialization_param sp;
+      if ( split_key_value( ARG_VAL, "=", &key, &value ) ) {
+        sp.first = key;
+        sp.second = value;
+      } else
+        sp.first = ARG_VAL;
+      zc_props.serialization_params_.push_back( sp );
+    }
+    else if ( IS_LONG_OPT( "--serialize-html" ) )
+      zc_props.serialize_html_ = true;
+    else if ( IS_LONG_OPT( "--serialize-only-query" ) ) {
+      PARSE_ARG( "--serialize-only-query" );
+      zc_props.serialize_only_query_ = bool_of( ARG_VAL );
+    }
+    else if ( IS_OPT( "--serialize-plan", "-s" ) )
+      zc_props.serialize_plan_ = true;
+    else if ( IS_LONG_OPT( "--serialize-text" ) )
+      zc_props.serialize_text_ = true;
+    else if ( IS_LONG_OPT( "--stable-iterator-ids" ) )
+      z_props.setStableIteratorIDs( true );
+#ifndef ZORBA_NO_FULL_TEXT
+    else if ( IS_LONG_OPT( "--stop-words" ) ) {
+      PARSE_ARG( "--stop-words" );
+      string uri, value;
+      if ( !split_key_value( ARG_VAL, ":=", &uri, &value ) ) {
+        error = "--stop-words argument must be of the form URI:=value\n";
+        break;
+      }
+      ft_mapping ft;
+      ft.uri = uri;
+      ft.value = value;
+      zc_props.stop_words_mapping_.push_back( ft );
+    }
+
+    ////////// t //////////////////////////////////////////////////////////////
+
+    else if ( IS_LONG_OPT( "--thesaurus" ) ) {
+      PARSE_ARG( "--thesaurus" );
+      string uri, value;
+      if ( !split_key_value( ARG_VAL, ":=", &uri, &value ) ) {
+        error = "--thesaurus argument must be of the form URI:=value\n";
+        break;
+      }
+      if ( uri == "default" )
+        uri = "##default";
+      ft_mapping ft;
+      ft.uri = uri;
+      ft.value = value;
+      zc_props.thesaurus_mapping_.push_back( ft );
+    }
+#endif /* ZORBA_NO_FULL_TEXT */
+    else if ( IS_OPT( "--timing", "-t" ) )
+      zc_props.timing_ = true;
+    else if ( IS_LONG_OPT( "--timeout" ) ) {
+      PARSE_ARG( "--timeout" );
+      SET_ZCPROP( timeout_ );
+    }
+    else if ( IS_LONG_OPT( "--trace-parsing" ) )
+      z_props.setTraceParsing( true );
+    else if ( IS_LONG_OPT( "--trace-scanning" ) )
+      z_props.setTraceScanning( true );
+#ifndef NDEBUG
+    else if ( IS_LONG_OPT( "--trace-codegen" ) )
+      z_props.setTraceCodegen( true );
+    else if ( IS_LONG_OPT( "--trace-fulltext" ) )
+      z_props.setTraceFulltext( true );
+    else if ( IS_LONG_OPT( "--trace-translator" ) )
+      z_props.setTraceTranslator( true );
+#endif /* NDEBUG */
+    else if ( IS_LONG_OPT( "--trailing-nl" ) )
+      zc_props.trailing_nl_ = true;
+
+    ////////// u //////////////////////////////////////////////////////////////
+
+    else if ( IS_LONG_OPT( "--uri-path" ) ) {
+      PARSE_ARG( "--uri-path" );
+      zc_props.uri_path_ = ARG_VAL;
+    }
+    else if ( IS_LONG_OPT( "--use-indexes" ) ) {
+      PARSE_ARG( "--use-indexes" );
+      z_props.setUseIndexes( true );
+    }
+
+    ////////// v //////////////////////////////////////////////////////////////
+
+    else if ( IS_OPT( "--version", "-v" ) ) {
+      cout << "Zorba NoSQL Query Processor, Version: "
+           << zorba::Zorba::version() << endl;
+      exit( 1 ); // should be 0, but the old code returned 1
+    }
+
+    ////////// END ////////////////////////////////////////////////////////////
+
+    else if ( IS_LONG_OPT( "--" ) )
+      break;
+    else if ( (*argv)[0] == '-' ) {
+      cerr << "unknown command line option " << *argv << endl;
+      exit( 1 );
+    } else {
+      zc_props.queries_or_files_.push_back( *argv );
+    }
+  } // for
+
+  if ( !error )
+    error = check_args();
+  if ( error ) {
+    cout << "Error: " << error << "\nUse -h for help." << endl;
+    exit( 1 );
+  }
+  return argv - argv_orig;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+/* vim:set et sw=2 ts=2: */

=== renamed file 'bin/zorbacmdproperties.cpp' => 'bin/zorbacmd_props.cpp'
--- bin/zorbacmdproperties.cpp	2013-06-16 00:37:21 +0000
+++ bin/zorbacmd_props.cpp	2014-02-10 00:46:59 +0000
@@ -13,202 +13,46 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#include "zorbacmdproperties.h"
-
-#include <fstream>
-#include <iostream>
-#include <cstdlib>
-
-#include <zorba/zorba.h>
-
-std::string ZorbaCMDProperties::check_args () {
-
-  if(queriesOrFilesBegin() == queriesOrFilesEnd())
-  {
-    return "No queries submitted \nUsage: zorba -q '1 + 1' execute an inline query \n zorba file.xq execute a query from a file \n Use -h for help.";
-  }
-
-  if(unknownOption())
-  {
-    return "Extra arguments found on command line. Use -h for help.";
-  }
-
-  if(queriesOrFilesBegin() == queriesOrFilesEnd())
-  {
-    return "No queries submitted \nUsage: zorba -q '1 + 1' execute an inline query \n zorba file.xq execute a query from a file \n Use -h for help.";
-  }
-
-  if ( theBoundarySpace.size() != 0 )
-  {
-    if ( ! (theBoundarySpace.compare("strip") == 0 || theBoundarySpace.compare("preserve") == 0 ))
-      return "Only strip and preserve are allowed as values for the option boundary-space";
-  }
-
-  if ( theConstructionMode.size() != 0 )
-  {
-    if ( ! (theConstructionMode.compare("strip") == 0 || theConstructionMode.compare("preserve") == 0 ))
-      return "Only strip and preserve are allowed as values for the option construction-mode";
-  }
-
-  if ( theOrderingMode.size() != 0 ) {
-    if ( ! (theOrderingMode.compare("ordered") == 0 || theOrderingMode.compare("unordered") == 0 ))
-      return "Only ordered and unordered are allowed as values for the option ordering-mode";
-  }
-
-  if ( ! (theOptimizationLevel.compare("O0") == 0 || theOptimizationLevel.compare("O1") == 0
-    || theOptimizationLevel.compare("O2") == 0 ) )
-    return "only O0, O1 and O2 are allowed as values for the option opt-level";
-
-  for (std::vector<std::string>::const_iterator lIter = theExternalVariable.begin();
-       lIter != theExternalVariable.end(); ++lIter) 
-  {
-    std::string lStr = *lIter;
-    std::string::size_type lPos = lStr.find_first_of("=");
-    std::string lVarName = lStr.substr(0, lPos);
-    std::string lValue = lStr.substr(lPos + 1);
-    bool lInlineFile = true;
-    if (lVarName.at(lVarName.size()-1) == ':')
-    {
-      lInlineFile = false;
-      lVarName.resize(lVarName.size()-1); // remove the :
-    }
-    ExternalVariable lExternalVariable;
-    lExternalVariable.var_name = lVarName;
-    lExternalVariable.var_value = lValue;
-    lExternalVariable.inline_file = lInlineFile;
-    theExternalVars.push_back(lExternalVariable);
-  }
-
-  for (std::vector<std::string>::const_iterator lIter = theOption.begin();
-       lIter != theOption.end(); ++lIter)
-  {
-    size_t lEQual = lIter->find_last_of("=");
-    if (lEQual == std::string::npos)
-      return "option must be of the form {namespace}localname=value";
-
-    std::string lClarkQName = lIter->substr(0, lEQual);
-    std::string lValue      = lIter->substr(lEQual + 1);
-
-    StaticContextOption lOption;
-    lOption.clark_qname = lClarkQName;
-    lOption.value = lValue;
-    theStaticContextOptions.push_back(lOption);
-  }
-
-  for (std::vector<std::string>::const_iterator lIter = theStopWords.begin();
-       lIter != theStopWords.end(); ++lIter)
-  {
-    size_t lEQual = lIter->find(":=");
-    if (lEQual == std::string::npos)
-      return "Stop-words mapping must be of the form URI:=value";
-
-    std::string lURI   = lIter->substr(0, lEQual);
-    std::string lValue = lIter->substr(lEQual + 2);
-
-    FullTextMapping lMapping;
-    lMapping.uri   = lURI;
-    lMapping.value = lValue;
-    theStopWordsMapping.push_back(lMapping);
-  }
-
-  for (std::vector<std::string>::const_iterator lIter = theThesaurus.begin();
-       lIter != theThesaurus.end(); ++lIter)
-  {
-    size_t lEQual = lIter->find(":=");
-    if (lEQual == std::string::npos)
-      return "Thesaurus mapping must be of the form URI:=value";
-
-    std::string lURI   = lIter->substr(0, lEQual);
-    std::string lValue = lIter->substr(lEQual + 2);
-
-    if ( lURI == "default" )
-      lURI = "##default";
-
-    FullTextMapping lMapping;
-    lMapping.uri   = lURI;
-    lMapping.value = lValue;
-    theThesaurusMapping.push_back(lMapping);
-  }
-       
-  return "";
-}
-
-
-bool ZorbaCMDProperties::loadProperties(int argc, char* argv[]) 
-{
-  std::string result = load_argv(argc, (const char **) argv);
-
-  if (result.empty())
-    result = check_args();
-
-  if (result == "!HELP") 
-  {
-    std::cout << "Zorba NoSQL Query Processor, Version: " 
-              << zorba::Zorba::version() << std::endl;
-    std::cout << "Available options:\n\n";
-    std::cout << get_help_msg ();
-    return false;
-  }
-  else if (result == "!VER") 
-  {
-    std::cout << "Zorba NoSQL Query Processor, Version: " 
-              << zorba::Zorba::version() << std::endl;
-    return false;
-  }
-  else if (result.empty ())
-  {
-    return true;
-  }
-  else if (result [0] != '!')
-  {
-    std::cout << "Error: " << result << std::endl;
-    return false;
-  }
-  else
-  {
-    return false;
-  }  
-}
-
-
-void ZorbaCMDProperties::getModulePath(std::string& aPath) const
-{
-  aPath = theModulePath;
-}
-
-void ZorbaCMDProperties::getURIPath(std::string& aPath) const
-{
-  aPath = theUriPath;
-}
-
-void ZorbaCMDProperties::getLibPath(std::string& aPath) const
-{
-  aPath = theLibPath;
-}
-
-void ZorbaCMDProperties::getJVMClassPath(std::string& aPath) const
-{
-  aPath = theClasspath;
-}
-
-std::vector<std::pair<std::string,std::string> > ZorbaCMDProperties::getSerializerParameters() const
-{
-  std::vector<std::pair<std::string,std::string> > lResult;
-  std::vector<std::string>::const_iterator lEnd = theSerializationParameter.end();
-  for (
-       std::vector<std::string>::const_iterator lIter = theSerializationParameter.begin();
-       lIter != lEnd;
-       ++lIter
-      ) 
-  {
-    std::string lStr = *lIter;
-    std::string::size_type lPos = lStr.find_first_of("=");
-    std::string lVarName = lStr.substr(0, lPos);
-    std::string lValue;
-    if (lPos != std::string::npos)
-        lValue = lStr.substr(lPos + 1);
-
-    lResult.push_back(std::pair<std::string,std::string>(lVarName, lValue));
-  }
-  return lResult;
-}
+
+// local
+#include "zorbacmd_props.h"
+
+///////////////////////////////////////////////////////////////////////////////
+
+ZorbaCmdProperties::ZorbaCmdProperties() {
+  as_files_ = true;
+  byte_order_mark_ = false;
+  compile_only_ = false;
+  debug_ = false;
+  debug_host_ = "127.0.0.1";
+  debug_port_ = 28028;
+  indent_ = false;
+  jsoniq_ = false;
+  lib_module_ = false;
+  load_plan_ = false;
+  multiple_ = 1;
+  no_logo_ = false;
+  no_serializer_ = false;
+  omit_xml_declaration_ = false;
+  optimization_level_ = 1;
+  parse_only_ = false;
+  print_errors_as_xml_ = false;
+  print_query_ = false;
+  save_plan_ = false;
+  serialize_html_ = false;
+  serialize_only_query_ = false;
+  serialize_plan_ = false;
+  serialize_text_ = false;
+  timeout_ = -1;
+  timing_ = false;
+  trailing_nl_ = false;
+}
+
+ZorbaCmdProperties& ZorbaCmdProperties::instance() {
+  static ZorbaCmdProperties instance;
+  return instance;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+/* vim:set et sw=2 ts=2: */

=== renamed file 'bin/zorbacmdproperties.h' => 'bin/zorbacmd_props.h'
--- bin/zorbacmdproperties.h	2014-01-31 23:27:47 +0000
+++ bin/zorbacmd_props.h	2014-02-10 00:46:59 +0000
@@ -1,10 +1,10 @@
 /*
- * Copyright 2006-2008 The FLWOR Foundation.
+ * Copyright 2006-2014 The FLWOR Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
@@ -13,114 +13,106 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 #ifndef ZORBA_CMD_PROPERTIES_H
 #define ZORBA_CMD_PROPERTIES_H
 
+// standard
+#include <string>
+#include <vector>
+#include <utility>                      /* for pair */
+
+// Zorba
 #include <zorba/config.h>
-#include <zorba/item.h>
-
-#include "zorbacmdproperties_base.h"
-
-class ZorbaCMDProperties : public zorbacmd::ZorbaCMDPropertiesBase 
-{
-public:
-  struct ExternalVariable
-  {
-    std::string var_name;
-    std::string var_value;
-    bool        inline_file;
-  };
-
-  typedef std::vector<ExternalVariable> ExternalVars_t;
-
-
-  struct StaticContextOption
-  {
-    std::string clark_qname;
-    std::string value;
-  };
-
-  typedef std::vector<StaticContextOption> Options_t;
-
-  struct FullTextMapping
-  {
-    std::string uri;
-    std::string value;
-  };
-
-  typedef std::vector<FullTextMapping> FullText_t;
-
-  typedef std::vector<std::string>      QueriesOrFiles_t;
-
-protected:
-  ExternalVars_t theExternalVars;
-  Options_t      theStaticContextOptions;
-  FullText_t     theStopWordsMapping;
-  FullText_t     theThesaurusMapping;
-
-public:
-  ExternalVars_t::const_iterator
-  externalVarsBegin() const  { return theExternalVars.begin(); }
-
-  ExternalVars_t::const_iterator
-  externalVarsEnd() const    { return theExternalVars.end(); }
-
-  Options_t::const_iterator
-  optionsBegin() const  { return theStaticContextOptions.begin(); }
-
-  Options_t::const_iterator
-  optionsEnd() const    { return theStaticContextOptions.end(); }
-
-  FullText_t::const_iterator
-  stopWordsBegin() const  { return theStopWordsMapping.begin(); }
-
-  FullText_t::const_iterator
-  stopWordsEnd() const    { return theStopWordsMapping.end(); }
-
-  FullText_t::const_iterator
-  thesaurusBegin() const  { return theThesaurusMapping.begin(); }
-
-  FullText_t::const_iterator
-  thesaurusEnd() const    { return theThesaurusMapping.end(); }
-
-  QueriesOrFiles_t::const_iterator
-  queriesOrFilesBegin() const { return theQueriesOrFiles.begin(); }
-
-  QueriesOrFiles_t::const_iterator
-  queriesOrFilesEnd() const   { return theQueriesOrFiles.end(); }
-  
-  std::vector<std::pair<std::string,std::string> > 
-  getSerializerParameters() const;
-
-  void
-  getModulePath(std::string&) const;
-  
-  void
-  getURIPath(std::string&) const;
-
-  void
-  getLibPath(std::string&) const;
-
-  void
-  getJVMClassPath(std::string&) const;
-
-  bool isDebug(){ return theDebug; }
-
-  bool hasNoLogo(){ return theNoLogo; }
-
-  std::string getDebugHost(){ return theDebugHost; }
-
-  unsigned int getDebugPort(){ return theDebugPort; }
-
-  std::string check_args ();
-
-  void printHelp(std::ostream& os) const {
-    os << "Zorba NoSQL Query Processor\n";
-    os << "Available options:\n";
-    os << get_help_msg ();
-  }
-
-  bool loadProperties(int argc, char* argv[]);
-};
+
+///////////////////////////////////////////////////////////////////////////////
+
+struct external_var {
+  std::string var_name;
+  std::string var_value;
+  bool        inline_file;
+
+  external_var() : inline_file( false ) { }
+};
+
+typedef std::vector<external_var> external_vars;
+
+typedef std::pair<std::string,std::string> serialization_param;
+typedef std::vector<serialization_param> serialization_params;
+
+struct sctx_opt {
+  std::string clark_qname;
+  std::string value;
+};
+
+typedef std::vector<sctx_opt> sctx_opts;
+
+#ifndef ZORBA_NO_FULL_TEXT
+struct ft_mapping {
+  std::string uri;
+  std::string value;
+};
+
+typedef std::vector<ft_mapping> ft_mappings;
+#endif /* ZORBA_NO_FULL_TEXT */
+
+struct ZorbaCmdProperties {
+  static ZorbaCmdProperties& instance();
+
+  bool          as_files_;
+  std::string   base_uri_;
+  std::string   boundary_space_;
+  bool          byte_order_mark_;
+  std::string   classpath_;
+  bool          compile_only_;
+  std::string   construction_mode_;
+  std::string   ctx_item_;
+  bool          debug_;
+  std::string   debug_host_;
+  unsigned      debug_port_;
+  std::string   default_collation_;
+  external_vars external_vars_;
+  bool          indent_;
+  bool          jsoniq_;
+  bool          lib_module_;
+  std::string   lib_path_;
+  bool          load_plan_;
+  std::string   module_path_;
+  unsigned long multiple_;
+  bool          no_logo_;
+  bool          no_serializer_;
+  bool          omit_xml_declaration_;
+  unsigned      optimization_level_;
+  std::string   ordering_mode_;
+#ifdef ZORBA_WITH_FILE_ACCESS
+  std::string   output_file_;
+#endif /* ZORBA_WITH_FILE_ACCESS */
+  bool          parse_only_;
+  bool          print_errors_as_xml_;
+  bool          print_query_;
+  bool          save_plan_;
+  sctx_opts     sctx_opts_;
+  bool          serialize_html_;
+  bool          serialize_only_query_;
+  bool          serialize_plan_;
+  bool          serialize_text_;
+#ifndef ZORBA_NO_FULL_TEXT
+  ft_mappings   stop_words_mapping_;
+  ft_mappings   thesaurus_mapping_;
+#endif /* ZORBA_NO_FULL_TEXT */
+  long          timeout_;               // unused
+  bool          timing_;
+  bool          trailing_nl_;
+  std::string   uri_path_;
+
+  serialization_params      serialization_params_;
+  std::vector<std::string>  queries_or_files_;
+
+private:
+  ZorbaCmdProperties();
+};
+
+///////////////////////////////////////////////////////////////////////////////
+
 #endif /* ZORBA_CMD_PROPERTIES_H */
 /* vim:set et sw=2 ts=2: */

=== removed file 'bin/zorbacmdproperties.txt'
--- bin/zorbacmdproperties.txt	2014-01-31 23:27:47 +0000
+++ bin/zorbacmdproperties.txt	1970-01-01 00:00:00 +0000
@@ -1,40 +0,0 @@
-("as-files,f", "Treat all -q arguments as file paths instead of URIs or inline queries.")
-("base-uri", po::value<std::string>(), "Set the base URI property of the static context.")
-("boundary-space", po::value<std::string>(), "Set the boundary-space policy ('strip' or 'preserve') in the static context.")
-("byte-order-mark", "Set the byte-order-mark for the serializer.")
-("classpath", po::value<std::string>(), "JVM classpath to be used by modules using Java implementations")
-("compile-only", "Only compile (don't execute)")
-("compile-plan,c", "Output the query plan as binary.")
-("construction-mode", po::value<std::string>(), "Set the construction mode ('strip' or 'preserve') in the static context.")
-("context-item", po::value<std::string> (), "Set the context item to the XML document in a given file.")
-("debug,d", "Launch the Zorba debugger server and connect to a DBGP-enabled debugger client.")
-("debug-host,h", po::value<std::string>()->default_value("127.0.0.1"), "The host where the DBGP-enabled debugger client listens for connections. Defaults to: 127.0.0.1")
-("debug-port,p", po::value<unsigned int>()->default_value (28028), "The port on which the DBGP-enabled debugger client listens for connections. Defaults to: 28028")
-("default-collation", po::value<std::string>(), "Add the given collation and set the value of the default collation in the static context to the given collation.")
-("execute-plan", "Take a query plan as binary and execute it. Binary query plans can be generated using the --compile-plan option.")
-("external-variable,e", po::value<std::vector<std::string> >(), "Provide the value for a variable given a file (name=file) or a value (name:=value)")
-("indent,i", "Indent output.")
-("lib-module,l", "Query compiler option to treat the query as a library module. If this is set --compile-only option is also set to true.")
-("lib-path", po::value<std::string>(), "Library path (list of directories) where Zorba will look for dynamic libraries (e.g., module external function implementations.")
-("module-path", po::value<std::string>(), "Path (list of directories) to add to both the URI and Library paths.")
-("multiple,m", po::value<unsigned long>()->default_value (1), "Execute the given queries multiple times.")
-("no-logo", "Print no logo when starting.")
-("no-serializer", "Do not serialize (discard) result.")
-("omit-xml-declaration,r", "Omit the XML declaration from the result.")
-("optimization-level", po::value<std::string>()->default_value("O1"), "Optimization level for the query compiler (O0, O1 or O2 - default: O1)")
-("option", po::value<std::vector<std::string> >(), "Set an XQuery option in the static context. The QName of the option is passed as a string in the notation by James Clark (i.e. {namespace}localname). For example, --option {http://zorba.io/}option=value";).
-("ordering-mode", po::value<std::string>(), "Set the ordering mode ('ordered' or 'unordered') in the static context.")
-("output-file,o", po::value<std::string>(), "Write the result to the given file.")
-("parse-only", "Stop after parsing the query.")
-("print-errors-as-xml,x", "Print the errors as XML.")
-("print-query", "Print the queries.")
-("query,q", po::value<std::vector<std::string> >(&theQueriesOrFiles), "Query test or file URI (file://...)")
-("serialization-parameter,z", po::value<std::vector<std::string> >(), "Set serialization parameter in the form of a parameter=value pair (see http://www.w3.org/TR/xslt-xquery-serialization/#serparam, e.g.: -z method=xhtml -z doctype-system=DTD/xhtml1-strict.dtd -z indent=yes).")
-("serialize-html", "Serialize the result as HTML.")
-("serialize-text", "Serialize the result as Text.")
-("stop-words", po::value<std::vector<std::string> >(), "Mapping specifying a stop-words URI to another.")
-("thesaurus", po::value<std::vector<std::string> >(), "Mapping specifying a thesaurus URI to another.")
-("timeout", po::value<long>()->default_value(-1), "Specify a timeout in seconds. After the specified time, the execution of the query will be aborted.")
-("timing,t", "Print timing information. In case of multiple queries the timing information is provided per each query. Both wallclock time and user time (which excludes I/O, network delays and other kernel waits) are shown.")
-("trailing-nl", "Output a trailing newline after the result of the query.")
-("uri-path", po::value<std::string>(), "URI path (list of directories) added to the built-in URI resolver, i.e. where to find modules/schemas to import.")

=== removed file 'bin/zorbacmdproperties_base.cpp'
--- bin/zorbacmdproperties_base.cpp	2014-01-31 23:33:01 +0000
+++ bin/zorbacmdproperties_base.cpp	1970-01-01 00:00:00 +0000
@@ -1,374 +0,0 @@
-/*
- * Copyright 2006-2008 The FLWOR Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "zorbacmdproperties_base.h"
-
-namespace zorbacmd {
-
-///////////////////////////////////////////////////////////////////////////////
-
-ZorbaCMDPropertiesBase::ZorbaCMDPropertiesBase() {
-  theAsFiles = true;
-  theByteOrderMark = false;
-  theCompileOnly = false;
-  theDebug = false;
-  theDebugHost = "127.0.0.1";
-  theDebugPort = 28028;
-  theFparm = false;
-  theIndent = false;
-  theLibModule = false;
-  theLoadPlan = false;
-  theMultiple = 1;
-  theNoLogo = false;
-  theNoSerializer = false;
-  theOmitXmlDeclaration = false;
-  theOptimizationLevel = "O1";
-  theParseOnly = false;
-  thePrintErrorsAsXml = false;
-  thePrintQuery = false;
-  theQBeforeF = false;
-  theSavePlan = false;
-  theSerializeHtml = false;
-  theSerializePlan = false;
-  theSerializeText = false;
-  theTimeout = -1;
-  theTiming = false;
-  theTrailingNl = false;
-  theUnknownOption = false;
-}
-
-char const** ZorbaCMDPropertiesBase::get_all_options() const {
-  static const char* result [] = {
-    "--as-files",
-    "--base-uri",
-    "--boundary-space",
-    "--byte-order-mark",
-    "--classpath",
-    "--compile-only",
-    "--compile-plan",
-    "--construction-mode",
-    "--context-item",
-    "--debug",
-    "--debug-host",
-    "--debug-port",
-    "--default-collation",
-    "--disable-http-resolution",
-    "--execute-plan",
-    "--external-variable",
-    "--indent",
-    "--lib-module",
-    "--lib-path",
-    "--module-path",
-    "--multiple",
-    "--no-logo",
-    "--no-serializer",
-    "--omit-xml-declaration",
-    "--optimization-level",
-    "--option",
-    "--ordering-mode",
-#ifdef ZORBA_WITH_FILE_ACCESS
-    "--output-file",
-#endif /* ZORBA_WITH_FILE_ACCESS */
-    "--parse-only",
-    "--print-errors-as-xml",
-    "--print-query",
-    "--query",
-    "--serialization-parameter",
-    "--serialize-html",
-    "--serialize-plan",
-    "--serialize-text",
-    "--stop-words",
-    "--thesaurus",
-    "--timeout",
-    "--timing",
-    "--trailing-nl",
-    "--uri-path",
-    NULL
-  };
-  return result;
-}
-
-#define IS_LONG_OPT(OPT)  (strcmp( *argv, (OPT) ) == 0)
-#define IS_SHORT_OPT(OPT) (strncmp( *argv, (OPT), 2 ) == 0)
-#define IS_OPT(LOPT,SOPT) (IS_LONG_OPT(LOPT) || IS_SHORT_OPT(SOPT))
-
-std::string ZorbaCMDPropertiesBase::load_argv(int argc, const char **argv) {
-  if ( !argv )
-    return "";
-
-  std::string result;
-  for ( ++argv; *argv; ++argv ) {
-    if ( IS_OPT( "--help", "-h" ) )
-      return "!HELP";
-    if ( IS_OPT( "--version", "-v" ) )
-      return "!VER";
-
-    if ( IS_OPT( "--as-files", "-f" ) ) {
-      theFparm = true;
-      theAsFiles = true;
-    }
-    else if ( IS_LONG_OPT( "--base-uri" ) ) {
-      int d = 2;
-      if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --base-uri option"; break; }
-      init_val(*argv, theBaseUri, d);
-    }
-    else if ( IS_LONG_OPT( "--boundary-space" ) ) {
-      int d = 2;
-      if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --boundary-space option"; break; }
-      init_val(*argv, theBoundarySpace, d);
-    }
-    else if ( IS_LONG_OPT( "--byte-order-mark" ) ) 
-      theByteOrderMark = true;
-    else if ( IS_LONG_OPT( "--classpath" ) ) {
-      int d = 2;
-      if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --classpath option"; break; }
-      init_val(*argv, theClasspath, d);
-    }
-    else if ( IS_LONG_OPT( "--compile-only" ) ) 
-      theCompileOnly = true;
-    else if ( IS_LONG_OPT( "--compile-plan" ) )
-      theSavePlan = true;
-    else if ( IS_LONG_OPT( "--construction-mode" ) ) {
-      int d = 2;
-      if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --construction-mode option"; break; }
-      init_val(*argv, theConstructionMode, d);
-    }
-    else if ( IS_LONG_OPT( "--context-item" ) ) {
-      int d = 2;
-      if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --context-item option"; break; }
-      init_val(*argv, theContextItem, d);
-    }
-    else if ( IS_OPT( "--debug", "-d" ) ) 
-      theDebug = true;
-    else if ( IS_OPT( "--debug-host", "-h" ) ) {
-      int d = 2;
-      if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --debug-host option"; break; }
-      init_val(*argv, theDebugHost, d);
-    }
-    else if ( IS_OPT( "--debug-port", "-p" ) ) {
-      int d = 2;
-      if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --debug-port option"; break; }
-      init_val(*argv, theDebugPort, d);
-    }
-    else if ( IS_LONG_OPT( "--default-collation" ) ) {
-      int d = 2;
-      if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --default-collation option"; break; }
-      init_val(*argv, theDefaultCollation, d);
-    }
-    else if ( IS_LONG_OPT( "--execute-plan" ) )
-      theLoadPlan = true;
-    else if ( IS_OPT( "--external-variable", "-e" ) ) {
-      int d = 2;
-      if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --external-variable option"; break; }
-      init_val(*argv, theExternalVariable, d);
-    }
-    else if ( IS_OPT( "--indent", "-i" ) ) 
-      theIndent = true;
-    else if ( IS_OPT( "--lib-module", "-l" ) )
-      theLibModule = true;
-    else if ( IS_LONG_OPT( "--lib-path" ) ) {
-      int d = 2;
-      if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --lib-path option"; break; }
-      init_val(*argv, theLibPath, d);
-    }
-    else if ( IS_LONG_OPT( "--module-path" ) ) {
-      int d = 2;
-      if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --module-path option"; break; }
-      init_val(*argv, theModulePath, d);
-    }
-    else if ( IS_LONG_OPT( "--no-logo" ) ) 
-      theNoLogo = true;
-    else if ( IS_LONG_OPT( "--no-serializer" ) ) 
-      theNoSerializer = true;
-    else if ( IS_OPT( "--multiple", "-m" ) ) {
-      int d = 2;
-      if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --multiple option"; break; }
-      init_val(*argv, theMultiple, d);
-    }
-    else if ( IS_OPT( "--omit-xml-declaration", "-r" ) ) 
-      theOmitXmlDeclaration = true;
-    else if ( IS_LONG_OPT( "--optimization-level" ) ) {
-      int d = 2;
-      if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --optimization-level option"; break; }
-      init_val(*argv, theOptimizationLevel, d);
-    }
-    else if ( IS_LONG_OPT( "--option" ) ) {
-      int d = 2;
-      if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --option option"; break; }
-      init_val(*argv, theOption, d);
-    }
-    else if ( IS_LONG_OPT( "--ordering-mode" ) ) {
-      int d = 2;
-      if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --ordering-mode option"; break; }
-      init_val(*argv, theOrderingMode, d);
-    }
-#ifdef ZORBA_WITH_FILE_ACCESS
-    else if ( IS_OPT( "--output-file", "-o" ) ) {
-      int d = 2;
-      if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --output-file option"; break; }
-      init_val(*argv, theOutputFile, d);
-    }
-#endif /* ZORBA_WITH_FILE_ACCESS */
-    else if ( IS_LONG_OPT( "--parse-only" ) ) 
-      theParseOnly = true;
-    else if ( IS_OPT( "--print-errors-as-xml", "-x" ) )
-      thePrintErrorsAsXml = true;
-    else if ( IS_LONG_OPT( "--print-query" ) ) 
-      thePrintQuery = true;
-    else if ( IS_OPT( "--query", "-q" ) ) {
-      int d = 2;
-      if(theFparm == false)
-        theAsFiles = false;
-      if(*(argv+1) && !strncmp(*(argv+1), "-f", 2))
-      {
-        theQBeforeF = true; // is it "-q -f <filename>" perhaps?
-        break;           // stop functionality here
-      }
-      if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --query option"; break; }
-      init_val(*argv, theQueriesOrFiles, d);
-    }
-    else if ( IS_LONG_OPT( "--serialize-html" ) ) 
-      theSerializeHtml = true;
-    else if ( IS_LONG_OPT( "--serialize-text" ) ) 
-      theSerializeText = true;
-    else if ( IS_OPT( "--serialization-parameter", "-z" ) ) {
-      int d = 2;
-      if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --serialization-parameter option"; break; }
-      init_val(*argv, theSerializationParameter, d);
-    }
-    else if ( IS_LONG_OPT( "--stop-words" ) ) {
-      int d = 2;
-      if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --stop-words option"; break; }
-      init_val(*argv, theStopWords, d);
-    }
-    else if ( IS_OPT( "--timing", "-t" ) ) 
-      theTiming = true;
-    else if ( IS_LONG_OPT( "--timeout" ) ) {
-      int d = 2;
-      if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --timeout option"; break; }
-      init_val(*argv, theTimeout, d);
-    }
-    else if ( IS_LONG_OPT( "--trailing-nl" ) ) 
-      theTrailingNl = true;
-    else if ( IS_LONG_OPT( "--uri-path" ) ) {
-      int d = 2;
-      if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --uri-path option"; break; }
-      init_val(*argv, theUriPath, d);
-    }
-    else if ( IS_OPT( "--serialize-plan", "-s" ) )
-      theSerializePlan = true;
-    else if ( IS_LONG_OPT( "--disable-http-resolution" ) ) {
-      init_val("{http://zorba.io/options/features}disable=http-uri-resolution";,
-                theOption, 0);
-    }
-    else if ( IS_LONG_OPT( "--thesaurus" ) ) {
-      int d = 2;
-      if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --thesaurus option"; break; }
-      init_val(*argv, theThesaurus, d);
-    }
-
-    else if ( IS_LONG_OPT( "--" ) ) {
-      copy_args (++argv);
-      break;
-    } else if ( (*argv)[0] == '-' ) {
-      result = "unknown command line option "; result += *argv; 
-      theUnknownOption = true; break; 
-    } else {
-      init_val(*argv, theQueriesOrFiles, 0);
-      copy_args( argv );
-    }
-  } // for
-  return result;
-}
-
-char const* ZorbaCMDPropertiesBase::get_help_msg() const {
-  return
-    "--as-files, -f\nTreat all -q arguments as file paths instead of URIs or inline queries. This option is deprecated and will be defaulted to true in the future, so any entry in the command line is going to be treated as files.\n\n"
-    "--base-uri\nSet the base URI property of the static context.\n\n"
-    "--boundary-space\nSet the boundary-space policy ('strip' or 'preserve') in the static context.\n\n"
-    "--byte-order-mark\nSet the byte-order-mark for the serializer.\n\n"
-    "--classpath\nJVM classpath to be used by modules using Java implementations\n\n"
-    "--compile-only\nOnly compile (don't execute)\n\n"
-    "--compile-plan,\nDo not execute the query; just compile it and save the execution plan in the file specified with the -o option.\n\n"
-    "--construction-mode\nSet the construction mode ('strip' or 'preserve') in the static context.\n\n"
-    "--context-item\nSet the context item to the XML document in a given file.\n\n"
-    "--debug, -d\nLaunch the Zorba debugger server and connect to a DBGP-enabled debugger client.\n\n"
-    "--debug-host, -h\nThe host where the DBGP-enabled debugger client listens for connections. Defaults to: 127.0.0.1\n\n"
-    "--debug-port, -p\nThe port on which the DBGP-enabled debugger client listens for connections. Defaults to: 28028\n\n"
-    "--default-collation\nAdd the given collation and set the value of the default collation in the static context to the given collation.\n\n"
-    "--disable-http-resolution\nDo not use HTTP to resolve URIs\n\n"
-    "--execute-plan\nDo not compile the query; instead load the execution plan from the file specified by the -f -q options (or by any file specified without any other argument), and execute the loaded plan.\n\n"
-    "--external-variable, -e\nProvide the value for a variable given a file (name=file) or a value (name:=value)\n\n"
-    "--indent, -i\nIndent output.\n\n"
-    "--lib-module, -l\nQuery compiler option to treat the query as a library module. If this is set --compile-only option is also set to true.\n\n"
-    "--lib-path\nLibrary path (list of directories) where Zorba will look for dynamic libraries (e.g., module external function implementations.\n\n"
-    "--module-path\nPath (list of directories) to add to both the URI and Library paths.\n\n"
-    "--multiple, -m\nExecute the given queries multiple times.\n\n"
-    "--no-logo\nPrint no logo when starting.\n\n"
-    "--no-serializer\nDo not serialize (discard) result.\n\n"
-    "--omit-xml-declaration, -r\nOmit the XML declaration from the result.\n\n"
-    "--optimization-level\nOptimization level for the query compiler (O0, O1 or O2 - default: O1)\n\n"
-    "--option\nSet an XQuery option in the static context. The QName of the option is passed as a string in the notation by James Clark (i.e. {namespace}localname). For example, --option {http://zorba.io/}option=value\n\n";
-    "--ordering-mode\nSet the ordering mode ('ordered' or 'unordered') in the static context.\n\n"
-    "--output-file, -o\nWrite the result to the given file.\n\n"
-    "--parse-only\nStop after parsing the query.\n\n"
-    "--print-errors-as-xml, -x\nPrint the errors as XML.\n\n"
-    "--print-query\nPrint the queries.\n\n"
-    "--query, -q\nQuery test or file URI (file://...)\n\n"
-    "--serialization-parameter, -z\nSet serialization parameter in the form of a parameter=value pair (see http://www.w3.org/TR/xslt-xquery-serialization/#serparam, e.g.: -z method=xhtml -z doctype-system=DTD/xhtml1-strict.dtd -z indent=yes).\n\n"
-    "--serialize-html\nSerialize the result as HTML.\n\n"
-    "--serialize-plan, -s\nSerialize and then load the query execution plan.\n\n"
-    "--serialize-text\nSerialize the result as Text.\n\n"
-    "--stop-words\nMapping specifying a stop-words URI to another.\n\n"
-    "--thesaurus\nMapping specifying a thesaurus URI to another.\n\n"
-    "--timeout\nSpecify a timeout in seconds. After the specified time, the execution of the query will be aborted.\n\n"
-    "--timing, -t\nPrint timing information. In case of multiple queries the timing information is provided per each query. Both wallclock time and user time (which excludes I/O, network delays and other kernel waits) are shown.\n\n"
-    "--trailing-nl\nOutput a trailing newline after the result of the query.\n\n"
-    "--uri-path\nURI path (list of directories) added to the built-in URI resolver, i.e. where to find modules/schemas to import.\n\n"
-    ;
-}
-
-ZorbaCMDPropertiesBase const* ZorbaCMDPropertiesBase::instance() {
-  static ZorbaCMDPropertiesBase result;
-  return &result;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-} // namespace zorbacmd
-/* vim:set et sw=2 ts=2: */

=== removed file 'bin/zorbacmdproperties_base.h'
--- bin/zorbacmdproperties_base.h	2014-01-31 23:27:47 +0000
+++ bin/zorbacmdproperties_base.h	1970-01-01 00:00:00 +0000
@@ -1,142 +0,0 @@
-/*
- * Copyright 2006-2008 The FLWOR Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <string>
-#include <sstream>
-#include <zorba/config.h>
-#include <zorba/properties_base.h>
-#include <cstring>
-
-#ifndef ZORBACMD_ZORBACMDPROPERTIESBASE
-#define ZORBACMD_ZORBACMDPROPERTIESBASE
-namespace zorbacmd {
-
-///////////////////////////////////////////////////////////////////////////////
-
-class ZorbaCMDPropertiesBase : public ::zorba::PropertiesBase {
-protected:
-  bool theTiming;
-#ifdef ZORBA_WITH_FILE_ACCESS
-  std::string theOutputFile;
-#endif /* ZORBA_WITH_FILE_ACCESS */
-  std::vector<std::string> theSerializationParameter;
-  bool theSerializeHtml;
-  bool theSerializeText;
-  bool theIndent;
-  bool thePrintQuery;
-  bool thePrintErrorsAsXml;
-  bool theByteOrderMark;
-  bool theOmitXmlDeclaration;
-  std::string theBaseUri;
-  std::string theBoundarySpace;
-  std::string theDefaultCollation;
-  std::string theConstructionMode;
-  std::string theOrderingMode;
-  unsigned long theMultiple;
-  std::vector<std::string> theQueriesOrFiles;
-  bool theAsFiles;
-  std::vector<std::string> theExternalVariable;
-  std::string theContextItem;
-  std::string theOptimizationLevel;
-  bool theLibModule;
-  bool theParseOnly;
-  bool theCompileOnly;
-  bool theNoSerializer;
-  bool theDebug;
-  std::string theDebugHost;
-  unsigned int theDebugPort;
-  bool theNoLogo;
-  long theTimeout;
-  std::string theUriPath;
-  std::string theLibPath;
-  std::string theModulePath;
-  std::string theClasspath;
-  std::vector<std::string> theOption;
-  bool theTrailingNl;
-  std::vector<std::string> theStopWords;
-  std::vector<std::string> theThesaurus;
-  bool theSerializePlan;
-  bool theSavePlan;
-  bool theLoadPlan;
-  bool theFparm;
-  bool theQBeforeF;
-  bool theUnknownOption;
-
-  // inherited
-  const char** get_all_options() const;
-
-public:
-  ZorbaCMDPropertiesBase();
-
-  bool timing () const { return theTiming; }
-#ifdef ZORBA_WITH_FILE_ACCESS
-  const std::string &outputFile () const { return theOutputFile; }
-#endif /* ZORBA_WITH_FILE_ACCESS */
-  const std::vector<std::string> &serializationParameter () const { return theSerializationParameter; }
-  bool serializeHtml () const { return theSerializeHtml; }
-  bool serializeText () const { return theSerializeText; }
-  bool indent () const { return theIndent; }
-  bool printQuery () const { return thePrintQuery; }
-  bool printErrorsAsXml () const { return thePrintErrorsAsXml; }
-  bool byteOrderMark () const { return theByteOrderMark; }
-  bool omitXmlDeclaration () const { return theOmitXmlDeclaration; }
-  const std::string &baseUri () const { return theBaseUri; }
-  const std::string &boundarySpace () const { return theBoundarySpace; }
-  const std::string &defaultCollation () const { return theDefaultCollation; }
-  const std::string &constructionMode () const { return theConstructionMode; }
-  const std::string &orderingMode () const { return theOrderingMode; }
-  unsigned long multiple () const { return theMultiple; }
-  const std::vector<std::string> &query () const { return theQueriesOrFiles; }
-  bool asFiles () const { return theAsFiles; }
-  const std::vector<std::string> &externalVariable () const { return theExternalVariable; }
-  const std::string &contextItem () const { return theContextItem; }
-  const std::string &optimizationLevel () const { return theOptimizationLevel; }
-  bool libModule () const { return theLibModule; }
-  bool parseOnly () const { return theParseOnly; }
-  bool compileOnly () const { return theCompileOnly; }
-  bool noSerializer () const { return theNoSerializer; }
-  bool debug () const { return theDebug; }
-  const std::string &debugHost () const { return theDebugHost; }
-  unsigned debugPort () const { return theDebugPort; }
-  bool noLogo () const { return theNoLogo; }
-  const long &timeout () const { return theTimeout; }
-  const std::string &uriPath () const { return theUriPath; }
-  const std::string &libPath () const { return theLibPath; }
-  const std::string &modulePath () const { return theModulePath; }
-  const std::string &classpath () const { return theClasspath; }
-  const std::vector<std::string> &option () const { return theOption; }
-  bool trailingNl () const { return theTrailingNl; }
-  const std::vector<std::string> &stopWords () const { return theStopWords; }
-  const std::vector<std::string> &thesaurus () const { return theThesaurus; }
-  bool serializePlan () const { return theSerializePlan; }
-  bool loadPlan () const { return theLoadPlan; }
-  bool savePlan () const { return theSavePlan; }
-  bool qBeforeF () const { return theQBeforeF; }
-  bool unknownOption() const { return theUnknownOption; }
-
-  std::string load_argv(int argc, const char **argv);
-
-  const char* get_help_msg() const;
-
-  static const ZorbaCMDPropertiesBase* instance();
-};
-
-///////////////////////////////////////////////////////////////////////////////
-
-} // namespace zorbacmd
-
-#endif /* ZORBACMD_ZORBACMDPROPERTIESBASE */
-/* vim:set et sw=2 ts=2: */

=== added file 'include/zorba/properties.h'
--- include/zorba/properties.h	1970-01-01 00:00:00 +0000
+++ include/zorba/properties.h	2014-02-10 00:46:59 +0000
@@ -0,0 +1,400 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef ZORBA_PROPERTIES_BASE_H
+#define ZORBA_PROPERTIES_BASE_H
+
+// standard
+#include <iostream>
+#include <sstream>
+#include <string>
+#include <vector>
+
+// Zorba
+#include <zorba/config.h>
+#include <zorba/internal/ztd.h>
+#include <zorba/internal/type_traits.h>
+#include <zorba/internal/unique_ptr.h>
+
+namespace zorba {
+
+///////////////////////////////////////////////////////////////////////////////
+
+/**
+ * \brief This class provides access to global properties.
+ *
+ * This class provides access to global properties set for Zorba in environment
+ * and configuration file.
+ */
+class ZORBA_DLL_PUBLIC Properties {
+public:
+  /**
+   * Gets the singleton instance.
+   *
+   * @return Returns said instance.
+   */
+  static Properties& instance();
+
+#ifndef NDEBUG
+  /**
+   * Gets whether abort(3) will be called when a ZorbaException is thrown.
+   * (This is a developer debugging aid.)
+   */
+  bool getAbort() const {
+    return abort_;
+  }
+
+  /**
+   * Sets whether abort(3) will be called when a ZorbaException is thrown.
+   * (This is a developer debugging aid.)
+   *
+   * @param abort If \c true, call abort(3) when a ZorbaException is thrown.
+   */
+  void setAbort( bool abort ) {
+    abort_ = abort;
+  }
+#endif /* NDEBUG */
+
+  /**
+   * Gets the stream used for additional developer debugging output.
+   * (This has nothing to do with the Zorba debugger.)
+   *
+   * @return Returns said stream; default: standard output.
+   */
+  std::ostream& getDebugStream() const {
+    return *debug_stream_.get();
+  }
+
+  /**
+   * Sets the file to use for additional developer debugging output.
+   * (This has nothing to do with the Zorba debugger.)
+   *
+   * @param file The path to the file to use.
+   */
+  void setDebugFile( char const *file );
+
+  /**
+   * Sets the file to use for additional developer debugging output.
+   * (This has nothing to do with the Zorba debugger.)
+   *
+   * @tparam StringType The string type.
+   * @param file The path to the file to use.
+   */
+  template<class StringType>
+  typename std::enable_if<ZORBA_HAS_C_STR(StringType),void>::type
+  setDebugFile( StringType const &file ) {
+    setDebugFile( file.c_str() );
+  }
+
+  /**
+   * Sets the stream to use for additional developer debugging output.
+   * (This has nothing to do with the Zorba debugger.)
+   *
+   * @param stream The stream to use.
+   * @param take_ownership If \c true, \a stream will be deleted when Zorba
+   * shuts down.
+   */
+  void setDebugStream( std::ostream &os, bool take_ownership = false );
+
+  bool getDumpLib() const {
+    return dump_lib_;
+  }
+
+  void setDumpLib( bool b ) {
+    dump_lib_ = b;
+  }
+
+  bool getForceGFLWOR() const {
+    return force_gflwor_;
+  }
+
+  void setForceGFLWOR( bool b ) {
+    force_gflwor_ = b;
+  }
+
+  bool getInferJoins() const {
+    return infer_joins_;
+  }
+
+  void setInferJoins( bool b ) {
+    infer_joins_ = b;
+  }
+
+  bool getInlineUDF() const {
+    return inline_udf_;
+  }
+
+  void setInlineUDF( bool b ) {
+    inline_udf_ = b;
+  }
+
+  std::string const& getClassPath() const {
+    return classpath_;
+  }
+
+  void setClassPath( char const *classpath ) {
+    classpath_ = classpath;
+  }
+
+  template<class StringType>
+  typename std::enable_if<ZORBA_HAS_C_STR(StringType),void>::type
+  setClassPath( StringType const &classpath ) {
+    setClassPath( classpath.c_str() );
+  }
+
+  /**
+   * \brief Get global JVM classpath property.
+   *
+   * Before the JVM is started this will return the classpath set by
+   * command line option, the CLASSPATH environment variable and in Zorba
+   * config file.
+   *
+   * After the JVM is started this will contain in addition the paths to jars
+   * used by modules that make use of the JVM.
+   *
+   * @deprecated Use getClassPath().
+   */
+  void getJVMClassPath( std::string &jvmClasspath ) const {
+    jvmClasspath = getClassPath();
+  }
+
+  /**
+   * \brief Set global JVM classpath property.
+   *
+   * This method should be used to set additional JVM classpath for modules
+   * that make use of JVM. This will overide the classpath set by CLASSPATH
+   * environment variable or Zorba config file.
+   *
+   * Once the JVM is started this method doesn't have any effect.
+   *
+   * @deprecated Use setClassPath().
+   */
+  void setJVMClassPath( std::string const &jvmClasspath ) {
+    setClassPath( jvmClasspath );
+  }
+
+  bool getLoopHoisting() const {
+    return loop_hoisting_;
+  }
+
+  void setLoopHoisting( bool b ) {
+    loop_hoisting_ = b;
+  }
+
+  uint32_t getMaxUDFCallDepth() const {
+    return max_udf_call_depth_;
+  }
+
+  void setMaxUDFCallDepth( uint32_t u ) {
+    max_udf_call_depth_ = u;
+  }
+
+  bool getNoCopyOptim() const {
+    return no_copy_optim_;
+  }
+
+  void setNoCopyOptim( bool b ) {
+    no_copy_optim_ = b;
+  }
+
+  bool getNoTreeIDs() const {
+    return no_tree_ids_;
+  }
+
+  void setNoTreeIDs( bool b ) {
+    no_tree_ids_ = b;
+  }
+
+  unsigned getOptimizationLevel() const {
+    return optimization_level_;
+  }
+
+  void setOptimizationLevel( unsigned optimization_level );
+
+  bool getPrintAST() const {
+    return print_ast_;
+  }
+
+  void setPrintAST( bool b ) {
+    print_ast_ = b;
+  }
+
+  bool getPrintIntermediateOpt() const {
+    return print_intermediate_opt_;
+  }
+
+  void setPrintIntermediateOpt( bool b ) {
+    print_intermediate_opt_ = b;
+  }
+
+  bool getPrintItemFlow() const {
+    return print_item_flow_;
+  }
+
+  void setPrintItemFlow( bool b ) {
+    print_item_flow_ = b ;
+  }
+
+  bool getPrintIteratorTree() const {
+    return print_iterator_locations_;
+  }
+
+  void setPrintIteratorTree( bool b ) {
+    print_iterator_locations_ = b;
+  }
+
+  bool getPrintLocations() const {
+    return print_locations_;
+  }
+
+  void setPrintLocations( bool b ) {
+    print_locations_ = b;
+  }
+
+  bool getPrintOptimized() const {
+    return print_optimized_;
+  }
+
+  void setPrintOptimized( bool b ) {
+    print_optimized_ = b;
+  }
+
+  bool getPrintStaticTypes() const {
+    return print_static_types_;
+  }
+
+  void setPrintStaticTypes( bool b ) {
+    print_static_types_ = b;
+  }
+
+  bool getPrintTranslated() const {
+    return print_translated_;
+  }
+
+  void setPrintTranslated( bool b ) {
+    print_translated_ = b;
+  }
+
+  bool getStableIteratorIDs() const {
+    return stable_iterator_ids_;
+  }
+
+  void setStableIteratorIDs( bool b ) {
+    stable_iterator_ids_ = b;
+  }
+
+  bool getTraceCodegen() const {
+    return trace_codegen_;
+  }
+
+  void setTraceCodegen( bool b ) {
+    trace_codegen_ = b;
+  }
+
+#ifndef ZORBA_NO_FULL_TEXT
+  bool getTraceFulltext() const {
+    return trace_fulltext_;
+  }
+
+  void setTraceFulltext( bool b ) {
+    trace_fulltext_ = b;
+  }
+#endif /* ZORBA_NO_FULL_TEXT */
+
+  bool getTraceParsing() const {
+    return trace_parsing_;
+  }
+
+  void setTraceParsing( bool b ) {
+    trace_parsing_ = b;
+  }
+
+  bool getTraceScanning() const {
+    return trace_scanning_;
+  }
+
+  void setTraceScanning( bool b ) {
+    trace_scanning_ = b;
+  }
+
+  bool getTraceTranslator() const {
+    return trace_translator_;
+  }
+
+  void setTraceTranslator( bool b ) {
+    trace_translator_ = b;
+  }
+
+  bool getUseIndexes() const {
+    return use_indexes_;
+  }
+
+  void setUseIndexes( bool b ) {
+    use_indexes_ = b;
+  }
+
+private:
+  typedef std::unique_ptr<std::ostream> stream_ptr;
+
+  Properties();
+  ~Properties();
+
+#ifndef NDEBUG
+  bool          abort_;
+#endif /* NDEBUG */
+  std::string   classpath_;
+  stream_ptr    debug_stream_;
+  bool          owns_debug_stream_;
+  bool          dump_lib_;
+  bool          force_gflwor_;
+  bool          infer_joins_;
+  bool          inline_udf_;
+  bool          loop_hoisting_;
+  uint32_t      max_udf_call_depth_;
+  bool          no_copy_optim_;
+  bool          no_tree_ids_;
+  unsigned      optimization_level_;
+  bool          print_ast_;
+  bool          print_intermediate_opt_;
+  bool          print_item_flow_;
+  bool          print_iterator_locations_;
+  bool          print_locations_;
+  bool          print_optimized_;
+  bool          print_static_types_;
+  bool          print_translated_;
+  bool          stable_iterator_ids_;
+  bool          trace_codegen_;
+#ifndef ZORBA_NO_FULL_TEXT
+  bool          trace_fulltext_;
+#endif /* ZORBA_NO_FULL_TEXT */
+  bool          trace_parsing_;
+  bool          trace_scanning_;
+  bool          trace_translator_;
+  bool          use_indexes_;
+};
+
+// deprecated name
+typedef Properties ProbertiesGlobal;
+
+///////////////////////////////////////////////////////////////////////////////
+
+} // namespace zorba
+#endif  // ZORBA_PROPERTIES_BASE_H
+/*
+ * Local variables:
+ * mode: c++
+ * End:
+ */
+/* vim:set et sw=2 ts=2: */

=== modified file 'include/zorba/properties_base.h'
--- include/zorba/properties_base.h	2013-02-07 17:24:36 +0000
+++ include/zorba/properties_base.h	2014-02-10 00:46:59 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006-2008 The FLWOR Foundation.
+ * Copyright 2006-2014 The FLWOR Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -13,136 +13,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 #ifndef ZORBA_PROPERTIES_BASE_H
 #define ZORBA_PROPERTIES_BASE_H
 
-#include <string>
-#include <sstream>
-#include <iostream>
-#include <vector>
-#include <cctype>
-#include <zorba/config.h>
-
-namespace zorba {
-
-/***************************************************************************//**
-
-********************************************************************************/
-class ZORBA_DLL_PUBLIC PropertiesBase 
-{
-protected:
-  std::vector<std::string> thePositionalArgs;
-
-public:
-  virtual ~PropertiesBase() {}
-
-  std::string load_all(
-        const char* cfgFilename,
-        const std::string& env_pfx,
-        int argc,
-        const char **argv) 
-  {
-    std::string result;
-
-    if (! (result = load_env(env_pfx)).empty())
-      return result;
-
-    if (! (result = load_file(cfgFilename)).empty())
-      return result;
-
-    return load_argv(argc, argv);
-  }
-
-  std::string load_env(const std::string& env_pfx) 
-  {
-    return load_env(env_pfx, get_all_options()); 
-  }
-
-  std::string load_env(const std::string& env_pfx, const char** options);
-
-  std::string load_file(const char* fname);
-
-  virtual std::string load_argv(int argc, const char **argv) = 0;
-
-  virtual const char** get_all_options() const = 0;
-
-  virtual std::string check_args() { return ""; }
-
-  const std::vector<std::string>& getPositionalArgs() const
-  {
-    return thePositionalArgs;
-  }
-
-  void copy_args (const char** argv) 
-  {
-    for (; *argv != NULL; ++argv) 
-    {
-      thePositionalArgs.push_back(*argv);
-    }
-  }
-
-  template<class T> void init_val(const char* str, T& val, unsigned delta = 0) 
-  {
-    std::istringstream is(str + delta);
-    is >> val;
-  }
-
-};
-
-
-template<> ZORBA_DLL_PUBLIC void PropertiesBase::init_val(
-    const char* str,
-    std::string& val,
-    unsigned delta);
-
-
-template<> ZORBA_DLL_PUBLIC void PropertiesBase::init_val(
-    const char* str,
-    std::vector<std::string>& val,
-    unsigned delta);
-
-/**
- * \brief This class provides access to global properties.
- *
- * This class provides access to global properties set for Zorba in environment
- * and configuration file.
- * It is available using Zorba.getProperties() method.
- * \see { Zorba::getProperties() }
- */
-class ZORBA_DLL_PUBLIC PropertiesGlobal : public PropertiesBase
-{
-public:
-  virtual ~PropertiesGlobal() {}
-
-  /**
-   * \brief Get global JVM classpath property.
-   *
-   * Before the JVM is started this will return the classpath set by
-   * command line option, the CLASSPATH environment variable and in Zorba
-   * config file.
-   *
-   * After the JVM is started this will contain in addition the paths to jars
-   * used by modules that make use of the JVM.
-   */
-  virtual void getJVMClassPath(std::string & jvmClasspath) {}
-
-  /**
-   * \brief Set global JVM classpath property.
-   *
-   * This method should be used to set additional JVM classpath for modules
-   * that make use of JVM. This will overide the classpath set by CLASSPATH
-   * environment variable or Zorba config file.
-   *
-   * Once the JVM is started this method doesn't have any effect.
-   */
-  virtual void setJVMClassPath(const std::string & jvmClasspath) {}
-};
-
-}
-#endif  // ZORBA_PROPERTIES_BASE_H
-/*
- * Local variables:
- * mode: c++
- * End:
- */
+// This is a deprecated header; #include <zorba/properties.h> instead.
+
+#include <zorba/properties.h>
+
+#endif /* ZORBA_PROPERTIES_BASE_H */
 /* vim:set et sw=2 ts=2: */

=== modified file 'include/zorba/util/fs_util.h'
--- include/zorba/util/fs_util.h	2013-08-05 22:12:13 +0000
+++ include/zorba/util/fs_util.h	2014-02-10 00:46:59 +0000
@@ -90,6 +90,16 @@
 ////////// Directory //////////////////////////////////////////////////////////
 
 /**
+ * Gets the directory where per-user configuration files are stored.
+ *
+ * @return Returns said directory.
+ * @throws ZorbaException with a diagnostic of zerr::ZOSE0004_IO_ERROR if it
+ * fails.
+ */
+ZORBA_DLL_PUBLIC
+std::string configdir();
+
+/**
  * Gets the current directory.
  *
  * @return Returns said directory.
@@ -269,6 +279,37 @@
   return path.substr( 0, pos );
 }
 
+/**
+ * Gets the extension (the part of the name after the last '.') of the last
+ * path component of the given path name.
+ *
+ * @param path The path to get the extension of.
+ * @return Returns the extension (without the '.') or the empty string if
+ * \a path does not have an extension.
+ */
+inline std::string extension( char const *path ) {
+  char const *const name = base_name( path );
+  char const *const dot = std::strrchr( name, '.' );
+  return dot ? dot + 1 : "";
+}
+
+/**
+ * Gets the extension (the part of the name after the last '.') of the last
+ * path component of the given path name.
+ *
+ * @tparam PathStringType The \a path string type.
+ * @param path The path to get the extension of.
+ * @return Returns the extension (without the '.') or the empty string if
+ * \a path does not have an extension.
+ */
+template<class PathStringType> inline
+typename std::enable_if<ZORBA_IS_STRING(PathStringType),PathStringType>::type
+extension( PathStringType const &path ) {
+  PathStringType const name( base_name( path ) );
+  typename PathStringType::size_type const pos = name.rfind( '.' );
+  return pos != PathStringType::npos ? name.substr( pos + 1 ) : "";
+}
+
 #ifdef ZORBA_WITH_FILE_ACCESS
 
 /**

=== modified file 'include/zorba/zorba.h'
--- include/zorba/zorba.h	2013-08-06 08:41:26 +0000
+++ include/zorba/zorba.h	2014-02-10 00:46:59 +0000
@@ -34,7 +34,7 @@
 #include <zorba/xquery.h>
 #include <zorba/zorba_string.h>
 #include <zorba/iterator.h>
-#include <zorba/properties_base.h>
+#include <zorba/properties.h>
 
 namespace zorba {
 
@@ -45,7 +45,7 @@
  * (2) create static contexts,
  * (3) provides access to the XmlDataManager,
  * (4) provides access to the ItemFactory, and
- * (5) provides access to the PropertiesGlobal.
+ * (5) provides access to the Properties.
  */
 class ZORBA_DLL_PUBLIC Zorba
 {
@@ -319,9 +319,18 @@
 
   /** \brief Gets the singleton instance of Zorba's properties object.
    *
-   * @return zorba::Properties the singleton instance of Zorba's properties object.
-   */
-  virtual PropertiesGlobal* getPropertiesGlobal() = 0;
+   * @return zorba::Properties the singleton instance of Zorba's properties
+   * object.
+   * @deprecated Use Properties::instance() instead.
+   */
+  virtual Properties* getProperties() = 0;
+
+  /**
+   * @deprecated Use Properties::instance() instead.
+   */
+  Properties* getPropertiesGlobal() {
+    return getProperties();
+  }
 
 }; /* class Zorba */
 

=== modified file 'src/api/CMakeLists.txt'
--- src/api/CMakeLists.txt	2014-01-15 02:07:22 +0000
+++ src/api/CMakeLists.txt	2014-02-10 00:46:59 +0000
@@ -62,6 +62,7 @@
     store_consts.cpp
     streambuf.cpp
     mem_streambuf.cpp
+    properties.cpp
     transcode_streambuf.cpp
     uuid.cpp
     module_info_impl.cpp

=== renamed file 'src/system/zorba_properties.cpp' => 'src/api/properties.cpp'
--- src/system/zorba_properties.cpp	2014-01-27 23:42:57 +0000
+++ src/api/properties.cpp	2014-02-10 00:46:59 +0000
@@ -14,377 +14,88 @@
  * limitations under the License.
  */
 
-#include <cstring>
-
-#include "zorba_properties.h"
+// standard
+#include <exception>
+#include <fstream>
+#include <iostream>
+
+// Zorba
+#include <zorba/config.h>
+#include <zorba/internal/cxx_util.h>
+#include <zorba/properties.h>
+
+#include "util/string_util.h"
+
+using namespace std;
 
 namespace zorba { 
 
 ///////////////////////////////////////////////////////////////////////////////
 
-ZorbaProperties::ZorbaProperties() {
-  theAbort = false;
-  theCompileOnly = false;
-  theDebug = false;
-  theDumpLib = false;
-  theForceGflwor = false;
-  theInferJoins = true;
-  theInlineUdf = true;
-  theIterPlanTest = false;
-  theJsoniqParser = false;
-  theLibModule = false;
-  theLoopHoisting = true;
-  theMaxUdfCallDepth = 1024;
-  theNoCopyOptim = true;
-  theNoTreeIds = false;
-  theOptimizer = 1;
-  thePrintAst = false;
-  thePrintIntermediateOpt = false;
-  thePrintItemFlow = false;
-  thePrintIteratorTree = false;
-  thePrintLocations = false;
-  thePrintNormalized = false;
-  thePrintOptimized = false;
-  thePrintQuery = false;
-  thePrintStaticTypes = true;
-  thePrintTime = false;
-  thePrintTranslated = false;
-  thePrintXqdoc = false;
-  theReorderGlobals = true;
-  theSerializeOnlyQuery = -1;
-  theSpecializeCmp = true;
-  theSpecializeNum = true;
-  theStableIteratorIds = false;
-  theTestPlanSerialization = false;
-  theTraceCodegen = false;
-  theTraceFulltext = false;
-  theTraceParsing = false;
-  theTraceScanning = false;
-  theTraceTranslator = false;
-  theUseIndexes = true;
-  theUseSerializer = false;
-}
-
-char const** ZorbaProperties::get_all_options() const {
-  static char const *result[] = {
-    "--abort",
-    "--CLASSPATH",
-    "--compile-only",
-    "--debug",
-    "--debug-file",
-    "--dot-plan-file",
-    "--dump-lib",
-    "--external-var",
-    "--force-gflwor",
-    "--infer-joins",
-    "--inline-udf",
-    "--iter-plan-test",
-    "--jsoniq",
-    "--lib-module",
-    "--loop-hoisting",
-    "--max-udf-call-depth",
-    "--no-copy-optim",
-    "--no-tree-ids",
-    "--optimizer",
-    "--plan",
-    "--print-ast",
-    "--print-intermediate-opt",
-    "--print-item-flow",
-    "--print-iterator-tree",
-    "--print-locations",
-    "--print-normalized",
-    "--print-optimized",
-    "--print-query",
-    "--print-static-types",
-    "--print-time",
-    "--print-translated",
-    "--print-xqdoc",
-    "--query",
-    "--reorder-globals",
-    "--result-file",
-    "--serialize-only-query",
-    "--serializer-param",
-    "--specialize-cmp",
-    "--specialize-num",
-    "--stable-iterator-ids",
-    "--trace-codegen",
-    "--trace-fulltext",
-    "--trace-parsing",
-    "--trace-scanning",
-    "--trace-translator",
-    "--tz",
-    "--use-serializer",
-    0
-  };
-  return result;
-}
-
-char const* ZorbaProperties::get_help_msg() const {
-  return
-    "--abort\nabort when fatal error happens\n\n"
-    "--CLASSPATH\nJVM classpath to be used by modules using Java implementations\n\n"
-    "--compile-only\nonly compile (don't execute)\n\n"
-    "--debug-file\nlog file for debugging information\n\n"
-    "--debug\ncompile the query in debug mode\n\n"
-    "--dot-plan-file\ngenerate the dot iterator plan\n\n"
-    "--dump-lib\ndump function library\n\n"
-    "--external-var, -x\nexternal variables (e.g. -x x=file1.xml -x y:=strValue)\n\n"
-    "--force-gflwor\nforce compiler to generate GFLWOR iterators\n\n"
-    "--infer-joins\ninfer joins (1=enabled (default), 0=off)\n\n"
-    "--inline-udf\ninline functions (1=enabled (default), 0=off)\n\n"
-    "--iter-plan-test\nrun as iterator plan test\n\n"
-    "--loop-hoisting\nhoist expressions out of loops (1=enabled (default), 0=off)\n\n"
-    "--max-udf-call-depth\nmaximum stack depth of udf function calls\n\n"
-    "--no-copy-optim\napply the no-copy optimization (1=enabled (default), 0=off)\n\n"
-    "--no-tree-ids\nsuppress ids and locations from compiler tree dumps\n\n"
-    "--optimizer, -O\noptimization level (0, 1 or 2 - 1 is default)\n\n"
-    "--plan\ntest plan serialization, i.e. save the plan, load it back and then execute it\n\n"
-    "--print-ast, -a\nprint the parse tree\n\n"
-    "--print-intermediate-opt\nprint intermediate optimizations\n\n"
-    "--print-item-flow, -f\nshow items produced by all iterators\n\n"
-    "--print-iterator-tree, -i\nprint the iterator tree\n\n"
-    "--print-locations\nprint parser locations for compiler expressions\n\n"
-    "--print-normalized, -n\nprint the translated expression tree\n\n"
-    "--print-optimized, -P\nprint the optimized expression tree\n\n"
-    "--print-query, -q\nprint the query\n\n"
-    "--print-static-types\nprint static type inference\n\n"
-    "--print-time, -t\nprint the execution time\n\n"
-    "--print-translated\nprint the normalized expression tree\n\n"
-    "--print-xqdoc\ncreate output for XQDoc\n\n"
-    "--query, -e\nexecute inline query\n\n"
-    "--reorder-globals\nreorder global variables (1=enabled (default), 0=off)\n\n"
-    "--result-file, -o\nresult file\n\n"
-    "--serialize-only-query\nserialize-only-query (<0=unknown (default), 1=enabled, 0=off)\n\n"
-    "--serializer-param, -z\nserializer parameters (see http://www.w3.org/TR/xslt-xquery-serialization/#serparam, e.g. -z method=xhtml, -z doctype-system='DTD/xhtml1-strict.dtd', -z indent=yes)\n\n"
-    "--specialize-cmp\nspecialize generic comparisons (1=enabled (default), 0=off)\n\n"
-    "--specialize-num\nspecialize numerics (1=enabled (default), 0=off)\n\n"
-    "--stable-iterator-ids\nprint the iterator plan with stable ids\n\n"
-#ifndef NDEBUG
-    "--trace-codegen, -c\ntrace the codegenerator\n\n"
-    "--trace-fulltext\ntrace full-text evaluation\n\n"
-    "--trace-translator, -l\ntrace the translator\n\n"
-#endif
-    "--trace-parsing, -p\ntrace parsing\n\n"
-    "--trace-scanning, -s\ntrace scanning\n\n"
-    "--tz\nimplicit time zone (in minutes)\n\n"
-    "--use-serializer, -r\nuse serializer\n\n"
-  ;
-}
-
-ZorbaProperties const* ZorbaProperties::instance() {
-  static ZorbaProperties instance;
-  return &instance;
-}
-
-#define IS_LONG_OPT(OPT)  (strcmp( *argv, (OPT) ) == 0)
-#define IS_SHORT_OPT(OPT) (strncmp( *argv, (OPT), 2 ) == 0)
-#define IS_OPT(LOPT,SOPT) (IS_LONG_OPT(LOPT) || IS_SHORT_OPT(SOPT))
-
-std::string ZorbaProperties::load_argv( int argc, char const *argv[] ) {
-  if ( !argv )
-    return "";
-
-  std::string result;
-  for ( ++argv; *argv; ++argv ) {
-    if ( IS_OPT( "--help", "-h" ) )
-      return "!HELP";
-    if ( IS_OPT( "--version", "-v" ) )
-      return "!VER";
-
-    if ( IS_LONG_OPT( "--abort" ) )
-      theAbort = true;
-    else if ( IS_LONG_OPT( "--compile-only" ) )
-      theCompileOnly = true;
-    else if ( IS_LONG_OPT( "--CLASSPATH" ) ) {
-      int d = 2;
-      if ((*argv)[1] == '-' || (*argv)[2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --CLASSPATH option"; break; }
-      init_val(*argv, theCLASSPATH, d);
-    }
-    else if ( IS_LONG_OPT( "--debug" ) )
-      theDebug = true;
-    else if ( IS_LONG_OPT( "--debug-file" ) ) {
-      int d = 2;
-      if ((*argv)[1] == '-' || (*argv)[2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --debug-file option"; break; }
-      init_val(*argv, theDebugFile, d);
-    }
-    else if ( IS_LONG_OPT( "--dot-plan-file" ) ) {
-      int d = 2;
-      if ((*argv)[1] == '-' || (*argv)[2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --dot-plan-file option"; break; }
-      init_val(*argv, theDotPlanFile, d);
-    }
-    else if ( IS_LONG_OPT( "--dump-lib" ) )
-      theDumpLib = true;
-    else if ( IS_OPT( "--external-var", "-x" ) ) {
-      int d = 2;
-      if ((*argv)[1] == '-' || (*argv)[2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --external-var option"; break; }
-      init_val( *argv, theExternalVar, d );
-    }
-    else if ( IS_LONG_OPT( "--force-gflwor" ) )
-      theForceGflwor = true;
-    else if ( IS_LONG_OPT( "--infer-joins" ) ) {
-      int d = 2;
-      if ((*argv)[1] == '-' || (*argv)[2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --infer-joins option"; break; }
-      init_val(*argv, theInferJoins, d);
-    }
-    else if ( IS_LONG_OPT( "--inline-udf" ) ) {
-      int d = 2;
-      if ((*argv)[1] == '-' || (*argv)[2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --inline-udf option"; break; }
-      init_val(*argv, theInlineUdf, d);
-    }
-    else if ( IS_LONG_OPT( "--iter-plan-test" ) )
-      theIterPlanTest = true;
-    else if ( IS_OPT( "--jsoniq", "-j" ) )
-      theJsoniqParser = true;
-    else if ( IS_LONG_OPT( "--lib-module" ) )
-      theLibModule = true;
-    else if ( IS_LONG_OPT( "--loop-hoisting" ) ) {
-      int d = 2;
-      if ((*argv)[1] == '-' || (*argv)[2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --loop-hoisting option"; break; }
-      init_val(*argv, theLoopHoisting, d);
-    }
-    else if ( IS_LONG_OPT( "--max-udf-call-depth" ) ) {
-      int d = 2;
-      if ((*argv)[1] == '-' || (*argv)[2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --max-udf-call-depth option"; break; }
-      init_val(*argv, theMaxUdfCallDepth, d);
-    }
-    else if ( IS_LONG_OPT( "--no-copy-optim" ) ) {
-      int d = 2;
-      if ((*argv)[1] == '-' || (*argv)[2] == '\0') { d = 0; ++argv; }
-      if (!*argv) {
-        result = "No value given for --no-copy-optim option"; break; 
-      }
-      init_val(*argv, theNoCopyOptim, d);
-    }
-    else if ( IS_LONG_OPT( "--no-tree-ids" ) )
-      theNoTreeIds = true;
-    else if ( IS_OPT( "--optimizer", "-O" ) ) {
-      int d = 2;
-      if ((*argv)[1] == '-' || (*argv)[2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --optimizer option"; break; }
-      init_val(*argv, theOptimizer, d);
-    }
-    else if ( IS_LONG_OPT( "--plan" ) )
-      theTestPlanSerialization = true;
-    else if ( IS_OPT( "--print-ast", "-a" ) )
-      thePrintAst = true;
-    else if ( IS_LONG_OPT( "--print-intermediate-opt" ) )
-      thePrintIntermediateOpt = true;
-    else if ( IS_OPT( "--print-item-flow", "-f" ) )
-      thePrintItemFlow = true;
-    else if ( IS_OPT( "--print-iterator-tree", "-i" ) )
-      thePrintIteratorTree = true;
-    else if ( IS_LONG_OPT( "--print-locations" ) )
-      thePrintLocations = true;
-    else if ( IS_OPT( "--print-normalized", "-n" ) )
-      thePrintNormalized = true;
-    else if ( IS_OPT( "--print-optimized", "-P" ) )
-      thePrintOptimized = true;
-    else if ( IS_OPT( "--print-query", "-q" ) )
-      thePrintQuery = true;
-    else if ( IS_LONG_OPT( "--print-static-types" ) ) {
-      int d = 2;
-      if ((*argv)[1] == '-' || (*argv)[2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --print-static-types option"; break; }
-      init_val(*argv, thePrintStaticTypes, d);
-    }
-    else if ( IS_OPT( "--print-time", "-t" ) )
-      thePrintTime = true;
-    else if ( IS_LONG_OPT( "--print-translated" ) )
-      thePrintTranslated = true;
-    else if ( IS_LONG_OPT( "--print-xqdoc" ) )
-      thePrintXqdoc = true;
-    else if ( IS_OPT( "--query", "-e" ) ) {
-      int d = 2;
-      if ((*argv)[1] == '-' || (*argv)[2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --query option"; break; }
-      init_val(*argv, theQuery, d);
-    }
-    else if ( IS_LONG_OPT( "--reorder-globals" ) ) {
-      int d = 2;
-      if ((*argv)[1] == '-' || (*argv)[2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --reorder-globals option"; break; }
-      init_val(*argv, theReorderGlobals, d);
-    }
-    else if ( IS_OPT( "--result-file", "-o" ) ) {
-      int d = 2;
-      if ((*argv)[1] == '-' || (*argv)[2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --result-file option"; break; }
-      init_val(*argv, theResultFile, d);
-    }
-    else if ( IS_LONG_OPT( "--serialize-only-query" ) ) {
-      int d = 2;
-      if ((*argv)[1] == '-' || (*argv)[2] == '\0') { d = 0; ++argv; }
-      if (!*argv)
-      { result = "No value given for --serialize-only-query option"; break; }
-      init_val(*argv, theSerializeOnlyQuery, d);
-    }
-    else if ( IS_OPT( "--serializer-param", "-z" ) ) {
-      int d = 2;
-      if ((*argv)[1] == '-' || (*argv)[2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --serializer-param option"; break; }
-      init_val(*argv, theSerializerParam, d);
-    }
-    else if ( IS_LONG_OPT( "--specialize-cmp" ) ) {
-      int d = 2;
-      if ((*argv)[1] == '-' || (*argv)[2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --specialize-cmp option"; break; }
-      init_val(*argv, theSpecializeCmp, d);
-    }
-    else if ( IS_LONG_OPT( "--specialize-num" ) ) {
-      int d = 2;
-      if ((*argv)[1] == '-' || (*argv)[2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --specialize-num option"; break; }
-      init_val(*argv, theSpecializeNum, d);
-    }
-    else if ( IS_LONG_OPT( "--stable-iterator-ids" ) )
-      theStableIteratorIds = true;
-    else if ( IS_OPT( "--trace-parsing", "-p" ) )
-      theTraceParsing = true;
-    else if ( IS_OPT( "--trace-scanning", "-s" ) )
-      theTraceScanning = true;
-#ifndef NDEBUG
-    else if ( IS_OPT( "--trace-codegen", "-c" ) )
-      theTraceCodegen = true;
-    else if ( IS_LONG_OPT( "--trace-fulltext" ) )
-      theTraceFulltext = true;
-    else if ( IS_OPT( "--trace-translator", "-l" ) )
-      theTraceTranslator = true;
-#endif
-    else if ( IS_LONG_OPT( "--tz" ) ) {
-      int d = 2;
-      if ((*argv)[1] == '-' || (*argv)[2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --tz option"; break; }
-      init_val(*argv, theTz, d);
-    }
-    else if ( IS_LONG_OPT( "--use-indexes" ) ) {
-      int d = 2;
-      if ((*argv)[1] == '-' || (*argv)[2] == '\0') { d = 0; ++argv; }
-      if (!*argv) { result = "No value given for --use-indexes option"; break; }
-      init_val(*argv, theUseIndexes, d);
-    }
-    else if ( IS_OPT( "--use-serializer", "-r" ) )
-      theUseSerializer = true;
-
-    else if ( IS_LONG_OPT( "--" ) ) {
-      copy_args( ++argv );
-      break;
-    } else if ( (*argv)[0] == '-' ) {
-      result = "unknown command line option "; result += *argv;
-      break; 
-    } else {
-      copy_args( argv );
-      break;
-    }
-  } // for
-  return result;
+Properties::Properties() {
+  abort_ = false;
+  owns_debug_stream_ = false;
+  debug_stream_.reset( &cout );
+  dump_lib_ = false;
+  force_gflwor_ = false;
+  infer_joins_ = true;
+  inline_udf_ = true;
+  loop_hoisting_ = true;
+  max_udf_call_depth_ = 1024;
+  no_copy_optim_ = true;
+  no_tree_ids_ = false;
+  optimization_level_ = 1;
+  print_ast_ = false;
+  print_intermediate_opt_ = false;
+  print_item_flow_ = false;
+  print_iterator_locations_ = false;
+  print_locations_ = false;
+  print_optimized_ = false;
+  print_static_types_ = true;
+  print_translated_ = false;
+  stable_iterator_ids_ = false;
+  trace_codegen_ = false;
+#ifndef ZORBA_NO_FULL_TEXT
+  trace_fulltext_ = false;
+#endif /* ZORBA_NO_FULL_TEXT */
+  trace_parsing_ = false;
+  trace_scanning_ = false;
+  trace_translator_ = false;
+  use_indexes_ = true;
+}
+
+Properties::~Properties() {
+  if ( !owns_debug_stream_ )
+    debug_stream_.release();
+}
+
+Properties& Properties::instance() {
+  static Properties properties;
+  return properties;
+}
+
+void Properties::setDebugFile( char const *file ) {
+  if ( file && *file )
+    setDebugStream( *(new ofstream( file )), true );
+  else
+    setDebugStream( cout );
+}
+
+void Properties::setDebugStream( ostream &os, bool take_ownership ) {
+  if ( !owns_debug_stream_ )
+    debug_stream_.release();
+  if ( take_ownership && (&os == &cout || &os == &cerr) )
+    take_ownership = false;
+  owns_debug_stream_ = take_ownership;
+  debug_stream_.reset( &os );
+}
+
+void Properties::setOptimizationLevel( unsigned opt_level ) {
+  if ( opt_level > 2 )
+    throw invalid_argument(
+      BUILD_STRING( opt_level, ": invalid optimization level; must be [0-2]" )
+    );
+  optimization_level_ = opt_level;
 }
 
 ///////////////////////////////////////////////////////////////////////////////

=== modified file 'src/api/zorbaimpl.cpp'
--- src/api/zorbaimpl.cpp	2013-08-06 08:41:26 +0000
+++ src/api/zorbaimpl.cpp	2014-02-10 00:46:59 +0000
@@ -21,6 +21,7 @@
 #include <zorba/diagnostic_list.h>
 #include <zorba/store_manager.h>
 #include <zorba/query_location.h>
+#include <zorba/properties.h>
 
 #include "api/xqueryimpl.h"
 #include "api/staticcontextimpl.h"
@@ -35,7 +36,6 @@
 #include "diagnostics/xquery_diagnostics.h"
 
 #include "system/globalenv.h"
-#include "system/properties.h"
 
 #include "context/static_context.h"
 
@@ -281,9 +281,9 @@
 /*******************************************************************************
 
 ********************************************************************************/
-PropertiesGlobal* ZorbaImpl::getPropertiesGlobal()
+Properties* ZorbaImpl::getProperties()
 {
-  return Properties::instance();
+  return &Properties::instance();
 }
 
 

=== modified file 'src/api/zorbaimpl.h'
--- src/api/zorbaimpl.h	2013-08-06 08:41:26 +0000
+++ src/api/zorbaimpl.h	2014-02-10 00:46:59 +0000
@@ -135,7 +135,7 @@
 
   audit::Provider* getAuditProvider();
 
-  PropertiesGlobal* getPropertiesGlobal();
+  Properties* getProperties();
 
 protected:
   ZorbaImpl();

=== modified file 'src/compiler/api/compiler_api.cpp'
--- src/compiler/api/compiler_api.cpp	2013-08-14 08:46:44 +0000
+++ src/compiler/api/compiler_api.cpp	2014-02-10 00:46:59 +0000
@@ -22,7 +22,7 @@
 #include "diagnostics/dict.h"
 
 #include "system/globalenv.h"
-#include "system/properties.h"
+#include <zorba/properties.h>
 
 #include "context/static_context.h"
 
@@ -164,7 +164,7 @@
 parsenode_t XQueryCompiler::parse(std::istream& aXQuery, const zstring& aFileName)
 {
   // TODO: move these out
-  if (Properties::instance()->printAst())
+  if (Properties::instance().getPrintAST())
   {
     theCompilerCB->theConfig.parse_cb = print_ast_tree;
   }

=== modified file 'src/compiler/api/compilercb.cpp'
--- src/compiler/api/compilercb.cpp	2013-12-04 06:14:57 +0000
+++ src/compiler/api/compilercb.cpp	2014-02-10 00:46:59 +0000
@@ -25,7 +25,7 @@
 
 #include "context/static_context.h"
 
-#include "system/properties.h"
+#include <zorba/properties.h>
 
 #include "zorbaserialization/serialize_template_types.h"
 #include "zorbaserialization/serialize_zorba_types.h"
@@ -39,13 +39,12 @@
 SERIALIZABLE_CLASS_VERSIONS_2(CompilerCB::config, TYPE_CompilerCB_config)
 
 
-#define DEF_PRINT_EXPR_TREE( phase )                                    \
-static void print_expr_tree_##phase(const expr* e, const std::string& name) \
-{                                                                       \
-  std::ostream& os = Properties::instance()->debug_out();               \
-  os << "Expression tree after " << #phase                              \
-     << " for " << name << "\n";                                        \
-  e->put(os) << std::endl;                                              \
+#define DEF_PRINT_EXPR_TREE( phase )                          \
+static void print_expr_tree_##phase(const expr* e, const std::string& name) { \
+  std::ostream& os = Properties::instance().getDebugStream(); \
+  os << "Expression tree after " << #phase                    \
+     << " for " << name << "\n";                              \
+  e->put(os) << std::endl;                                    \
 }
 
 
@@ -66,15 +65,15 @@
   translate_cb = optimize_cb = NULL;
 
   // TODO: move these out
-  print_item_flow = Properties::instance()->printItemFlow();
+  print_item_flow = Properties::instance().getPrintItemFlow();
 
-  if (Properties::instance()->printTranslated())
+  if (Properties::instance().getPrintTranslated())
     translate_cb = print_expr_tree_translation;
 
-  if (Properties::instance()->printOptimized())
+  if (Properties::instance().getPrintOptimized())
     optimize_cb = print_expr_tree_optimization;
 
-  force_gflwor = Properties::instance()->forceGflwor();
+  force_gflwor = Properties::instance().getForceGFLWOR();
 }
 
 

=== modified file 'src/compiler/codegen/plan_visitor.cpp'
--- src/compiler/codegen/plan_visitor.cpp	2013-10-10 03:54:10 +0000
+++ src/compiler/codegen/plan_visitor.cpp	2014-02-10 00:46:59 +0000
@@ -22,15 +22,15 @@
 
 #include <zorba/config.h>
 #include <zorba/diagnostic_list.h>
+#include <zorba/internal/unique_ptr.h>
+#include <zorba/properties.h>
+
 #include "diagnostics/assert.h"
-#include <zorba/internal/unique_ptr.h>
-
 #include "util/hashmap32.h"
 #include "util/stl_util.h"
 #include "util/tracer.h"
 
 #include "system/globalenv.h"
-#include "system/properties.h"
 
 #include "compiler/expression/expr_manager.h"
 #include "compiler/api/compilercb.h"
@@ -127,7 +127,7 @@
 #define CODEGEN_TRACE(msg)                                         \
   QLOCDECL;                                                        \
   SCTXDECL;                                                        \
-  if (Properties::instance()->traceCodegen())                      \
+  if (Properties::instance().getTraceCodegen())                    \
   {                                                                \
     std::cout << (msg) << TRACE << ", stk size " << itstack.size() \
               << std::endl << std::endl;                           \
@@ -3808,12 +3808,9 @@
 
   if (result != NULL &&
       descr != NULL &&
-      Properties::instance()->printIteratorTree())
+      Properties::instance().getPrintIteratorTree())
   {
-    std::ostream& os = (Properties::instance()->iterPlanTest() ?
-                        std::cout :
-                        Properties::instance()->debug_out());
-
+    std::ostream &os = Properties::instance().getDebugStream();
     os << "Iterator tree for " << descr << ":\n";
     XMLIterPrinter vp(os);
     print_iter_plan(vp, result);

=== modified file 'src/compiler/expression/expr_base.cpp'
--- src/compiler/expression/expr_base.cpp	2013-06-13 14:54:50 +0000
+++ src/compiler/expression/expr_base.cpp	2014-02-10 00:46:59 +0000
@@ -52,7 +52,7 @@
 
 static xqtref_t print_expr_and_type(expr* e, xqtref_t t)
 {
-  if (Properties::instance()->printStaticTypes())
+  if (Properties::instance().getPrintStaticTypes())
   {
     std::cout << "Return type for " << e << ":\n";
     e->put(std::cout);

=== modified file 'src/compiler/expression/expr_put.cpp'
--- src/compiler/expression/expr_put.cpp	2013-07-01 09:26:16 +0000
+++ src/compiler/expression/expr_put.cpp	2014-02-10 00:46:59 +0000
@@ -22,8 +22,7 @@
 #include <vector>
 
 #include <zorba/config.h>
-
-#include "system/properties.h"
+#include <zorba/properties.h>
 
 #include "context/static_context_consts.h"
 
@@ -101,7 +100,7 @@
 
 static inline string expr_addr(const void* e)
 {
-  if (Properties::instance()->noTreeIds())
+  if (Properties::instance().getNoTreeIDs())
   {
     return "";
   }
@@ -119,7 +118,7 @@
   if (e == NULL)
     return "";
 
-  if (Properties::instance()->printLocations())
+  if (Properties::instance().getPrintLocations())
   {
     ostringstream os;
     os << " (loc: " << e->get_loc().getLineBegin() << ", "

=== modified file 'src/compiler/parser/xquery_driver.cpp'
--- src/compiler/parser/xquery_driver.cpp	2013-05-15 10:58:40 +0000
+++ src/compiler/parser/xquery_driver.cpp	2014-02-10 00:46:59 +0000
@@ -16,7 +16,8 @@
 #include "stdafx.h"
 
 #include <fstream>
-#include "system/properties.h"
+
+#include <zorba/properties.h>
 #include "compiler/parser/xquery_driver.h"
 
 #ifdef __GNUC__
@@ -197,12 +198,12 @@
   if (grammar_type == XQUERY_GRAMMAR)
   {    
     xquery_scanner scanner(this, &in);
-    scanner.set_yy_flex_debug(Properties::instance()->traceScanning());
+    scanner.set_yy_flex_debug(Properties::instance().getTraceScanning());
     this->xquery_lexer = &scanner;
     // scanner.set_yy_flex_debug(true); // debugging purposes
 
     xquery_parser parser(*this);
-    parser.set_debug_level(Properties::instance()->traceParsing());
+    parser.set_debug_level(Properties::instance().getTraceParsing());
     // parser.set_debug_level(true); // debugging purposes
     
     return (parser.parse() == 0);
@@ -210,12 +211,12 @@
   else
   {
     jsoniq_scanner scanner(this, &in);
-    scanner.set_yy_flex_debug(Properties::instance()->traceScanning());
+    scanner.set_yy_flex_debug(Properties::instance().getTraceScanning());
     this->jsoniq_lexer = &scanner;
     // scanner.set_yy_flex_debug(true); // debugging purposes
 
     jsoniq_parser parser(*this);
-    parser.set_debug_level(Properties::instance()->traceParsing());
+    parser.set_debug_level(Properties::instance().getTraceParsing());
     // parser.set_debug_level(true); // debugging purposes
     
     return (parser.parse() == 0);

=== modified file 'src/compiler/rewriter/framework/default_optimizer.cpp'
--- src/compiler/rewriter/framework/default_optimizer.cpp	2013-05-15 10:27:06 +0000
+++ src/compiler/rewriter/framework/default_optimizer.cpp	2014-02-10 00:46:59 +0000
@@ -30,7 +30,7 @@
 
 #include "functions/udf.h"
 
-#include "system/properties.h"
+#include <zorba/properties.h>
 
 #include "context/static_context.h"
 
@@ -67,7 +67,7 @@
 
   // InlineFunctions
 
-  if (Properties::instance()->inlineUdf())
+  if (Properties::instance().getInlineUDF())
   {
     SingletonRuleMajorDriver<InlineFunctions> driverInlineFunctions;
     if (driverInlineFunctions.rewrite(rCtx))
@@ -150,7 +150,7 @@
   }
 
   // Loop Hoisting
-  if (Properties::instance()->loopHoisting())
+  if (Properties::instance().getLoopHoisting())
   {
     HoistRule rule;
     bool local_modified = false;
@@ -165,7 +165,7 @@
     {
       modified = true;
 
-      if (Properties::instance()->printIntermediateOpt())
+      if (Properties::instance().getPrintIntermediateOpt())
       {
         std::cout << "After hoisting : " << std::endl;
         rCtx.getRoot()->put(std::cout) << std::endl;
@@ -177,7 +177,7 @@
   }
 
   // index matching
-  if (Properties::instance()->useIndexes())
+  if (Properties::instance().getUseIndexes())
   {
     static_context* sctx = rCtx.theRoot->get_sctx();
 
@@ -212,7 +212,7 @@
 
       if (local_modified)
       {
-        if (Properties::instance()->printIntermediateOpt())
+        if (Properties::instance().getPrintIntermediateOpt())
         {
           std::cout << "After index matching : " << std::endl;
           rCtx.getRoot()->put(std::cout) << std::endl;
@@ -224,7 +224,7 @@
   }
 
   // Index Joins
-  if (Properties::instance()->inferJoins())
+  if (Properties::instance().getInferJoins())
   {
     bool local_modified = false;
 
@@ -243,7 +243,7 @@
       {
         modified = true;
 
-        if (Properties::instance()->printIntermediateOpt())
+        if (Properties::instance().getPrintIntermediateOpt())
         {
           std::cout << "After index join : " << std::endl;
           rCtx.getRoot()->put(std::cout) << std::endl;
@@ -258,7 +258,7 @@
   }
 
   // Mark node copy property
-  if (Properties::instance()->noCopyOptim())
+  if (Properties::instance().getNoCopyOptim())
   {
     if (rCtx.theUDF == NULL)
     {

=== modified file 'src/compiler/rewriter/framework/rule_driver.cpp'
--- src/compiler/rewriter/framework/rule_driver.cpp	2013-05-13 08:45:43 +0000
+++ src/compiler/rewriter/framework/rule_driver.cpp	2014-02-10 00:46:59 +0000
@@ -22,7 +22,7 @@
 
 #include "functions/udf.h"
 
-#include "system/properties.h"
+#include <zorba/properties.h>
 
 
 namespace zorba
@@ -82,7 +82,7 @@
           rCtx.theUDF->invalidatePlan();
         }
 
-        if (Properties::instance()->printIntermediateOpt())
+        if (Properties::instance().getPrintIntermediateOpt())
         {
           std::cout << rCtx.theMessage << std::endl
                     << "After " << (*i)->getRuleName() << " :" << std::endl;
@@ -119,7 +119,7 @@
     }
   }
 
-  if (modified && Properties::instance()->printIntermediateOpt())
+  if (modified && Properties::instance().getPrintIntermediateOpt())
   {
     if (rCtx.theUDF != NULL)
     {

=== modified file 'src/compiler/rewriter/rules/flwor_rules.cpp'
--- src/compiler/rewriter/rules/flwor_rules.cpp	2013-09-23 09:11:02 +0000
+++ src/compiler/rewriter/rules/flwor_rules.cpp	2014-02-10 00:46:59 +0000
@@ -35,7 +35,7 @@
 #include "diagnostics/xquery_warning.h"
 #include "diagnostics/assert.h"
 
-#include "system/properties.h"
+#include <zorba/properties.h>
 
 #include "zorbatypes/integer.h"
 #include <zorba/internal/unique_ptr.h>
@@ -366,7 +366,7 @@
         theFlwor->compute_return_type(false, NULL);
     }
 
-    if (modified && Properties::instance()->printIntermediateOpt())
+    if (modified && Properties::instance().getPrintIntermediateOpt())
     {
       std::cout << rCtx.theMessage << std::endl
                 << "After folding var : " << var << " :" << std::endl;

=== modified file 'src/compiler/rewriter/rules/index_join_rule.cpp'
--- src/compiler/rewriter/rules/index_join_rule.cpp	2013-06-13 14:54:50 +0000
+++ src/compiler/rewriter/rules/index_join_rule.cpp	2014-02-10 00:46:59 +0000
@@ -29,7 +29,7 @@
 
 #include "types/typeops.h"
 
-#include "system/properties.h"
+#include <zorba/properties.h>
 
 #include "diagnostics/assert.h"
 
@@ -1124,7 +1124,7 @@
 
   sctx->bind_index(idx, loc);
 
-  if (Properties::instance()->printIntermediateOpt())
+  if (Properties::instance().getPrintIntermediateOpt())
   {
     std::cout << std::endl << idx->toString() << std::endl;
   }

=== modified file 'src/compiler/rewriter/rules/index_matching_rule.cpp'
--- src/compiler/rewriter/rules/index_matching_rule.cpp	2013-05-31 01:47:24 +0000
+++ src/compiler/rewriter/rules/index_matching_rule.cpp	2014-02-10 00:46:59 +0000
@@ -39,7 +39,7 @@
 
 #include "diagnostics/assert.h"
 
-#include "system/properties.h"
+#include <zorba/properties.h>
 
 
 namespace zorba

=== modified file 'src/compiler/rewriter/rules/type_rules.cpp'
--- src/compiler/rewriter/rules/type_rules.cpp	2013-09-16 09:08:27 +0000
+++ src/compiler/rewriter/rules/type_rules.cpp	2014-02-10 00:46:59 +0000
@@ -34,7 +34,7 @@
 #include "functions/library.h"
 #include "functions/udf.h"
 
-#include "system/properties.h"
+#include <zorba/properties.h>
 
 #include "diagnostics/assert.h"
 

=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp	2013-10-15 17:00:25 +0000
+++ src/compiler/translator/translator.cpp	2014-02-10 00:46:59 +0000
@@ -25,7 +25,7 @@
 #include <zorba/config.h>
 #include <zorba/diagnostic_list.h>
 #include <zorba/internal/unique_ptr.h>
-
+#include <zorba/properties.h>
 
 #include "common/common.h"
 
@@ -67,7 +67,6 @@
 #include "compiler/xqddf/collection_decl.h"
 
 #include "system/globalenv.h"
-#include "system/properties.h"
 
 #include "functions/library.h"
 #include "functions/signature.h"
@@ -143,7 +142,7 @@
 #define TRACE_VISIT()                                                   \
   const QueryLoc& loc = v.get_location(); (void)loc;                    \
                                                                         \
-  if (Properties::instance()->traceTranslator())                        \
+  if (Properties::instance().getTraceTranslator())                      \
     std::cout << std::string(++thePrintDepth, ' ') << TRACE << ", stk size "   \
               << theNodeStack.size() << ", tstk size: " << theTypeStack.size() \
               << ", scope depth " << theScopeDepth << std::endl;
@@ -152,7 +151,7 @@
 #define TRACE_VISIT_OUT()                                               \
   const QueryLoc& loc = v.get_location(); (void)loc;                    \
                                                                         \
-  if (Properties::instance()->traceTranslator())                        \
+  if (Properties::instance().getTraceTranslator())                      \
     std::cout << std::string(thePrintDepth--, ' ') << TRACE << ", stk size: "  \
               << theNodeStack.size() << ", tstk size: " << theTypeStack.size() \
               << ", scope depth " << theScopeDepth << std::endl;
@@ -823,7 +822,7 @@
     theNodeStack.pop();
 
 #ifndef NDEBUG
-    if (Properties::instance()->traceTranslator())
+    if (Properties::instance().getTraceTranslator())
     {
       std::cout << "Popped from nodestack:\n";
       if (e_h != NULL)
@@ -845,7 +844,7 @@
   theNodeStack.push(e);
 
 #ifndef NDEBUG
-  if (Properties::instance()->traceTranslator())
+  if (Properties::instance().getTraceTranslator())
   {
     std::cout << "Pushed to nodestack: \n";
     if (e != NULL)
@@ -937,7 +936,7 @@
     theFTNodeStack.pop();
 
 #ifndef NDEBUG
-    if ( Properties::instance()->traceTranslator() )
+    if ( Properties::instance().getTraceTranslator() )
     {
       std::cout << "Popped from ftnode stack:\n";
       if ( n )
@@ -13436,7 +13435,7 @@
   nameExpr = CREATE(const)(theRootSctx, theUDF, loc, qnameItem);
 
   bool copyNodes = (theCCB->theConfig.opt_level < CompilerCB::config::O1 ||
-                    !Properties::instance()->noCopyOptim());
+                    !Properties::instance().getNoCopyOptim());
 
   push_nodestack(CREATE(elem)(theRootSctx,
                               theUDF,
@@ -14131,7 +14130,7 @@
   fo_expr* enclosed = wrap_in_enclosed_expr(content, loc);
 
   bool copyNodes = (theCCB->theConfig.opt_level < CompilerCB::config::O1 ||
-                    !Properties::instance()->noCopyOptim());
+                    !Properties::instance().getNoCopyOptim());
 
   push_nodestack(CREATE(doc)(theRootSctx, theUDF, loc, enclosed, copyNodes));
 }
@@ -14180,7 +14179,7 @@
   }
 
   bool copyNodes = (theCCB->theConfig.opt_level < CompilerCB::config::O1 ||
-                    !Properties::instance()->noCopyOptim());
+                    !Properties::instance().getNoCopyOptim());
 
   push_nodestack(CREATE(elem)(theRootSctx,
                               theUDF,
@@ -16373,7 +16372,7 @@
 #ifndef NDEBUG
       expr* e_h = pop_nodestack();
 
-      if (! Properties::instance()->traceTranslator())
+      if (! Properties::instance().getTraceTranslator())
       {
         if (e_h != NULL)
           e_h->put(std::cout) << std::endl;

=== modified file 'src/diagnostics/zorba_exception.cpp'
--- src/diagnostics/zorba_exception.cpp	2013-06-04 00:34:52 +0000
+++ src/diagnostics/zorba_exception.cpp	2014-02-10 00:46:59 +0000
@@ -15,8 +15,16 @@
  */
 #include "stdafx.h"
 
+// standard
+#ifndef NDEBUG
+#include <cstdlib>                      /* for abort() */
+#endif /* NDEBUG */
 #include <sstream>
 
+// Zorba
+#ifndef NDEBUG
+#include <zorba/properties.h>
+#endif /* NDEBUG */
 #include <zorba/zorba_exception.h>
 #include <zorba/xquery_warning.h>
 
@@ -24,13 +32,9 @@
 #include "util/omanip.h"
 #include "zorbamisc/ns_consts.h"
 
+// local
 #include "dict.h"
 
-#ifndef NDEBUG
-#include <cstdlib>                      /* for abort() */
-ZORBA_DLL_PUBLIC bool g_abort_on_error;
-#endif /* NDEBUG */
-
 #define if_inc_indent if_do( do_indent, inc_indent )
 #define if_dec_indent if_do( do_indent, dec_indent )
 
@@ -58,8 +62,13 @@
   message_( message )
 {
 #ifndef NDEBUG
-  if ( g_abort_on_error )
+  if ( Properties::instance().getAbort() ) {
+    cerr << "ZorbaException thrown:" << '\n'
+         << "  what: " << message_ << '\n'
+         << "  file: " << raise_file_ << '\n'
+         << "  line: " << raise_line_ << endl;
     abort();
+  }
 #endif /* NDEBUG */
 }
 

=== modified file 'src/functions/function_impl.h'
--- src/functions/function_impl.h	2013-07-02 21:32:23 +0000
+++ src/functions/function_impl.h	2014-02-10 00:46:59 +0000
@@ -29,10 +29,10 @@
 
 #ifndef NDEBUG
 
-#include "system/properties.h"
+#include <zorba/properties.h>
 
 #define DEBUG_FN_DECL(fname, cnt)                                     \
-  if (Properties::instance()->dumpLib())                              \
+  if (Properties::instance().getDumpLib())                            \
     std::cout << "Bound function " << fname->getStringValue() << "/" << cnt << std::endl;
 
 #else

=== modified file 'src/runtime/api/plan_wrapper.cpp'
--- src/runtime/api/plan_wrapper.cpp	2013-07-25 14:09:47 +0000
+++ src/runtime/api/plan_wrapper.cpp	2014-02-10 00:46:59 +0000
@@ -23,7 +23,7 @@
 #include "runtime/api/plan_wrapper.h"
 #include "runtime/base/plan_iterator.h"
 #include "runtime/util/timeout.h"
-#include "system/properties.h"
+#include <zorba/properties.h>
 
 
 namespace zorba {
@@ -62,7 +62,7 @@
                                aDynamicContext,
                                lStateSize,
                                aStackDepth,
-                               Properties::instance()->maxUdfCallDepth());
+                               Properties::instance().getMaxUDFCallDepth());
 
   // set the compiler cb in the state
   thePlanState->theCompilerCB = aCompilerCB;

=== modified file 'src/runtime/base/plan_iterator.cpp'
--- src/runtime/base/plan_iterator.cpp	2014-01-15 00:58:24 +0000
+++ src/runtime/base/plan_iterator.cpp	2014-02-10 00:46:59 +0000
@@ -32,7 +32,7 @@
 #include "diagnostics/util_macros.h"
 
 #ifndef NDEBUG
-#include "system/properties.h"
+#include <zorba/properties.h>
 #endif
 
 namespace zorba
@@ -219,7 +219,7 @@
 
   if (planState.theCompilerCB->theConfig.print_item_flow)
   {
-    if (Properties::instance()->stableIteratorIds())
+    if (Properties::instance().getStableIteratorIDs())
       std::cout << "next (" << iter->getId();
     else
       std::cout << "next (" << iter;

=== modified file 'src/runtime/full_text/apply.cpp'
--- src/runtime/full_text/apply.cpp	2013-12-14 00:43:29 +0000
+++ src/runtime/full_text/apply.cpp	2014-02-10 00:46:59 +0000
@@ -37,9 +37,9 @@
 #include "zorbamisc/ns_consts.h"
 
 #ifndef NDEBUG
-# include "system/properties.h"
-# define DOUT             Properties::instance()->debug_out()
-# define TRACE_FULL_TEXT  Properties::instance()->traceFulltext()
+# include <zorba/properties.h>
+# define DOUT             Properties::instance().getDebugStream()
+# define TRACE_FULL_TEXT  Properties::instance().getTraceFulltext()
 #endif /* NDEBUG */
 
 #include "apply.h"

=== modified file 'src/runtime/full_text/ftcontains_visitor.cpp'
--- src/runtime/full_text/ftcontains_visitor.cpp	2013-08-14 08:46:44 +0000
+++ src/runtime/full_text/ftcontains_visitor.cpp	2014-02-10 00:46:59 +0000
@@ -31,9 +31,9 @@
 #include "zorbatypes/integer.h"
 
 #ifndef NDEBUG
-#include "system/properties.h"
-#define DOUT            Properties::instance()->debug_out()
-#define TRACE_FULL_TEXT Properties::instance()->traceFulltext()
+# include <zorba/properties.h>
+# define DOUT             Properties::instance().getDebugStream()
+# define TRACE_FULL_TEXT  Properties::instance().getTraceFulltext()
 #endif /* NDEBUG */
 
 #include "apply.h"

=== modified file 'src/runtime/jsound/jsound_util.cpp'
--- src/runtime/jsound/jsound_util.cpp	2013-12-19 01:10:50 +0000
+++ src/runtime/jsound/jsound_util.cpp	2014-02-10 00:46:59 +0000
@@ -23,6 +23,7 @@
 #include <zorba/diagnostic_list.h>
 #include <zorba/internal/cxx_util.h>
 #include <zorba/internal/unique_ptr.h>
+#include <zorba/properties.h>
 #include <zorba/store_consts.h>
 
 #include "compiler/api/compiler_api.h"
@@ -38,7 +39,6 @@
 #include "store/api/item_factory.h"
 #include "store/api/iterator.h"
 #include "system/globalenv.h"
-#include "system/properties.h"
 #include "types/casting.h"
 #include "types/root_typemanager.h"
 #include "types/typeops.h"
@@ -973,7 +973,7 @@
 bool constraint::validate( dynamic_context &dctx ) const {
   PlanState state(
     &dctx, &dctx, plan_->getStateSizeOfSubtree(), 0,
-    Properties::instance()->maxUdfCallDepth()
+    Properties::instance().getMaxUDFCallDepth()
   );
   state.theCompilerCB = const_cast<CompilerCB*>( &ccb_ );
   uint32_t offset = 0;

=== modified file 'src/runtime/spec/printer_visitor_cpp.xq'
--- src/runtime/spec/printer_visitor_cpp.xq	2013-08-09 08:27:30 +0000
+++ src/runtime/spec/printer_visitor_cpp.xq	2014-02-10 00:46:59 +0000
@@ -55,9 +55,9 @@
   $gen:indent,'theIterator->accept(*this);',$gen:newline,
   $gen:indent,'thePrinter.stop();',$gen:newline,'}',$gen:newline,$gen:newline,
   'void PrinterVisitor::printCommons(const PlanIterator* aIter, int theId) {',$gen:newline,
-  $gen:indent,'if (! Properties::instance()->noTreeIds()) {',$gen:newline,
+  $gen:indent,'if (! Properties::instance().getNoTreeIDs()) {',$gen:newline,
   gen:indent(2),'std::stringstream lStream;',$gen:newline,
-  gen:indent(2),'if (Properties::instance()->stableIteratorIds())',$gen:newline,
+  gen:indent(2),'if (Properties::instance().getStableIteratorIDs())',$gen:newline,
   gen:indent(3),'lStream << theId;',$gen:newline,
   gen:indent(2),'else',$gen:newline,
   gen:indent(3),'lStream << aIter;',$gen:newline,
@@ -101,7 +101,7 @@
     $gen:newline, $gen:newline,
     '#include "runtime/visitors/iterprinter.h"',
     $gen:newline, $gen:newline,
-    '#include "system/properties.h"',
+    '#include &lt;zorba/properties.h&gt;',
     $gen:newline, $gen:newline,
     '#include "util/string_util.h"',
     $gen:newline, $gen:newline,
@@ -151,12 +151,17 @@
 {
   variable $temp := local:get-files($files);
 
-  string-join((gen:add-copyright(),
-               local:create-includes($files),
-               'namespace zorba{',
-               local:create-class(),
-               $temp,
-               '}'),
-              string-join(($gen:newline,$gen:newline),''))
+  string-join(
+    (
+      gen:add-copyright(),
+      local:create-includes($files),
+      'namespace zorba{',
+      local:create-class(),
+      $temp,
+      '}'
+    ),
+    concat( $gen:newline, $gen:newline )
+  )
 }
 
+(: vim:set et sw=2 ts=2: :)

=== modified file 'src/runtime/visitors/pregenerated/printer_visitor.cpp'
--- src/runtime/visitors/pregenerated/printer_visitor.cpp	2014-01-31 01:39:38 +0000
+++ src/runtime/visitors/pregenerated/printer_visitor.cpp	2014-02-10 00:46:59 +0000
@@ -32,7 +32,7 @@
 
 #include "runtime/visitors/iterprinter.h"
 
-#include "system/properties.h"
+#include <zorba/properties.h>
 
 #include "util/string_util.h"
 
@@ -86,9 +86,9 @@
 }
 
 void PrinterVisitor::printCommons(const PlanIterator* aIter, int theId) {
-  if (! Properties::instance()->noTreeIds()) {
+  if (! Properties::instance().getNoTreeIDs()) {
     std::stringstream lStream;
-    if (Properties::instance()->stableIteratorIds())
+    if (Properties::instance().getStableIteratorIDs())
       lStream << theId;
     else
       lStream << aIter;

=== modified file 'src/runtime/visitors/printer_visitor_impl.cpp'
--- src/runtime/visitors/printer_visitor_impl.cpp	2013-10-08 00:48:47 +0000
+++ src/runtime/visitors/printer_visitor_impl.cpp	2014-02-10 00:46:59 +0000
@@ -19,7 +19,7 @@
 
 #include "types/typeops.h"
 
-#include "system/properties.h"
+#include <zorba/properties.h>
 
 #include "runtime/core/item_iterator.h"
 #include "runtime/core/var_iterators.h"
@@ -743,7 +743,7 @@
       str << " ";
   }
 
-  if (! Properties::instance()->noTreeIds())
+  if (! Properties::instance().getNoTreeIDs())
     thePrinter.addAttribute("referenced-by", str.str());
 
   thePrinter.endBeginVisit(theId);
@@ -780,7 +780,7 @@
       str << " ";
   }
 
-  if (! Properties::instance()->noTreeIds())
+  if (! Properties::instance().getNoTreeIDs())
     thePrinter.addAttribute("referenced-by", str.str());
 
   if (!posRefs.empty())
@@ -795,7 +795,7 @@
         str << " ";
     }
 
-    if (! Properties::instance()->noTreeIds())
+    if (! Properties::instance().getNoTreeIDs())
       thePrinter.addAttribute("pos-referenced-by", str.str());
   }
 
@@ -837,7 +837,7 @@
 
   str1 << inputVar->getVarName()->getStringValue() << " : ";
 
-  if (! Properties::instance()->noTreeIds())
+  if (! Properties::instance().getNoTreeIDs())
     str1 << inputVar.getp();
 
   csize numRefs = varRefs.size();
@@ -849,7 +849,7 @@
   }
 
   thePrinter.addAttribute("inputVar", str1.str());
-  if (! Properties::instance()->noTreeIds())
+  if (! Properties::instance().getNoTreeIDs())
     thePrinter.addAttribute("referenced-by", str2.str());
 
   thePrinter.endBeginVisit(theId);
@@ -874,7 +874,7 @@
 
   str1 << inputVar->getVarName()->getStringValue() << " : ";
 
-  if (! Properties::instance()->noTreeIds())
+  if (! Properties::instance().getNoTreeIDs())
     str1 << inputVar.getp();
 
   csize numRefs = varRefs.size();
@@ -886,7 +886,7 @@
   }
 
   thePrinter.addAttribute("inputVar", str1.str());
-  if (! Properties::instance()->noTreeIds())
+  if (! Properties::instance().getNoTreeIDs())
     thePrinter.addAttribute("referenced-by", str2.str());
 
   thePrinter.endBeginVisit(theId);
@@ -930,7 +930,7 @@
 
     str1 << iter->getVarName()->getStringValue() << " : ";
 
-    if (! Properties::instance()->noTreeIds())
+    if (! Properties::instance().getNoTreeIDs())
       str1 <<  iter;
   }
   else
@@ -941,7 +941,7 @@
 
     str1 << iter->getVarName()->getStringValue() << " : " ;
 
-    if (! Properties::instance()->noTreeIds())
+    if (! Properties::instance().getNoTreeIDs())
       str1 << iter;
   }
 
@@ -954,7 +954,7 @@
   }
 
   thePrinter.addAttribute("inputVar", str1.str());
-  if (! Properties::instance()->noTreeIds())
+  if (! Properties::instance().getNoTreeIDs())
     thePrinter.addAttribute("referenced-by", str2.str());
 
   thePrinter.endBeginVisit(theId);
@@ -1024,7 +1024,7 @@
       str << " ";
   }
 
-  if (! Properties::instance()->noTreeIds())
+  if (! Properties::instance().getNoTreeIDs())
     thePrinter.addAttribute("referenced-by", str.str());
 
   thePrinter.endBeginVisit(theId);
@@ -1052,7 +1052,7 @@
       str << " ";
   }
 
-  if (! Properties::instance()->noTreeIds())
+  if (! Properties::instance().getNoTreeIDs())
     thePrinter.addAttribute("referenced-by", str.str());
 
   thePrinter.endBeginVisit(theId);
@@ -1084,7 +1084,7 @@
       str << " ";
   }
 
-  if (! Properties::instance()->noTreeIds())
+  if (! Properties::instance().getNoTreeIDs())
     thePrinter.addAttribute("referenced-by", str.str());
 
   thePrinter.endBeginVisit(theId);
@@ -1116,7 +1116,7 @@
       str << " ";
   }
 
-  if (! Properties::instance()->noTreeIds())
+  if (! Properties::instance().getNoTreeIDs())
     thePrinter.addAttribute("referenced-by", str.str());
 
   thePrinter.endBeginVisit(theId);

=== modified file 'src/store/naive/CMakeLists.txt'
--- src/store/naive/CMakeLists.txt	2013-06-15 02:57:08 +0000
+++ src/store/naive/CMakeLists.txt	2014-02-10 00:46:59 +0000
@@ -32,7 +32,6 @@
     node_updates.cpp
     nsbindings.cpp
     ordpath.cpp
-    properties.cpp
     pul_primitive_factory.cpp
     pul_primitives.cpp
     qname_pool.cpp

=== removed file 'src/store/naive/properties.cpp'
--- src/store/naive/properties.cpp	2013-02-07 17:24:36 +0000
+++ src/store/naive/properties.cpp	1970-01-01 00:00:00 +0000
@@ -1,115 +0,0 @@
-/*
- * Copyright 2006-2008 The FLWOR Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "stdafx.h"
-
-#include <fstream>
-#include <iostream>
-#include <sstream>
-#include <cstdlib>
-
-#include "properties.h"
-
-
-#define CONFIG_FOLDER "zorba"
-#define CONFIG_FILE "simplestore.cfg"
-
-namespace zorba { namespace store {
-
-Properties* Properties::instance()
-{
-  static Properties lProperties;
-  return &lProperties;
-}
-
-  
-bool Properties::getOSConfigFolder(std::string& aFolderURI) 
-{
-  char *pValue;
-    
-#ifdef __unix__
-  pValue = getenv("HOME"); 
-#elif defined WINCE
-  pValue = NULL;
-#elif defined WIN32
-  size_t len;
-  _dupenv_s( &pValue, &len, "APPDATA" );
-#else
-  pValue = getenv( "APPDATA" );
-#endif
-  if (pValue == 0)
-    return false;
-
-  aFolderURI = pValue;
-    
-  return true;
-}
-  
-
-bool Properties::getOSConfigFile(std::string& aFileURI) 
-{
-#if defined (WIN32) || defined (UNIX)
-#define DOT_FILE "."
-#else
-#define DOT_FILE ""
-#endif
-
-  std::string lFolder;
-  std::stringstream lStream;
-    
-  if (getOSConfigFolder(lFolder)) 
-  {
-    // $HOME/.zorba/simplestore.cfg
-#ifdef __win32__
-    lStream << lFolder << "\\" << DOT_FILE CONFIG_FOLDER << "\\" << CONFIG_FILE;
-# else
-    lStream << lFolder << "/" << DOT_FILE CONFIG_FOLDER << "/" << CONFIG_FILE;
-#endif
-    aFileURI = lStream.str();
-    return true;
-  }
-  return false;
-}
-
-  
-bool Properties::loadProps(int argc, char *argv[])
-{
-    std::string cfgfile;
-    getOSConfigFile (cfgfile);
-    std::string result = load_all (cfgfile.c_str (), "ZORBA_STORE_CFG_", argc, (const char **) argv);
-    if (result.empty ()) result = check_args ();
-    if (result == "!HELP") {
-      std::cout << "Allowed options:\n\n";
-      std::cout << get_help_msg ();
-      return false;
-    } else if (result.empty ()) {
-      return true;
-    } else if (result [0] != '!') {
-      std::cout << "Error: " << result << std::endl;
-      return false;
-    } else {
-      return false;
-    }
- }
-
-
-  bool Properties::load(int argc, char *argv[]) {
-    Properties* lProps = Properties::instance();
-    return lProps->loadProps(argc, argv);
-  }
-
-}
-} /* namespace zorba */
-/* vim:set et sw=2 ts=2: */

=== removed file 'src/store/naive/properties.h'
--- src/store/naive/properties.h	2013-02-07 17:24:36 +0000
+++ src/store/naive/properties.h	1970-01-01 00:00:00 +0000
@@ -1,74 +0,0 @@
-/*
- * Copyright 2006-2008 The FLWOR Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef ZORBA_STORE_PROPERTIES_H
-#define ZORBA_STORE_PROPERTIES_H
-
-#include <string>
-#include <fstream>
-#include <vector>
-
-#include "store_properties.h"
-
-namespace zorba { namespace store {
-
-class Properties : public StoreProperties
-{
-private:
-  /**
-   * Gets the Operation System folger where the properties of the current 
-   * user are saved.
-   * Linux, Mac: /home/username
-   * Windows Vista: C:\Users\username\Application Data
-   * Windows XP: C:\Documents and Settings\username\Application Data
-   * 
-   * @param aFolderURI 
-   * @return true, if found
-   */
-  bool 
-  getOSConfigFolder(std::string& aFolderURI);
-      
-  /**
-   * Gets the location of the zorba property in the operation system.
-   * 
-   * Linux, Mac: /home/username/.zorba/simplestore.cfg
-   * Windows Vista: C:\Users\username\Application Data\zorba\simplestore.cfg
-   * Windows XP: C:\Documents and Settings\username\Application Data\zorba\simplestore.cfg
-   * 
-   * @param aFileURI 
-   * @return true, if found
-   */
-  bool 
-  getOSConfigFile(std::string& aFileURI);
-    
-  bool loadProps(int argc, char *argv[]);
-    
-public:
-  static Properties* instance();
-      
-  static bool load(int argc, char *argv[]);
-      
-};
-
-}
-} /* namespace zorba */
-#endif
-
-/*
- * Local variables:
- * mode: c++
- * End:
- */
-/* vim:set et sw=2 ts=2: */

=== modified file 'src/store/naive/store.cpp'
--- src/store/naive/store.cpp	2013-09-26 07:38:44 +0000
+++ src/store/naive/store.cpp	2014-02-10 00:46:59 +0000
@@ -32,7 +32,6 @@
 
 #include "store/api/pul.h"
 
-#include "properties.h"
 #include "string_pool.h"
 #include "simple_store.h"
 #include "simple_temp_seq.h"
@@ -143,8 +142,6 @@
     LIBXML_TEST_VERSION
     xmlInitParser();
 
-    store::Properties::load(0, NULL);
-
     theNamespacePool = new StringPool(NAMESPACE_POOL_SIZE);
 
     theNamespacePool->insertc("", theEmptyNs);
@@ -166,8 +163,6 @@
     
     theTreeIdGeneratorFactory = createTreeIdGeneratorFactory();
 
-    theTraceLevel = store::Properties::instance()->storeTraceLevel();
-
     theCollections = createCollectionSet();
 
     StoreManagerImpl::theStore = this;
@@ -376,18 +371,18 @@
     return new FragmentXmlLoader(theItemFactory,
                                  aXQueryDiagnostics,
                                  loadProperties,
-                                 store::Properties::instance()->buildDataguide());
+                                 false);
 
   else if (loadProperties.getDTDValidate())
     return new DtdXmlLoader(theItemFactory,
                             aXQueryDiagnostics,
                             loadProperties,
-                            store::Properties::instance()->buildDataguide());
+                            false);
   else
     return new FastXmlLoader(theItemFactory,
                              aXQueryDiagnostics,
                              loadProperties,
-                             store::Properties::instance()->buildDataguide());
+                             false);
 }
 
 

=== removed file 'src/store/naive/store_properties.h'
--- src/store/naive/store_properties.h	2013-02-07 17:24:36 +0000
+++ src/store/naive/store_properties.h	1970-01-01 00:00:00 +0000
@@ -1,112 +0,0 @@
-/*
- * Copyright 2006-2008 The FLWOR Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/* vim:set et sw=2 ts=2: */
-
-#include <string>
-#include <sstream>
-#include <zorba/config.h>
-#include <zorba/properties_base.h>
-#include <cstring>
-
-#ifndef ZORBA_STORE_STOREPROPERTIES
-#define ZORBA_STORE_STOREPROPERTIES
-namespace zorba 
-{ 
-namespace store 
-{
-
- 
-class StoreProperties : public ::zorba::PropertiesBase 
-{
-protected:
-  const char** get_all_options() const 
-  {
-    static const char *result [] = { "--build-dataguide", "--store-trace-level", NULL };
-    return result;
-  }
-
-  bool theBuildDataguide;
-  long theStoreTraceLevel;
-
-  void initialize () 
-  {
-    theBuildDataguide = false;
-    theStoreTraceLevel = 0;
-  }
-public:
-  const bool& buildDataguide() const { return theBuildDataguide; }
-  const long& storeTraceLevel() const { return theStoreTraceLevel; }
-
-  std::string load_argv(int argc, const char **argv) 
-  {
-    if (argv == NULL) return "";
-
-    std::string result;
-    for (++argv; *argv != NULL; ++argv) 
-    {
-      if (strcmp (*argv, "--help") == 0 || strcmp (*argv, "-h") == 0)
-        return "!HELP";
-      else if (strcmp (*argv, "--version") == 0)
-        return "!VER";
-      else if (strcmp (*argv, "--build-dataguide") == 0) 
-      {
-        theBuildDataguide = true;
-      }
-      else if (strcmp (*argv, "--store-trace-level") == 0) 
-      {
-        int d = 2;
-        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-        if (*argv == NULL) { result = "No value given for --store-trace-level option"; break; }        init_val (*argv, theStoreTraceLevel, d);
-      }
-      else if (strcmp (*argv, "--") == 0) 
-      {
-        copy_args (++argv);
-        break;
-      }
-      else if ((*argv) [0] == '-') 
-      {
-        result = "unknown command line option "; result += *argv; break; 
-      }
-      else
-      {
-        copy_args (argv);
-        break;
-      }
-    }
-
-    return result;
-  }
-
-  const char* get_help_msg () const 
-  {
-    return
-"--build-dataguide\nbuild-dataguide (true/false)\n\n"
-"--store-trace-level\nstore trace level (<= 0 : no tracing)\n\n"
-;
-  }
-
-  static const StoreProperties* instance() 
-  {
-    static StoreProperties result;
-    return &result;
-  }
-
-  StoreProperties() { initialize(); }
-};
-
-} }   // namespaces
-
-#endif // ZORBA_STORE_STOREPROPERTIES

=== removed file 'src/store/naive/store_properties.txt'
--- src/store/naive/store_properties.txt	2013-02-07 17:24:36 +0000
+++ src/store/naive/store_properties.txt	1970-01-01 00:00:00 +0000
@@ -1,2 +0,0 @@
-    ("build-dataguide", "build-dataguide (true/false)")
-    ("store-trace-level", po::value<long>()->default_value (0), "store trace level (<= 0 : no tracing)")

=== modified file 'src/system/CMakeLists.txt'
--- src/system/CMakeLists.txt	2014-01-24 05:19:21 +0000
+++ src/system/CMakeLists.txt	2014-02-10 00:46:59 +0000
@@ -1,4 +1,4 @@
-# Copyright 2006-2008 The FLWOR Foundation.
+# Copyright 2006-2014 The FLWOR Foundation.
 # 
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -11,8 +11,9 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
+
 SET(SYSTEM_SRCS
     globalenv.cpp
-    properties.cpp
-    zorba_properties.cpp
 )
+
+# vim:set et sw=2 ts=2:

=== removed file 'src/system/properties.cpp'
--- src/system/properties.cpp	2013-02-07 17:24:36 +0000
+++ src/system/properties.cpp	1970-01-01 00:00:00 +0000
@@ -1,182 +0,0 @@
-/*
- * Copyright 2006-2008 The FLWOR Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "stdafx.h"
-
-#include <fstream>
-#include <iostream>
-#include <sstream>
-#include <cctype>
-#include <cstdlib>
-
-#include "system/properties.h"
-
-#include "zorba/config.h"
-#include "zorba/zorba.h"
-
-#define CONFIG_FOLDER "zorba"
-#define CONFIG_FILE "properties.cfg"
-
-namespace zorba
-{
-
-Properties* Properties::instance() 
-{
-  static Properties lProperties;
-  return &lProperties;
-}
-
-
-bool Properties::load(int argc, char *argv[]) 
-{
-  Properties* lProps = Properties::instance();
-  return lProps->loadProps(argc, argv);
-}
-
-
-bool Properties::loadProps(int argc, char *argv[]) 
-{
-  std::string cfgfile;
-  getOSConfigFile(cfgfile);
-
-  std::string result = load_all(cfgfile.c_str(),
-                                "ZORBA_CFG_",
-                                argc,
-                                (const char **) argv);
-
-  if (! debugFile().empty()) 
-  {
-    debug_stream_ptr.reset(new std::ofstream(debugFile().c_str()));
-    debug_stream = debug_stream_ptr.get();
-  }
-
-  if (result.empty())
-    result = check_args();
-
-  if (result == "!HELP") 
-  {
-    std::cout << "Allowed options:\n\n";
-    std::cout << get_help_msg();
-    return false;
-  }
-  else if (result == "!VER") 
-  {
-    std::cout << "Zorba XQuery Engine, Version: " 
-              << zorba::Zorba::version() << std::endl;
-    return false;
-  }
-  else if (result.empty()) 
-  {
-    return true;
-  }
-  else if (result[0] != '!') 
-  {
-    std::cout << "Error: " << result << std::endl;
-    return false;
-  }
-  else
-  {
-    return false;
-  }
-}
-  
-
-std::vector<std::pair<std::string,std::string> > Properties::getExternalVars() 
-{
-  std::vector<std::pair<std::string,std::string> > lResult;
-  std::vector<std::string>::const_iterator lEnd = theExternalVar.end();
-
-  for (std::vector<std::string>::const_iterator lIter = theExternalVar.begin();
-       lIter != lEnd;
-       ++lIter) 
-  {
-    std::string lStr = *lIter;
-    std::string::size_type lPos = lStr.find_first_of("=");
-    std::string lVarName = lStr.substr(0, lPos);
-    std::string lValue = lStr.substr(lPos + 1);
-    lResult.push_back(std::pair<std::string,std::string>(lVarName, lValue));
-  }
-  return lResult;
-}
-
-  
-std::vector<std::pair<std::string,std::string> > Properties::getSerializerParameters() 
-{
-  std::vector<std::pair<std::string,std::string> > lResult;
-  std::vector<std::string>::const_iterator lEnd = theSerializerParam.end();
-
-  for (std::vector<std::string>::const_iterator lIter = theSerializerParam.begin();
-       lIter != lEnd;
-       ++lIter) 
-  {
-    std::string lStr = *lIter;
-    std::string::size_type lPos = lStr.find_first_of("=");
-    std::string lVarName = lStr.substr(0, lPos);
-    std::string lValue = lStr.substr(lPos + 1);
-    lResult.push_back(std::pair<std::string,std::string>(lVarName, lValue));
-  }
-  return lResult;
-}
-  
-
-bool Properties::getOSConfigFile(std::string& aFileURI) 
-{
-  std::string lFolder;
-  std::stringstream lStream;  
-    
-  if (getOSConfigFolder(lFolder)) 
-  {
-#if defined (WIN32) || defined (UNIX)
-#define DOT_FILE "."
-#else
-#define DOT_FILE ""
-#endif
-
-#ifdef __win32__
-    lStream << lFolder << "\\" << DOT_FILE CONFIG_FOLDER << "\\" << CONFIG_FILE;
-# else
-    lStream << lFolder << "/" << DOT_FILE CONFIG_FOLDER << "/" << CONFIG_FILE;
-#endif
-    aFileURI = lStream.str();
-    return true;
-  }
-  return false;
-}
-
-
-bool Properties::getOSConfigFolder(std::string& aFolderURI) 
-{
-  char *pValue;
-    
-#ifdef __unix__
-  pValue = getenv("HOME"); 
-#elif defined WINCE
-  pValue = NULL;
-#elif defined WIN32
-  size_t len;
-  _dupenv_s( &pValue, &len, "APPDATA" );
-#else
-  pValue = getenv( "APPDATA" );
-#endif
-  if (pValue == 0)
-    return false;
-  aFolderURI = pValue;
-    
-  return true;
-}
-
-  
-} /* namespace zorba */
-/* vim:set et sw=2 ts=2: */

=== removed file 'src/system/properties.h'
--- src/system/properties.h	2013-08-14 08:46:44 +0000
+++ src/system/properties.h	1970-01-01 00:00:00 +0000
@@ -1,126 +0,0 @@
-/*
- * Copyright 2006-2008 The FLWOR Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-#ifndef ZORBA_PROPERTIES_H
-#define ZORBA_PROPERTIES_H
-
-#include <string>
-#include <fstream>
-#include <vector>
-
-#include <zorba/config.h>
-#include <zorba/internal/unique_ptr.h>
-#include "system/zorba_properties.h"
-
-namespace zorba {
-
-
-/***************************************************************************//**
-
-********************************************************************************/
-class ZORBA_DLL_PUBLIC Properties : public ZorbaProperties 
-{
- protected:
-  std::ostream                 *debug_stream;
-  std::unique_ptr<std::ostream>   debug_stream_ptr;
-    
- public:
-  static Properties* instance();
-
-  static bool load(int argc, char **argv);
-
- public:
-  Properties() : debug_stream (& std::cout) {}
-
-  bool loadProps(int argc, char **argv);
-
-  std::vector<std::pair<std::string,std::string> > getExternalVars();
-
-  std::vector<std::pair<std::string,std::string> > getSerializerParameters();
-
-  bool inlineQuery() const { return ! query().empty (); }
-
-  std::string queryFile() const { return getPositionalArgs().at(0); }
-
-  std::string check_args() { return ""; }
-
-  bool hasSingleQuery() 
-  {
-    size_t sz = getPositionalArgs().size();
-    return ((inlineQuery () && sz == 0) || (! inlineQuery () && sz == 1));
-  }
-
-  void setDebugMode(bool mode){ theDebug = mode; }
-
-  std::ostream& debug_out() { return *debug_stream; }
-
-  /**
-    * Before the JVM is started this will return the classpath set by
-    * command line option, the CLASSPATH environment variable and in Zorba
-    * config file.
-    *
-    * After the JVM is started this will contain in addition the paths to jars
-    * used by modules that make use of the JVM.
-    */
-  void getJVMClassPath(std::string & jvmClasspath)
-  { jvmClasspath = theCLASSPATH ; }
-
-  /**
-    * This method should be used to set additional JVM classpath for modules
-    * that make use of JVM. This will overide the classpath set by CLASSPATH
-    * environment variable or Zorba config file.
-    *
-    * Once the JVM is started this method doesn't have any effect.
-    */
-  void setJVMClassPath(const std::string & jvmClasspath)
-  { theCLASSPATH = jvmClasspath; }
-
- protected:
-  /**
-   * Gets the Operation System folder where the properties of the current 
-   * user are saved.
-   * Linux, Mac: /home/username
-   * Windows Vista: C:\Users\username\Application Data
-   * Windows XP: C:\Documents and Settings\username\Application Data
-   * 
-   * @param aFolderURI 
-   * @return true, if found
-   */
-  bool getOSConfigFolder(std::string& aFolderURI);
-      
-  /**
-   * Gets the location of the zorba property in the operation system.
-   * 
-   * Linux, Mac: /home/username/.zorba/properties.cfg
-   * Windows Vista: C:\Users\username\Application Data\zorba\properties.cfg
-   * Windows XP: C:\Documents and Settings\username\Application Data\zorba\properties.cfg
-   * 
-   * @param aFileURI 
-   * @return true, if found
-   */
-  bool getOSConfigFile(std::string& aFileURI);
-};
-
-
-} /* namespace zorba */
-#endif
-
-/*
- * Local variables:
- * mode: c++
- * End:
- */
-/* vim:set et sw=2 ts=2: */

=== removed file 'src/system/zorba_properties.h'
--- src/system/zorba_properties.h	2014-01-24 05:19:21 +0000
+++ src/system/zorba_properties.h	1970-01-01 00:00:00 +0000
@@ -1,145 +0,0 @@
-/*
- * Copyright 2006-2008 The FLWOR Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ZORBA_ZORBAPROPERTIES
-#define ZORBA_ZORBAPROPERTIES
-
-// standard
-#include <string>
-
-// Zorba
-#include <zorba/config.h>
-#include <zorba/properties_base.h>
-
-namespace zorba {
-
-///////////////////////////////////////////////////////////////////////////////
-
-class ZORBA_DLL_PUBLIC ZorbaProperties : public ::zorba::PropertiesGlobal {
-public:
-  bool abort() const { return theAbort; }
-  const std::string& CLASSPATH() const { return theCLASSPATH; }
-  bool compileOnly() const { return theCompileOnly; }
-  bool debug() const { return theDebug; }
-  const std::string& debugFile() const { return theDebugFile; }
-  const std::string& dotPlanFile() const { return theDotPlanFile; }
-  bool dumpLib() const { return theDumpLib; }
-  const std::vector<std::string>& externalVar() const { return theExternalVar; }
-  bool forceGflwor() const { return theForceGflwor; }
-  bool inferJoins() const { return theInferJoins; }
-  bool inlineUdf() const { return theInlineUdf; }
-  bool iterPlanTest() const { return theIterPlanTest; }
-  bool jsoniqParser() const { return theJsoniqParser; }
-  bool libModule() const { return theLibModule; }
-  bool loopHoisting() const { return theLoopHoisting; }
-  uint32_t maxUdfCallDepth() const { return theMaxUdfCallDepth; }
-  bool noCopyOptim() const { return theNoCopyOptim; }
-  bool noTreeIds() const { return theNoTreeIds; }
-  int optimizer() const { return theOptimizer; }
-  bool printAst() const { return thePrintAst; }
-  bool printIntermediateOpt() const { return thePrintIntermediateOpt; }
-  bool printItemFlow() const { return thePrintItemFlow; }
-  bool printIteratorTree() const { return thePrintIteratorTree; }
-  bool printLocations() const { return thePrintLocations; }
-  bool printNormalized() const { return thePrintNormalized; }
-  bool printOptimized() const { return thePrintOptimized; }
-  bool printQuery() const { return thePrintQuery; }
-  bool printStaticTypes() const { return thePrintStaticTypes; }
-  bool printTime() const { return thePrintTime; }
-  bool printTranslated() const { return thePrintTranslated; }
-  bool printXqdoc() const { return thePrintXqdoc; }
-  const std::string& query() const { return theQuery; }
-  bool reorderGlobals() const { return theReorderGlobals; }
-  const std::string& resultFile() const { return theResultFile; }
-  int serializeOnlyQuery() const { return theSerializeOnlyQuery; }
-  const std::vector<std::string>& serializerParam() const { return theSerializerParam; }
-  bool specializeCmp() const { return theSpecializeCmp; }
-  bool specializeNum() const { return theSpecializeNum; }
-  bool stableIteratorIds() const { return theStableIteratorIds; }
-  bool testPlanSerialization() const { return theTestPlanSerialization; }
-  bool traceCodegen() const { return theTraceCodegen; }
-  bool traceFulltext() const { return theTraceFulltext; }
-  bool traceParsing() const { return theTraceParsing; }
-  bool traceScanning() const { return theTraceScanning; }
-  bool traceTranslator() const { return theTraceTranslator; }
-  int tz() const { return theTz; }
-  bool useIndexes() const { return theUseIndexes; }
-  bool useSerializer() const { return theUseSerializer; }
-
-  char const* get_help_msg() const;
-  static const ZorbaProperties* instance();
-  std::string load_argv( int argc, char const **argv );
-
-protected:
-  ZorbaProperties();
-
-  const char** get_all_options() const;
-
-  bool theAbort;
-  std::string theCLASSPATH;
-  bool theCompileOnly;
-  bool theDebug;
-  std::string theDebugFile;
-  std::string theDotPlanFile;
-  bool theDumpLib;
-  std::vector<std::string> theExternalVar;
-  bool theForceGflwor;
-  bool theInferJoins;
-  bool theInlineUdf;
-  bool theIterPlanTest;
-  bool theJsoniqParser;
-  bool theLibModule;
-  bool theLoopHoisting;
-  uint32_t theMaxUdfCallDepth;
-  bool theNoCopyOptim;
-  bool theNoTreeIds;
-  int theOptimizer;
-  bool thePrintAst;
-  bool thePrintIntermediateOpt;
-  bool thePrintItemFlow;
-  bool thePrintIteratorTree;
-  bool thePrintLocations;
-  bool thePrintNormalized;
-  bool thePrintOptimized;
-  bool thePrintQuery;
-  bool thePrintStaticTypes;
-  bool thePrintTime;
-  bool thePrintTranslated;
-  bool thePrintXqdoc;
-  std::string theQuery;
-  std::string theResultFile;
-  bool theReorderGlobals;
-  int theSerializeOnlyQuery;
-  std::vector<std::string> theSerializerParam;
-  bool theSpecializeCmp;
-  bool theSpecializeNum;
-  bool theStableIteratorIds;
-  bool theTestPlanSerialization;
-  bool theTraceCodegen;
-  bool theTraceFulltext;
-  bool theTraceParsing;
-  bool theTraceScanning;
-  bool theTraceTranslator;
-  int theTz;
-  bool theUseIndexes;
-  bool theUseSerializer;
-};
-
-///////////////////////////////////////////////////////////////////////////////
-
-} // namespace zorba
-#endif /* ZORBA_ZORBAPROPERTIES */
-/* vim:set et sw=2 ts=2: */

=== removed file 'src/system/zorba_properties.txt'
--- src/system/zorba_properties.txt	2014-01-27 23:42:57 +0000
+++ src/system/zorba_properties.txt	1970-01-01 00:00:00 +0000
@@ -1,49 +0,0 @@
-      ("abort", "abort when fatal error happens")
-      ("CLASSPATH", po::value<std::string>(), "JVM classpath to be used by modules using Java implementations")
-      ("compile-only", "only compile (don't execute)")
-      ("debug", "compile the query in debug mode")
-      ("debug-file", po::value<std::string>(), "log file for debugging information")
-      ("dot-plan-file", po::value<std::string>(), "generate the dot iterator plan")
-      ("dump-lib", "dump function library")
-      ("external-var,x", po::value<std::vector<std::string> >(), "external variables (e.g. -x x=file1.xml -x y:=strValue)")
-      ("force-gflwor", "force compiler to generate GFLWOR iterators")
-      ("infer-joins", po::value<bool>()->default_value (true), "infer joins (1=enabled (default), 0=off)")
-      ("inline-udf", po::value<bool> ()->default_value (true), "inline functions (1=enabled (default), 0=off)")
-      ("iter-plan-test", "run as iterator plan test")
-      ("jsoniq,j", "use the new alternative jsoniq parser")
-      ("lib-module", "treat the query as a library module. If this is set --compile-only option is also set to true")
-      ("loop-hoisting", po::value<bool>()->default_value (true), "hoist expressions out of loops (1=enabled (default), 0=off)")
-      ("max-udf-call-depth", po::value<uint32_t>()->default_value(1024), "maximum stack depth of udf function calls")
-      ("no-copy-optim", po::value<bool>()->default_value(true), "no copy optim (1=enabled (default), 0=off)")
-      ("no-tree-ids", "suppress ids and locations from compiler tree dumps")
-      ("optimizer,O", po::value<int> ()->default_value (1), "optimization level (0, 1 or 2 - 1 is default)")
-      ("plan", "test plan serialization, i.e. save the plan, load it back and then execute it")
-      ("print-ast,a", "print the parse tree")
-      ("print-intermediate-opt", "print intermediate optimizations")
-      ("print-item-flow,f", "show items produced by all iterators")
-      ("print-iterator-tree,i", "print the iterator tree")
-      ("print-locations", "print parser locations for compiler expressions")
-      ("print-normalized,n", "print the translated expression tree")
-      ("print-optimized,P", "print the optimized expression tree")
-      ("print-query,q", "print the query")
-      ("print-static-types", po::value<bool> ()->default_value (true), "print static type inference")
-      ("print-time,t", "print the execution time")
-      ("print-translated", "print the normalized expression tree")
-      ("print-xqdoc", "create output for XQDoc")
-      ("query,e", po::value<std::string>(), "execute inline query")
-      ("reorder-globals", po::value<bool> ()->default_value (true), "reorder global variables (1=enabled (default), 0=off)")
-      ("result-file,o", po::value<std::string>(), "result file")
-      ("serialize-only-query", po::value<int>()->default_value(-1), "serialize-only query (1=true, 0=false, -1 unknown (default))")
-      ("serializer-param,z", po::value<std::vector<std::string> >(), "serializer parameters (see http://www.w3.org/TR/xslt-xquery-serialization/#serparam, e.g. -z method=xhtml, -z doctype-system='DTD/xhtml1-strict.dtd', -z indent=yes)")
-      ("specialize-cmp", po::value<bool> ()->default_value (true), "specialize generic comparisons (1=enabled (default), 0=off)")
-      ("specialize-num", po::value<bool> ()->default_value (true), "specialize numerics (1=enabled (default), 0=off)")
-      ("stable-iterator-ids", "print the iterator plan with stable ids")
-#ifndef NDEBUG
-      ("trace-codegen,c", "trace the codegenerator")
-      ("trace-fulltext", "trace full-text evaluation")
-      ("trace-translator,l", "trace the translator")
-#endif
-      ("trace-parsing,p", "trace parsing")
-      ("trace-scanning,s", "trace scanning")
-      ("tz", po::value<int>(), "implicit time zone (in minutes)")
-      ("use-serializer,r", "use serializer")

=== modified file 'src/unit_tests/test_stemmer.cpp'
--- src/unit_tests/test_stemmer.cpp	2013-08-05 11:24:53 +0000
+++ src/unit_tests/test_stemmer.cpp	2014-02-10 00:46:59 +0000
@@ -18,13 +18,12 @@
 #include <cassert>
 #include <iostream>
 
+#include <zorba/properties.h>
 #include <zorba/stemmer.h>
 #include <zorba/store_manager.h>
 #include <zorba/zorba.h>
 #include <zorba/zorba_exception.h>
 
-#include "system/properties.h"
-
 using namespace std;
 using namespace zorba;
 using namespace zorba::locale;
@@ -89,8 +88,6 @@
   int result = 0;
 
   try {
-    Properties::load( 0, NULL );
-
     char const *const query_src =
       "let $x := <msg>foobar</msg>"
       "return $x contains text \"foo\" using stemming";

=== modified file 'src/unit_tests/test_thesaurus.cpp'
--- src/unit_tests/test_thesaurus.cpp	2013-02-07 17:24:36 +0000
+++ src/unit_tests/test_thesaurus.cpp	2014-02-10 00:46:59 +0000
@@ -20,13 +20,12 @@
 #include <list>
 #include <map>
 
+#include <zorba/properties.h>
+#include <zorba/store_manager.h>
 #include <zorba/thesaurus.h>
-#include <zorba/store_manager.h>
 #include <zorba/zorba.h>
 #include <zorba/zorba_exception.h>
 
-#include "system/properties.h"
-
 using namespace std;
 using namespace zorba;
 using namespace zorba::locale;
@@ -156,8 +155,6 @@
   int result = 0;
 
   try {
-    Properties::load( 0, NULL );
-
     char const *const query_src =
       "let $x := <msg>foobar</msg> \n"
       "return $x contains text \"foo\" \n"

=== modified file 'src/unit_tests/test_tokenizer.cpp'
--- src/unit_tests/test_tokenizer.cpp	2013-08-05 11:24:53 +0000
+++ src/unit_tests/test_tokenizer.cpp	2014-02-10 00:46:59 +0000
@@ -24,6 +24,7 @@
 #include <iostream>
 
 #include <zorba/diagnostic_list.h>
+#include <zorba/properties.h>
 #include <zorba/store_consts.h>
 #include <zorba/store_manager.h>
 #include <zorba/tokenizer.h>
@@ -31,8 +32,6 @@
 #include <zorba/zorba.h>
 #include <zorba/zorba_exception.h>
 
-#include "system/properties.h"
-
 using namespace std;
 using namespace zorba;
 using namespace zorba::locale;
@@ -371,8 +370,6 @@
   Zorba *const zorba = Zorba::getInstance( zstore );
 
   try {
-    Properties::load( 0, NULL );
-
     char const *const query_src =
       "let $x :="
       "  <content>"

=== modified file 'src/util/fs_util.cpp'
--- src/util/fs_util.cpp	2013-12-04 14:28:07 +0000
+++ src/util/fs_util.cpp	2014-02-10 00:46:59 +0000
@@ -15,10 +15,10 @@
  */
 #include "stdafx.h"
 
+# include <cstdlib>                     /* for getenv(3), _dupenv_s() */
 #ifndef WIN32
 # include <climits>                     /* for PATH_MAX */
 # include <cstdio>
-# include <cstdlib>                     /* for getenv(3) */
 # include <fcntl.h>                     /* for creat(2) */
 # include <sys/stat.h>
 # include <sys/types.h>
@@ -281,6 +281,20 @@
 
 #endif /* ZORBA_WITH_FILE_ACCESS */
 
+string configdir() {
+#if defined( WINCE )
+  return "";
+#elif defined( WIN32 )
+  char *buf;
+  if ( _dupenv_s( &buf, nullptr, "APPDATA" ) != 0 ) {
+    throw ZORBA_IO_EXCEPTION( "_dupenv_s()", "" );
+  unique_ptr<char[]> const buf_ptr( buf );
+  return buf;
+#else
+  return getenv( "HOME" );
+#endif
+}
+
 string curdir() {
 #ifndef WIN32
   static size_t dir_buf_len = PATH_MAX;
@@ -305,7 +319,7 @@
   win32::wtoa( wpath, path, MAX_PATH );
   string dir( path );
   if ( !is_absolute( dir ) ) {
-    // GetCurrentDirectory() sometimes misses drive letter.
+    // GetCurrentDirectory() sometimes misses the drive letter.
     make_absolute( &dir );
   }
   return dir;

=== modified file 'src/zorbautils/CMakeLists.txt'
--- src/zorbautils/CMakeLists.txt	2013-12-12 18:41:52 +0000
+++ src/zorbautils/CMakeLists.txt	2014-02-10 00:46:59 +0000
@@ -14,7 +14,6 @@
 
 SET(ZORBAUTILS_SRCS
     fatal.cpp
-    properties_base.cpp
     hashset_node_itemh.cpp
     hashset_atomic_itemh.cpp
     mutex.cpp

=== removed file 'src/zorbautils/properties_base.cpp'
--- src/zorbautils/properties_base.cpp	2013-03-06 10:36:56 +0000
+++ src/zorbautils/properties_base.cpp	1970-01-01 00:00:00 +0000
@@ -1,192 +0,0 @@
-/*
- * Copyright 2006-2008 The FLWOR Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "stdafx.h"
-
-#include <fstream>
-#include <cstring>
-#include <cstdlib>
-#include <cassert>
-
-#include <zorba/properties_base.h>
-#ifdef WINCE
-#include <sys/types.h>
-#endif
-
-using namespace std;
-
-namespace zorba {
-
-template<> void PropertiesBase::init_val(
-    const char* str,
-    string& val,
-    unsigned delta) 
-{
-  val = str + delta; 
-}
-
-
-template<> void PropertiesBase::init_val(
-    const char* str,
-    vector<string>& val,
-    unsigned delta) 
-{
-  val.push_back(str + delta);
-}
-
-
-string PropertiesBase::load_file(const char* fname) 
-{
-  ifstream is(fname);
-
-  vector<pair<const char *, const char *> > arg_vec;
-  string line;
-  unsigned nargs = 1;
-
-  while (getline(is, line)) 
-  {
-    if (line.size() == 0 || line[0] == '#')
-      continue;
-
-    size_t i = 0;
-    for (; i < line.size(); ++i)
-    {
-      if (!isspace(line[i]))
-        break;
-    }
-
-    if (i == line.size())
-      continue;
-
-    ++nargs;
-
-    char* str = new char[line.size() + 3];
-
-    str[0] = str[1] = '-';
-
-    memcpy(str + 2, line.data(), line.size());
-
-    str[line.size() + 2] = '\0';
-
-    char* p = strchr(str, '=');
-    if (p != NULL) 
-    {
-      ++nargs;
-      *p = '\0';
-    }
-
-    arg_vec.push_back(pair<const char *, const char *> (str, p));
-  }
-
-  if (nargs == 1)
-  {
-    return "";
-  }
-  else 
-  {
-    const char** argv = new const char * [nargs + 1];
-
-    unsigned i, j;
-
-    for (i = 0, j = 1; i < arg_vec.size(); ++i) 
-    {
-      argv[j++] = arg_vec[i].first;
-
-      if (arg_vec[i].second != NULL)
-        argv[j++] = arg_vec[i].second + 1;
-    }
-
-    assert (j == nargs);
-
-    argv[nargs] = NULL;
-
-    string res = load_argv(nargs, argv);
-
-    delete [] argv;
-
-    for (i = 0; i < arg_vec.size (); ++i)
-      delete [] arg_vec [i].first;
-
-    return res;
-  }
-}
-
-
-string PropertiesBase::load_env(const string& env_pfx, const char** options) 
-{
-  string opt;
-  vector<const char *> arg_vec;
-
-  arg_vec.push_back("cmd");
-
-  for (; *options != NULL; ++options) 
-  {
-    opt.clear();
-    opt += env_pfx;
-    opt += *options + 2;
-
-    for (unsigned i = 0; i < opt.size(); i++) 
-    {
-      if (opt[i] == '-')
-        opt[i] = '_';
-      else if (islower(opt[i]))
-        opt[i] += 'A' - 'a';
-    }
-
-    const char* val = getenv(opt.c_str());
-
-    if (val != NULL) 
-    {
-      arg_vec.push_back(*options);
-      arg_vec.push_back(val);
-    }
-    else
-    {
-      // workaround for binary options
-      opt += "_ON";
-      const char *val = getenv(opt.c_str());
-
-      if (val != NULL)
-        arg_vec.push_back(*options);
-    }
-  }
-  
-  int nargs = (int)arg_vec.size();
-
-  if (nargs == 1)
-  {
-    return "";
-  }
-  else 
-  {
-    const char **argv = new const char * [nargs + 1];
-
-    for (int i = 0; i < nargs; i++)
-      argv[i] = arg_vec[i];
-
-    argv[nargs] = NULL;
-    arg_vec.clear();
-
-    string res = load_argv (nargs, argv);
-
-    delete [] argv;
-
-    return res;
-  }
-}
- 
- 
-}
-/* vim:set et sw=2 ts=2: */

=== modified file 'test/driver/testdriver.cpp'
--- test/driver/testdriver.cpp	2013-10-13 00:47:03 +0000
+++ test/driver/testdriver.cpp	2014-02-10 00:46:59 +0000
@@ -33,8 +33,6 @@
 #include "testuriresolver.h"
 #include "testdriver_common.h"
 
-#include "system/properties.h"
-
 #include <zorba/static_context.h>
 #include <zorba/util/fs_util.h>
 #include <zorba/internal/unique_ptr.h>
@@ -55,12 +53,6 @@
 std::string w3c_ts = "w3c_testsuite/";
 
 
-void loadProperties () 
-{
-  zorba::Properties::load(0, NULL);
-}
-
-
 
 int analyzeError (const Specification &lSpec, const TestDiagnosticHandler& errHandler) 
 {
@@ -98,7 +90,6 @@
   int errors;
   Specification lSpec;
   std::string lModulePath;
-  loadProperties ();
 
   // Instantiate the store and the zorba query processor
   void* store = zorba::StoreManager::getStore();

=== modified file 'test/driver/testdriver_common.cpp'
--- test/driver/testdriver_common.cpp	2013-09-26 07:38:44 +0000
+++ test/driver/testdriver_common.cpp	2014-02-10 00:46:59 +0000
@@ -13,20 +13,23 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 #include <iostream>
 
+#include <zorba/diagnostic_list.h>
+#include <zorba/iterator.h>
+#include <zorba/properties.h>
+#include <zorba/static_context_consts.h>
+#include <zorba/store_consts.h>
 #include <zorbatypes/URI.h>
-#include <zorba/static_context_consts.h>
-#include <zorba/iterator.h>
 #include <zorba/xmldatamanager.h>
-#include <zorba/store_consts.h>
-#include <zorba/diagnostic_list.h>
-#include <util/string_util.h>
-#include <util/ascii_util.h>
+
+#include "util/ascii_util.h"
+#include "util/string_util.h"
+
 #include "testdriverconfig.h"
 #include "testdriver_common.h"
 #include "specification.h"
-#include "system/properties.h"
 
 static void set_var(
     DriverContext& driverCtx,
@@ -209,10 +212,10 @@
 
   lHints.for_serialization_only = false;
 
-  if (zorba::Properties::instance()->serializeOnlyQuery() > 0)
-  {
+#if 0
+  if ( zorba::Properties::instance().getSerializeOnlyQuery() )
     lHints.for_serialization_only = true;
-  }
+#endif
 
   return lHints;
 }

=== modified file 'test/driver/testdriver_mt.cpp'
--- test/driver/testdriver_mt.cpp	2013-10-01 11:11:45 +0000
+++ test/driver/testdriver_mt.cpp	2014-02-10 00:46:59 +0000
@@ -37,8 +37,6 @@
 
 #include "zorbautils/mutex.h"
 
-#include "system/properties.h"
-
 #include "testdriverconfig.h" // SRC and BIN dir definitions
 #include "specification.h" // parsing spec files
 #include "testuriresolver.h"
@@ -858,8 +856,6 @@
   main(int argc, char** argv)
 #endif
 {
-  zorba::Properties::load(0, NULL);
-
   std::string bucketName;
   std::string bucketPath;
   std::string queriesDir;

=== modified file 'test/driver/updtestdriver.cpp'
--- test/driver/updtestdriver.cpp	2013-09-17 21:12:49 +0000
+++ test/driver/updtestdriver.cpp	2014-02-10 00:46:59 +0000
@@ -42,7 +42,6 @@
 
 #include <zorba/store_manager.h>
 
-#include "system/properties.h"
 #include "testdriver_comparator.h"
 
 //#define ZORBA_TEST_PLAN_SERIALIZATION
@@ -230,8 +229,6 @@
     return 1;
   }
 
-  zorba::Properties::load (0, NULL);
-
   zorba::Zorba* engine = zorba::Zorba::getInstance(zorba::StoreManager::getStore());
 
   zorba::XmlDataManager_t xmlDataMgr = engine->getXmlDataManager();

=== modified file 'test/extern/test_extern_func.cpp'
--- test/extern/test_extern_func.cpp	2013-02-07 17:24:36 +0000
+++ test/extern/test_extern_func.cpp	2014-02-10 00:46:59 +0000
@@ -31,8 +31,6 @@
 #include <zorba/store_manager.h>
 #include <zorba/singleton_item_sequence.h>
 
-#include "system/properties.h"
-
 using namespace zorba;
 
 class MySimpleExternalFunction;
@@ -249,8 +247,6 @@
   void* lStore = zorba::StoreManager::getStore();
   Zorba* lZorba = Zorba::getInstance(lStore);
 
-  zorba::Properties::load(0, NULL);
-
   std::string str = load_file(filename);
   try
   {

=== modified file 'test/iterplans/CMakeLists.txt'
--- test/iterplans/CMakeLists.txt	2013-07-11 06:54:25 +0000
+++ test/iterplans/CMakeLists.txt	2014-02-10 00:46:59 +0000
@@ -16,7 +16,12 @@
 CONFIGURE_FILE(itertest.xq.in ${CMAKE_CURRENT_BINARY_DIR}/itertest.xq)
 
 # apitest
-ZORBA_GENERATE_EXE("apitest" "apitest.cpp" "" "" "")
+SET(APITEST_SRCS
+  apitest_args.cpp
+  apitest_props.cpp
+  apitest.cpp
+)
+ZORBA_GENERATE_EXE("apitest" "${APITEST_SRCS}" "" "" "")
 
 MESSAGE (STATUS "Adding iterator plan tests")
 FILE (GLOB_RECURSE TESTFILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.iter)
@@ -49,3 +54,4 @@
     PROPERTIES PASS_REGULAR_EXPRESSION "Passed! *")
 ENDFOREACH(TESTFILE)
 
+# vim:set et sw=2 ts=2:

=== modified file 'test/iterplans/apitest.cpp'
--- test/iterplans/apitest.cpp	2013-09-18 19:14:11 +0000
+++ test/iterplans/apitest.cpp	2014-02-10 00:46:59 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006-2008 The FLWOR Foundation.
+ * Copyright 2006-2014 The FLWOR Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,317 +14,234 @@
  * limitations under the License.
  */
 
-#include <zorba/zorba.h>
-
+// standard
+#include <cassert>
 #include <fstream>
 #include <iostream>
-#include <iomanip>
 #include <sstream>
 
-// tests are allowed to use internals
-#include "api/unmarshaller.h"
-#include "system/properties.h"
-
+// Zorba
+#include <zorba/internal/unique_ptr.h>
+#include <zorba/iterator.h>
+#include <zorba/properties.h>
 #include <zorba/store_manager.h>
-#include <zorba/iterator.h>
 #include <zorba/util/fs_util.h>
-#include <zorba/xquery_exception.h>
-#include <zorba/internal/unique_ptr.h>
-
-// Global variable g_abort_on_error is used to generate an abort() when an
-// error is encountered, to aid debugging
-#ifndef NDEBUG
-#ifdef BUILDING_ZORBA_STATIC
-extern bool g_abort_on_error;
-#else
-ZORBA_DLL_PUBLIC bool g_abort_on_error;
-#endif
-#endif
-
-
+#include <zorba/zorba_exception.h>
+#include <zorba/zorba.h>
+
+// local
+#include "apitest_props.h"
+
+using namespace std;
 using namespace zorba;
-using namespace std;
-
-
-void set_var (string name, string val, DynamicContext* dctx)
-{
-  if (name [name.size () - 1] == ':')
-  {
-    name = name.substr (0, name.size () - 1);
-    Item lItem = Zorba::getInstance(NULL)->getItemFactory()->createString(val);
-    if(name != ".") {
-      dctx->setVariable(name, lItem);
-    } else
-      dctx->setContextItem(lItem);
-  }
-  else if (name[name.size () - 1] != ':')
-  {
-    ifstream is(val.c_str());
-    assert (is);
-    try {
-      XmlDataManager_t lXmlMgr = Zorba::getInstance(NULL)->getXmlDataManager();
-      Item lDoc = lXmlMgr->parseXML(is);
-      assert (lDoc.getNodeKind() == zorba::store::StoreConsts::documentNode);
-      if(name != ".")
-        dctx->setVariable(name, lDoc);
-      else
-        dctx->setContextItem(lDoc);
-    } catch (zorba::ZorbaException& e) {
-      std::cerr << "could not set external variable "  << e << std::endl;
-      exit(1);
-    }
-  }
-}
-
+
+extern int parse_args( int argc, char const *argv[] );
+
+///////////////////////////////////////////////////////////////////////////////
 
 #ifndef _WIN32_WCE
-int main(int argc, char* argv[])
+int main( int argc, char const *argv[] ) {
 #else
-int _tmain(int argc, _TCHAR* argv[])
+int _tmain( int argc, _TCHAR const *argv[] ) {
 #endif
-{
-  // read the command file properties
-  if (! Properties::load(argc,argv))
-    return 4;
+  int const optind = parse_args( argc, argv );
+  argc -= optind;
+  argv += optind;
 
-  Properties* lProp = Properties::instance();
-  if (! lProp->hasSingleQuery ()) {
+  Properties const &z_props = Properties::instance();
+  APITestProperties const &at_props = APITestProperties::instance();
+#if 0
+  if (! z_props.hasSingleQuery ()) {
     cout << "Error: either a single inline query or a single query file must be supplied" << endl;
     return 4;
   }
+#endif
   Zorba_CompilerHints chints;
-  switch (lProp->optimizer()) {
-  case 0:
-    chints.opt_level = ZORBA_OPT_LEVEL_O0;
-    break;
-  case 1:
-    chints.opt_level = ZORBA_OPT_LEVEL_O1;
-    break;
-  case 2:
-    chints.opt_level = ZORBA_OPT_LEVEL_O1;
-    break;
-  default:
-    chints.opt_level = ZORBA_OPT_LEVEL_O1;
-  }
-
-  chints.for_serialization_only = false;
-
-  if (Properties::instance()->serializeOnlyQuery() > 0)
-  {
-    chints.for_serialization_only = true;
-  }
-
-  // default is false
-  if (lProp->libModule())
-  {
-    chints.lib_module = true;
-  }
+  switch ( z_props.getOptimizationLevel() ) {
+    case 0 : chints.opt_level = ZORBA_OPT_LEVEL_O0; break;
+    case 2 : chints.opt_level = ZORBA_OPT_LEVEL_O1; break;
+    default: chints.opt_level = ZORBA_OPT_LEVEL_O1;
+  }
+
+  chints.for_serialization_only = at_props.serialize_only_query_;
+  chints.lib_module = at_props.lib_module_;
 
   // output file (either a file or the standard out if no file is specified)
-  unique_ptr<ostream> outputFile (lProp->resultFile ().empty ()
-                                ? NULL : new ofstream (lProp->resultFile().c_str()));
-  ostream *resultFile = outputFile.get ();
-  if (resultFile == NULL)
-    resultFile = &cout;
+  unique_ptr<ostream> output_file_ptr(
+    at_props.output_file_.empty() ?
+      NULL : new ofstream( at_props.output_file_.c_str() )
+  );
+  ostream *output_file = output_file_ptr.get();
+  if ( !output_file )
+    output_file = &cout;
 
   // input file (either from a file or given as parameter)
-  unique_ptr<istream> qfile;
-  std::string path;
+  unique_ptr<istream> qstream;
+  string path;
 
-  if (! lProp->inlineQuery()) 
-  {
-    path = lProp->queryFile ();
+  if ( at_props.as_file_ ) {
+    path = at_props.query_;
     fs::make_absolute( &path );
-    qfile.reset (new ifstream (path.c_str ()));
-    if (!qfile->good() || qfile->eof()) 
-    {
+    qstream.reset( new ifstream( path.c_str() ) );
+    if ( !qstream->good() || qstream->eof() ) {
       cerr << "no query given or not readable " << path << endl;
       return 3;
     }
-  }
-  else 
-  {
-    qfile.reset (new istringstream(lProp->query ()));
-  }
+  } else
+    qstream.reset( new istringstream( at_props.query_ ) );
 
   // print the query if requested
-  if (lProp->printQuery()) {
-    lProp->debug_out ()<< "Query text:\n";
-    copy (istreambuf_iterator<char> (*qfile), istreambuf_iterator<char> (), ostreambuf_iterator<char> (lProp->debug_out ()));
-    lProp->debug_out () << "\n" << endl;
-    qfile->seekg(0); // go back to the beginning
+  if ( at_props.print_query_ ) {
+    z_props.getDebugStream() << "Query text:\n";
+    copy(
+      istreambuf_iterator<char>( *qstream ),
+      istreambuf_iterator<char>(),
+      ostreambuf_iterator<char>( z_props.getDebugStream() )
+    );
+    z_props.getDebugStream() << '\n' << endl;
+    qstream->seekg( 0 );
   }
 
   // Instantiate the simple store
-  void* store = zorba::StoreManager::getStore();
-
-  // Set the g_abort_on_exception flag in error_manager.cpp
-#ifndef NDEBUG
-  if (lProp->abort())
-    g_abort_on_error = true;
-#endif
+  void *const store = StoreManager::getStore();
 
   // start processing
-  Zorba* zengine = Zorba::getInstance(store);
-
-  zorba::StaticContext_t staticContext = zengine->createStaticContext();
-
-  // start parsing the query
-  XQuery_t query = zengine->createQuery ();
+  Zorba *const zorba = Zorba::getInstance( store );
+  StaticContext_t sctx( zorba->createStaticContext() );
+  XQuery_t query( zorba->createQuery() );
 
 #ifdef ZORBA_WITH_DEBUGGER
-  if (lProp->debug()) 
-  {
-    query->setDebugMode(lProp->debug());
-    Zorba_CompilerHints lHints;
-    lHints.opt_level = ZORBA_OPT_LEVEL_O0;
-  }
-#endif
-
-  if (! lProp->inlineQuery())
-  {
-    query->setFileName(path);
-  }
-
-  if (lProp->jsoniqParser())
-  {
-    staticContext->setJSONiqVersion(zorba::jsoniq_version_1_0);
-  }
-
-  try 
-  {
-    query->compile(*qfile, staticContext, chints);
-  }
-  catch (ZorbaException& e)
-  {
+  if ( at_props.debug_ )
+    query->setDebugMode( true );
+#endif /* ZORBA_WITH_DEBUGGER */
+
+  if ( !path.empty() )
+    query->setFileName( path );
+
+  if ( at_props.jsoniq_ )
+    sctx->setJSONiqVersion( jsoniq_version_1_0 );
+
+  try {
+    query->compile( *qstream, sctx, chints );
+  }
+  catch ( ZorbaException const &e ) {
     // no need to close because the object is not valid
     cerr << "Compilation error: " << e << endl;
     return 1;
   }
 
-  if (lProp->testPlanSerialization())
-  {
-    try
-    {
-      std::string binary_path;
-      if (lProp->inlineQuery())
+  if ( at_props.test_plan_serialization_ ) {
+    try {
+      string binary_path;
+      if ( path.empty() )
+        binary_path = "./temp.plan";
+      else
         binary_path = path + ".plan";
-      else
-        binary_path = "./temp.plan";
 
-      std::ofstream fbinary(binary_path.c_str(), std::ios_base::binary);
-      if (!query->saveExecutionPlan(fbinary))
-      {
-        printf("save execution plan FAILED\n");
+      ofstream fbinary( binary_path.c_str(), ios_base::binary );
+      if ( !query->saveExecutionPlan( fbinary ) ) {
+        printf( "save execution plan FAILED\n" );
         return 0x0badc0de;
       }
-      fbinary.close();
-      printf("saved execution plan at: %s\n", binary_path.c_str());
+      printf( "saved execution plan at: %s\n", binary_path.c_str() );
     }
-    catch(zorba::ZorbaException &err)
-    {
-      std::cout << err << std::endl;
+    catch( ZorbaException const &e ) {
+      cout << e << endl;
       return -1;
     }
 
     // Now load back the plan
-    try
-    {
-      std::string binary_path;
-      if (lProp->inlineQuery())
+    try {
+      string binary_path;
+      if ( path.empty() )
+        binary_path = "./temp.plan";
+      else
         binary_path = path + ".plan";
-      else
-        binary_path = "./temp.plan";
-      query = zengine->createQuery();
-      std::ifstream ifbinary(binary_path.c_str(), std::ios_base::binary);
-      if(!ifbinary.is_open())
-      {
-        std::cout << "cannot open plan " << binary_path << std::endl;
+      query = zorba->createQuery();
+      ifstream ifbinary( binary_path.c_str(), ios_base::binary );
+      if ( !ifbinary.is_open() ) {
+        cout << "cannot open plan " << binary_path << endl;
         return 15;
       }
 
-      bool load_ret = query->loadExecutionPlan(ifbinary);
-
-      if (!load_ret)
-      {
-        std::cout << "cannot load plan " << binary_path << std::endl;
+      bool load_ret = query->loadExecutionPlan( ifbinary );
+      if ( !load_ret ) {
+        cout << "cannot load plan " << binary_path << endl;
         return 16;
       }
-
-      printf("load execution plan: %s\n", binary_path.c_str());
+      printf( "load execution plan: %s\n", binary_path.c_str() );
     }
-    catch(zorba::ZorbaException &err)
-    {
-      std::cout << err << std::endl;
+    catch ( ZorbaException const &e ) {
+      cout << e << endl;
       return -1;
     }
   }
 
   // set external variables
-  vector<pair <string, string> > ext_vars = lProp->getExternalVars();
-  DynamicContext* dctx = query->getDynamicContext ();
-  dctx->setImplicitTimezone (lProp->tz ());
-  for (vector<pair <string, string> >::const_iterator iter = ext_vars.begin ();
-       iter != ext_vars.end (); iter++) 
-  {
-    set_var (iter->first, iter->second, dctx);
+  external_vars const &ext_vars = at_props.external_vars_;
+  DynamicContext *const dctx = query->getDynamicContext();
+  dctx->setImplicitTimezone( at_props.tz_ );
+  for ( external_vars::const_iterator
+        i = ext_vars.begin(); i != ext_vars.end(); ++i ) {
+    Item item;
+    if ( i->inline_file ) {
+      ifstream is( i->var_value.c_str() );
+      assert( is );
+      try {
+        XmlDataManager_t xml_dm( zorba->getXmlDataManager() );
+        item = xml_dm->parseXML( is );
+        assert( item.getNodeKind() == store::StoreConsts::documentNode );
+      }
+      catch ( ZorbaException const &e ) {
+        cerr << "could not set external variable " << e << endl;
+        exit( 1 );
+      }
+    } else {
+      item = zorba->getItemFactory()->createString( i->var_value );
+    }
+    if ( i->var_name == "." )
+      dctx->setContextItem( item );
+    else
+      dctx->setVariable( i->var_name, item );
   }
 
-  //if you want to print the plan into a file
-  if( ! lProp->dotPlanFile().empty () ) 
-  {
-    unique_ptr<ostream> planFile (new ofstream (lProp->dotPlanFile().c_str()));
-    ostream *printPlanFile = planFile.get ();
-
-    query->printPlan(*printPlanFile, true);
+  // if you want to print the plan into a file
+  if ( !at_props.dot_plan_file_.empty() ) {
+    ofstream plan_file( at_props.dot_plan_file_.c_str() );
+    query->printPlan( plan_file, true );
   }
 
   int return_code = 0;
-  if (! lProp->compileOnly() && ! lProp->libModule())
-  {
+  if ( !at_props.compile_only_ && !at_props.lib_module_ ) {
+
     // output the result (either using xml serialization or using show)
 
-    try 
-    {
-      if (lProp->useSerializer()) 
-      {
-        Zorba_SerializerOptions const opts(lProp->getSerializerParameters());
-        query->execute(*resultFile, &opts);
-      }
-      else if (lProp->iterPlanTest())
-      {
-        Iterator_t result = query->iterator();
-        result->open();
-        Item lItem;
-        while (result->next(lItem)) 
-        {
-          ;
-        }
-        result->close();
-      }
-      else
-      {
-        Iterator_t result = query->iterator();
-        result->open();
-        Item lItem;
-        while (result->next(lItem)) 
-        {
-          ;
-        }
-        result->close();
+    try {
+      if ( at_props.use_serializer_ ) {
+        Zorba_SerializerOptions const opts( at_props.serialization_params_ );
+        query->execute( *output_file, &opts );
+      } else {
+        Iterator_t i( query->iterator() );
+        i->open();
+        Item item;
+        while ( i->next( item ) )
+          ;
+        i->close();
       }
     }
-    catch (ZorbaException const &e)
-    {
+    catch ( ZorbaException const &e ) {
       cerr << "Execution error: " << e << endl;
       return_code = 2;
     }
   }
 
-  staticContext->removeReference();  // force destruction
-  staticContext = NULL;
-  query->close();  
-  zengine->shutdown();
-  zorba::StoreManager::shutdownStore(store);
+  sctx->removeReference();  // force destruction
+  query->close();
+  zorba->shutdown();
+  StoreManager::shutdownStore( store );
   return return_code;
 }
+
+///////////////////////////////////////////////////////////////////////////////
+
+/* vim:set et sw=2 ts=2: */

=== added file 'test/iterplans/apitest_args.cpp'
--- test/iterplans/apitest_args.cpp	1970-01-01 00:00:00 +0000
+++ test/iterplans/apitest_args.cpp	2014-02-10 00:46:59 +0000
@@ -0,0 +1,541 @@
+/*
+ * Copyright 2006-2014 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// standard
+#include <algorithm>
+#include <cctype>
+#include <cstdlib>
+#include <iostream>
+
+// Zorba
+#include <zorba/zorba.h>
+#include <zorba/properties.h>
+
+// local
+#include "apitest_props.h"
+
+using namespace std;
+using namespace zorba;
+
+static char const* check_args();
+
+///////////////////////////////////////////////////////////////////////////////
+
+#define HELP_OPT(ARG) ARG "\n"
+
+char const* get_help_msg() {
+  return
+
+    ////////// a //////////////////////////////////////////////////////////////
+
+#ifndef NDEBUG
+    HELP_OPT( "--abort" )
+      "Call abort(3) when a ZorbaException is thrown.\n\n"
+#endif /* NDEBUG */
+
+    ////////// c //////////////////////////////////////////////////////////////
+
+    HELP_OPT( "--compile-only" )
+      "Only compile (don't execute)\n\n"
+
+    ////////// d //////////////////////////////////////////////////////////////
+
+    HELP_OPT( "--debug, -d" )
+      "Launch the Zorba debugger server and connect to a DBGP-enabled debugger client.\n\n"
+
+    HELP_OPT( "--debug-host, -h" )
+      "The host where the DBGP-enabled debugger client listens for connections. Defaults to: 127.0.0.1\n\n"
+
+    HELP_OPT( "--debug-port, -p" )
+      "The port on which the DBGP-enabled debugger client listens for connections. Defaults to: 28028\n\n"
+
+    ////////// e //////////////////////////////////////////////////////////////
+
+    HELP_OPT( "--execute-plan" )
+      "Do not compile the query; instead load the execution plan from the file specified by the -f -q options (or by any file specified without any other argument), and execute the loaded plan.\n\n"
+
+    HELP_OPT( "--external-var, -x" )
+      "Provide the value for a variable given a file (name=file) or a value (name:=value)\n\n"
+
+    ////////// i //////////////////////////////////////////////////////////////
+
+    HELP_OPT( "--infer-joins" )
+      "Infer joins.\n\n"
+
+    HELP_OPT( "--inline-udf" )
+      "Inline user-defined functions.\n\n"
+
+    ////////// j //////////////////////////////////////////////////////////////
+
+    HELP_OPT( "--jsoniq, -j" )
+      "Force queries to be considered JSONiq.\n\n"
+
+    ////////// l //////////////////////////////////////////////////////////////
+
+    HELP_OPT( "--lib-module, -l" )
+      "Query compiler option to treat the query as a library module. If this is set --compile-only option is also set to true.\n\n"
+
+    HELP_OPT( "--lib-path" )
+      "Library path (list of directories) where Zorba will look for dynamic libraries (e.g., module external function implementations.\n\n"
+
+    HELP_OPT( "--loop-hosting" )
+      "Hoist expressions out of loops.\n\n"
+
+    ////////// m //////////////////////////////////////////////////////////////
+
+    HELP_OPT( "--max-udf-call-depth" )
+      "Maximum stack depth of user-defined function calls.\n\n"
+
+    HELP_OPT( "--module-path" )
+      "Path (list of directories) to add to both the URI and Library paths.\n\n"
+
+    ////////// n //////////////////////////////////////////////////////////////
+
+    HELP_OPT( "--no-copy-optim" )
+      "Apply the no-copy optimization.\n\n"
+
+    HELP_OPT( "--no-serializer" )
+      "Do not serialize (discard) result.\n\n"
+
+    HELP_OPT( "--no-tree-ids" )
+      "Suppress IDs and locations from compiler tree dumps.\n\n"
+
+    ////////// o //////////////////////////////////////////////////////////////
+
+    HELP_OPT( "--optimization-level, -O" )
+      "Optimization level for the query compiler [0-2], default: 1\n\n"
+
+#ifdef ZORBA_WITH_FILE_ACCESS
+    HELP_OPT( "--output-file, -o" )
+      "Write the result to the given file.\n\n"
+#endif /* ZORBA_WITH_FILE_ACCESS */
+
+    ////////// p //////////////////////////////////////////////////////////////
+
+    HELP_OPT( "--parse-only" )
+      "Stop after parsing the query.\n\n"
+
+    HELP_OPT( "--plan" )
+      "Test plan serialization.\n\n"
+
+    HELP_OPT( "--print-ast" )
+      "Print the abstract syntax tree.\n\n"
+
+    HELP_OPT( "--print-intermediate-opt" )
+      "Print intermediate optimizations.\n\n"
+
+    HELP_OPT( "--print-item-flow" )
+      "Print items produced by all iterators.\n\n"
+
+    HELP_OPT( "--print-iterator-tree" )
+      "Print the iterator tree.\n\n"
+
+    HELP_OPT( "--print-locations" )
+      "Print parser locations for compiler expressions.\n\n"
+
+    HELP_OPT( "--print-optimized" )
+      "Print the optimized expression tree.\n\n"
+
+    HELP_OPT( "--print-query" )
+      "Print the queries.\n\n"
+
+    HELP_OPT( "--print-static-types" )
+      "Print static type inference.\n\n"
+
+    HELP_OPT( "--print-translated" )
+      "Print the normalized expression tree.\n\n"
+
+    ////////// q //////////////////////////////////////////////////////////////
+
+    HELP_OPT( "--query, -q" )
+      "Query test or file URI (file://...)\n\n"
+
+    ////////// s //////////////////////////////////////////////////////////////
+
+    HELP_OPT( "--serialization-parameter, -z" )
+      "Set serialization parameter in the form of a parameter=value pair (see http://www.w3.org/TR/xslt-xquery-serialization/#serparam, e.g.: -z method=xhtml -z doctype-system=DTD/xhtml1-strict.dtd -z indent=yes).\n\n"
+
+    ////////// t //////////////////////////////////////////////////////////////
+
+    HELP_OPT( "--trace-parsing" )
+      "Trace parsing.\n\n"
+
+    HELP_OPT( "--trace-scanning" )
+      "Trace scanning.\n\n"
+
+#ifndef NDEBUG
+    HELP_OPT( "--trace-codegen" )
+      "Trace code generatio.\n\n"
+
+    HELP_OPT( "--trace-fulltext" )
+      "Trace full-text.\n\n"
+
+    HELP_OPT( "--trace-translator" )
+      "Trace the translator.\n\n"
+#endif /* NDEBUG */
+
+    HELP_OPT( "--tz" )
+      "Set implicit time zone (in minutes.\n\n"
+
+    ////////// u //////////////////////////////////////////////////////////////
+
+    HELP_OPT( "--use-serializer" )
+      "Use serializer.\n\n"
+
+    ////////// v //////////////////////////////////////////////////////////////
+
+    HELP_OPT( "--version, -v" )
+      "Print the version number and exit.\n\n"
+
+    ;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+static bool split_key_value( char const *s, char const *split,
+                             string *key, string *value ) {
+  char const *const p = strstr( s, split );
+  size_t const split_len = strlen( split );
+  if ( !p || p == s /* =xxx */ || !p[ split_len ] /* xxx= */ )
+    return false;
+  key->assign( s, 0, p - s );
+  value->assign( p + split_len );
+  return true;
+}
+
+inline char to_lower( char c ) {
+  return tolower( c );
+}
+
+template<class StringType> inline
+typename enable_if<ZORBA_IS_STRING(StringType),void>::type
+to_lower( StringType &s ) {
+  transform(
+    s.begin(), s.end(), s.begin(), static_cast<char (*)(char)>( to_lower )
+  );
+}
+
+static bool bool_of( char const *s ) {
+  string b( s );
+  to_lower( b );
+  if ( b == "t" || b == "true" || b == "y" || b == "yes" || b == "1" )
+    return true;
+  if ( b == "f" || b == "false" || b == "n" || b == "no" || b == "0" )
+    return false;
+  cerr << '"' << s << "\": invalid boolean value" << endl;
+  exit( 1 );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+#define IS_LONG_OPT(OPT)  (strcmp( *argv, (OPT) ) == 0)
+#define IS_SHORT_OPT(OPT) (strncmp( *argv, (OPT), 2 ) == 0)
+#define IS_OPT(LOPT,SOPT) (IS_LONG_OPT(LOPT) || IS_SHORT_OPT(SOPT))
+
+#define PARSE_ARG(ARG)                                                    \
+  int offset = 2;                                                         \
+  if ( (*argv)[1] == '-' || !(*argv)[2] ) { offset = 0; ++argv; }         \
+  if ( !*argv ) { error = "No value given for " #ARG " option"; break; }
+
+#define ARG_VAL (*argv + offset)
+
+template<typename T> inline
+void atoi( char const *s,  T *result, int offset = 0 ) {
+  istringstream iss( s + offset );
+  iss >> *result;
+}
+
+#define SET_ATPROP(PROP) \
+  atoi( *argv, &at_props.PROP, offset )
+
+template<class C,typename T> inline
+void atoi( char const *s, C &c, void (C::*f)( T ), int offset = 0 ) {
+  T temp;
+  atoi( s, &temp, offset );
+  (c.*f)( temp );
+}
+
+#define SET_ZPROP(PROP) \
+  atoi( *argv, z_props, &Properties::set##PROP, offset )
+
+int parse_args( int argc, char const *argv[] ) {
+  char const *error = 0;
+  Properties &z_props = Properties::instance();
+  APITestProperties &at_props = APITestProperties::instance();
+
+  char const **const argv_orig = argv;
+  for ( ++argv; *argv; ++argv ) {
+
+    ////////// a //////////////////////////////////////////////////////////////
+
+#ifndef NDEBUG
+    if ( IS_LONG_OPT( "--abort" ) )
+      z_props.setAbort( true );
+    else
+#endif /* NDEBUG */
+
+    ////////// c //////////////////////////////////////////////////////////////
+
+    if ( IS_LONG_OPT( "--compile-only" ) )
+      at_props.compile_only_ = true;
+
+    ////////// d //////////////////////////////////////////////////////////////
+
+#ifdef ZORBA_WITH_DEBUGGER
+    else if ( IS_OPT( "--debug", "-d" ) )
+      at_props->debug_ = true;
+    else if ( IS_OPT( "--debug-host", "-h" ) ) {
+      PARSE_ARG( "--debug-host" );
+      at_props.debugger_host_ = ARG_VAL;
+    }
+    else if ( IS_OPT( "--debug-port", "-p" ) ) {
+      PARSE_ARG( "--debug-port" );
+      SET_ATPROP( debugger_port_ );
+    }
+#endif /* ZORBA_WITH_DEBUGGER */
+    else if ( IS_LONG_OPT( "--dot-plan-file" ) )
+      at_props.dot_plan_file_ = true;
+    else if ( IS_LONG_OPT( "--dump-lib" ) )
+      z_props.setDumpLib( true );
+
+    ////////// e //////////////////////////////////////////////////////////////
+
+    else if ( IS_LONG_OPT( "--execute-plan" ) )
+      at_props.load_plan_ = true;
+    else if ( IS_OPT( "--external-var", "-x" ) ) {
+      PARSE_ARG( "--external-var" );
+      string key, value;
+      if ( !split_key_value( ARG_VAL, "=", &key, &value ) ) {
+        error = "--external-var argument must be of the form name=file or name:=value";
+        break;
+      }
+      external_var ev;
+      ev.var_value = value;
+
+      if ( key[0] == ':' ) {
+        error = "--external-var argument must be of the form name=file or name:=value";
+        break;
+      }
+      if ( key[ key.size() - 1 ] == ':' )
+        key.erase( key.size() - 1 );
+      else
+        ev.inline_file = true;
+      ev.var_name = key;
+
+      at_props.external_vars_.push_back( ev );
+    }
+
+    ////////// f //////////////////////////////////////////////////////////////
+
+    else if ( IS_LONG_OPT( "--force-gflwor" ) )
+      z_props.setForceGFLWOR( true );
+
+    ////////// h //////////////////////////////////////////////////////////////
+
+    else if ( IS_OPT( "--help", "-h" ) ) {
+      cout << "Zorba NoSQL Query Processor, Version: "
+           << Zorba::version() << '\n'
+           << "Available options:\n\n"
+           << get_help_msg();
+      exit( 0 );
+    }
+
+    ////////// i //////////////////////////////////////////////////////////////
+
+    else if ( IS_LONG_OPT( "--infer-joins" ) ) {
+      PARSE_ARG( "--infer-joins" );
+      z_props.setInferJoins( bool_of( ARG_VAL ) );
+    }
+    else if ( IS_LONG_OPT( "--inline-udf" ) ) {
+      PARSE_ARG( "--inline-udf" );
+      z_props.setInlineUDF( bool_of( ARG_VAL ) );
+    }
+    else if ( IS_LONG_OPT( "--iter-plan-test" ) )
+      at_props.iter_plan_test_ = true;
+
+    ////////// j //////////////////////////////////////////////////////////////
+
+    else if ( IS_OPT( "--jsoniq", "-j" ) )
+      at_props.jsoniq_ = true;
+
+    ////////// l //////////////////////////////////////////////////////////////
+
+    else if ( IS_OPT( "--lib-module", "-l" ) )
+      at_props.lib_module_ = true;
+    else if ( IS_LONG_OPT( "--lib-path" ) ) {
+      PARSE_ARG( "--lib-path" );
+      at_props.lib_path_ = ARG_VAL;
+    }
+    else if ( IS_LONG_OPT( "--loop-hoisting" ) ) {
+      PARSE_ARG( "--loop-hoisting" );
+      z_props.setLoopHoisting( bool_of( ARG_VAL ) );
+    }
+
+    ////////// n //////////////////////////////////////////////////////////////
+
+    else if ( IS_LONG_OPT( "--no-copy-optim" ) ) {
+      PARSE_ARG( "--no-copy-optim" );
+      z_props.setNoCopyOptim( bool_of( ARG_VAL ) );
+    }
+    else if ( IS_LONG_OPT( "--no-tree-ids" ) )
+      z_props.setNoTreeIDs( true );
+
+    ////////// o //////////////////////////////////////////////////////////////
+
+    else if ( IS_OPT( "--optimization-level", "-O" ) ||
+              IS_LONG_OPT( "--optimizer" ) ) {
+      PARSE_ARG( "--optimization-level" );
+      unsigned opt_level;
+      atoi( ARG_VAL, &opt_level );
+      if ( opt_level > 2 ) {
+        error = "Only 0, 1 and 2 are allowed as values for --optimization-level";
+        break;
+      }
+      z_props.setOptimizationLevel( opt_level );
+    }
+#ifdef ZORBA_WITH_FILE_ACCESS
+    else if ( IS_OPT( "--output-file", "-o" ) ) {
+      PARSE_ARG( "--output-file" );
+      at_props.output_file_ = ARG_VAL;
+    }
+#endif /* ZORBA_WITH_FILE_ACCESS */
+
+    ////////// p //////////////////////////////////////////////////////////////
+
+    else if ( IS_LONG_OPT( "--parse-only" ) )
+      at_props.parse_only_ = true;
+    else if ( IS_LONG_OPT( "--plan" ) )
+      at_props.test_plan_serialization_ = true;
+    else if ( IS_OPT( "--print-ast", "-a" ) )
+      z_props.setPrintAST( true );
+    else if ( IS_LONG_OPT( "--print-intermediate-opt" ) )
+      z_props.setPrintIntermediateOpt( true );
+    else if ( IS_LONG_OPT( "--print-item-flow" ) )
+      z_props.setPrintItemFlow( true );
+    else if ( IS_LONG_OPT( "--print-iterator-tree" ) )
+      z_props.setPrintIteratorTree( true );
+    else if ( IS_LONG_OPT( "--print-locations" ) )
+      z_props.setPrintLocations( true );
+    else if ( IS_OPT( "--print-optimized", "-P" ) )
+      z_props.setPrintOptimized( true );
+    else if ( IS_LONG_OPT( "--print-query" ) )
+      at_props.print_query_ = true;
+    else if ( IS_LONG_OPT( "--print-static-types" ) )
+      z_props.setPrintStaticTypes( true );
+    else if ( IS_LONG_OPT( "--print-translated" ) )
+      z_props.setPrintTranslated( true );
+
+    ////////// q //////////////////////////////////////////////////////////////
+
+    else if ( IS_OPT( "--query", "-e" ) ) {
+      PARSE_ARG( "--query" );
+      at_props.query_ = ARG_VAL;
+    }
+
+    ////////// s //////////////////////////////////////////////////////////////
+
+    else if ( IS_LONG_OPT( "--serialize-only-query" ) ) {
+      PARSE_ARG( "--serialize-only-query" );
+      at_props.serialize_only_query_ = bool_of( ARG_VAL );
+    }
+    else if ( IS_OPT( "--serialization-parameter", "-z" ) ) {
+      PARSE_ARG( "--serialization-parameter" );
+      string key, value;
+      serialization_param sp;
+      if ( split_key_value( ARG_VAL, "=", &key, &value ) ) {
+        sp.first = key;
+        sp.second = value;
+      } else
+        sp.first = ARG_VAL;
+      at_props.serialization_params_.push_back( sp );
+    }
+    else if ( IS_LONG_OPT( "--stable-iterator-ids" ) )
+      z_props.setStableIteratorIDs( true );
+
+    ////////// t //////////////////////////////////////////////////////////////
+
+    else if ( IS_LONG_OPT( "--trace-parsing" ) )
+      z_props.setTraceParsing( true );
+    else if ( IS_LONG_OPT( "--trace-scanning" ) )
+      z_props.setTraceScanning( true );
+#ifndef NDEBUG
+    else if ( IS_LONG_OPT( "--trace-codegen" ) )
+      z_props.setTraceCodegen( true );
+    else if ( IS_LONG_OPT( "--trace-fulltext" ) )
+      z_props.setTraceFulltext( true );
+    else if ( IS_LONG_OPT( "--trace-translator" ) )
+      z_props.setTraceTranslator( true );
+#endif /* NDEBUG */
+    else if ( IS_LONG_OPT( "--tz" ) ) {
+      PARSE_ARG( "--tz" );
+      SET_ATPROP( tz_ );
+    }
+
+    ////////// u //////////////////////////////////////////////////////////////
+
+    else if ( IS_LONG_OPT( "--use-indexes" ) )
+      z_props.setUseIndexes( true );
+    else if ( IS_LONG_OPT( "--use-serializer" ) )
+      at_props.use_serializer_ = true;
+
+    ////////// v //////////////////////////////////////////////////////////////
+
+    else if ( IS_OPT( "--version", "-v" ) ) {
+      cout << "Zorba NoSQL Query Processor, Version: "
+           << zorba::Zorba::version() << endl;
+      exit( 1 ); // should be 0, but the old code returned 1
+    }
+
+    ////////// END ////////////////////////////////////////////////////////////
+
+    else if ( IS_LONG_OPT( "--" ) )
+      break;
+    else if ( (*argv)[0] == '-' ) {
+      cerr << "unknown command line option " << *argv << endl;
+      exit( 1 );
+    } else {
+      if ( !at_props.query_.empty() ) {
+        error = "exactly one inline query or query file must be specified";
+        break;
+      }
+      at_props.as_file_ = true;
+      at_props.query_ = *argv;
+    }
+  } // for
+
+  if ( !error )
+    error = check_args();
+  if ( error ) {
+    cout << "Error: " << error << "\nUse -h for help.";
+    exit( 1 );
+  }
+  return argv - argv_orig;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+static char const* check_args() {
+  APITestProperties const &at_props = APITestProperties::instance();
+
+  if ( at_props.optimization_level_ > 2 )
+    return "only 0, 1 and 2 are allowed as values for the option --optimization-level";
+
+  return 0;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+/* vim:set et sw=2 ts=2: */

=== added file 'test/iterplans/apitest_props.cpp'
--- test/iterplans/apitest_props.cpp	1970-01-01 00:00:00 +0000
+++ test/iterplans/apitest_props.cpp	2014-02-10 00:46:59 +0000
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2006-2014 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// local
+#include "apitest_props.h"
+
+///////////////////////////////////////////////////////////////////////////////
+
+APITestProperties::APITestProperties() {
+  as_file_ = false;
+  compile_only_ = false;
+  debug_ = false;
+  debug_host_ = "127.0.0.1";
+  debug_port_ = 28028;
+  iter_plan_test_ = false;
+  jsoniq_ = false;
+  lib_module_ = false;
+  load_plan_ = false;
+  optimization_level_ = 1;
+  parse_only_ = false;
+  print_query_ = false;
+  serialize_only_query_ = false;
+  test_plan_serialization_ = false;
+  tz_ = 0;
+  use_serializer_ = false;
+}
+
+APITestProperties& APITestProperties::instance() {
+  static APITestProperties instance;
+  return instance;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+/* vim:set et sw=2 ts=2: */

=== added file 'test/iterplans/apitest_props.h'
--- test/iterplans/apitest_props.h	1970-01-01 00:00:00 +0000
+++ test/iterplans/apitest_props.h	2014-02-10 00:46:59 +0000
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2006-2014 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ZORBA_APITEST_PROPERTIES_H
+#define ZORBA_APITEST_PROPERTIES_H
+
+// standard
+#include <string>
+#include <vector>
+#include <utility>                      /* for pair */
+
+// Zorba
+#include <zorba/config.h>
+
+///////////////////////////////////////////////////////////////////////////////
+
+struct external_var {
+  std::string var_name;
+  std::string var_value;
+  bool        inline_file;
+
+  external_var() : inline_file( false ) { }
+};
+
+typedef std::vector<external_var> external_vars;
+
+typedef std::pair<std::string,std::string> serialization_param;
+typedef std::vector<serialization_param> serialization_params;
+
+struct APITestProperties {
+  static APITestProperties& instance();
+
+  bool          as_file_;
+  bool          compile_only_;
+  bool          debug_;
+  std::string   debug_host_;
+  unsigned      debug_port_;
+  std::string   dot_plan_file_;
+  external_vars external_vars_;
+  bool          iter_plan_test_;        // unused
+  bool          jsoniq_;
+  bool          lib_module_;
+  std::string   lib_path_;
+  bool          load_plan_;
+  unsigned      optimization_level_;
+#ifdef ZORBA_WITH_FILE_ACCESS
+  std::string   output_file_;
+#endif /* ZORBA_WITH_FILE_ACCESS */
+  bool          parse_only_;
+  bool          print_query_;
+  std::string   query_;
+  bool          serialize_only_query_;
+  bool          test_plan_serialization_;
+  int           tz_;
+  bool          use_serializer_;
+
+  serialization_params serialization_params_;
+
+private:
+  APITestProperties();
+};
+
+///////////////////////////////////////////////////////////////////////////////
+
+#endif /* ZORBA_APITEST_PROPERTIES_H */
+/* vim:set et sw=2 ts=2: */

=== modified file 'test/unit/context_item.cpp'
--- test/unit/context_item.cpp	2013-06-13 14:54:50 +0000
+++ test/unit/context_item.cpp	2014-02-10 00:46:59 +0000
@@ -26,8 +26,6 @@
 #include <zorba/options.h>
 #include <zorba/item_factory.h>
 
-#include "system/properties.h"
-
 
 int test_1(zorba::Zorba* zorba)
 {
@@ -214,8 +212,6 @@
   void* store = zorba::StoreManager::getStore();
   zorba::Zorba* zorba = zorba::Zorba::getInstance(store);
 
-  zorba::Properties::load(0, NULL);
-
   int result1 = 0;
   result1 = test_1(zorba);
 

=== modified file 'test/unit/ext_in_opt.cpp'
--- test/unit/ext_in_opt.cpp	2013-02-07 17:24:36 +0000
+++ test/unit/ext_in_opt.cpp	2014-02-10 00:46:59 +0000
@@ -29,8 +29,6 @@
 #include <zorba/xquery_exception.h>
 #include <zorba/diagnostic_list.h>
 
-#include "system/properties.h"
-
 
 using namespace zorba;
 
@@ -105,8 +103,6 @@
   Zorba* lZorba = Zorba::getInstance(lStore);
   bool lCorrectError = false;
 
-  zorba::Properties::load(0, NULL);
-
   try 
   {
     std::ifstream lIn("ext_in_opt.xq");

=== modified file 'test/unit/main_sequential.cpp'
--- test/unit/main_sequential.cpp	2013-02-07 17:24:36 +0000
+++ test/unit/main_sequential.cpp	2014-02-10 00:46:59 +0000
@@ -29,8 +29,6 @@
 #include <zorba/xquery_exception.h>
 #include <zorba/diagnostic_list.h>
 
-#include "system/properties.h"
-
 using namespace zorba;
 
 namespace zorba { namespace main_sequential {
@@ -80,8 +78,6 @@
   void* lStore = zorba::StoreManager::getStore();
   Zorba* lZorba = Zorba::getInstance(lStore);
 
-  zorba::Properties::load(0, NULL);
-
   try 
   {
     // test the sausalito use case

=== modified file 'test/unit/no_folding.cpp'
--- test/unit/no_folding.cpp	2013-05-28 00:58:27 +0000
+++ test/unit/no_folding.cpp	2014-02-10 00:46:59 +0000
@@ -28,8 +28,6 @@
 #include <zorba/empty_sequence.h>
 #include <zorba/xquery_exception.h>
 
-#include "system/properties.h"
-
 
 using namespace zorba;
 
@@ -80,8 +78,6 @@
   void* lStore = zorba::StoreManager::getStore();
   Zorba* lZorba = Zorba::getInstance(lStore);
 
-  zorba::Properties::load(0, NULL);
-
   try 
   {
     // test the sausalito use case

=== modified file 'test/unit/plan_serializer.cpp'
--- test/unit/plan_serializer.cpp	2013-05-28 00:58:27 +0000
+++ test/unit/plan_serializer.cpp	2014-02-10 00:46:59 +0000
@@ -14,17 +14,14 @@
  * limitations under the License.
  */
 
-#include <vector>
+// standard
 #include <fstream>
 #include <iostream>
 #include <sstream>
-#include <cassert>
 
+// Zorba
+#include <zorba/store_manager.h>
 #include <zorba/zorba.h>
-#include <zorba/store_manager.h>
-#include <zorba/zorba_exception.h>
-
-#include "system/properties.h"
 
 using namespace zorba;
 
@@ -53,7 +50,7 @@
      }
      return true;
   }
-  catch (ZorbaException& e) 
+  catch ( ZorbaException const &e ) 
   {
     std::cerr << e << std::endl;
     return false;
@@ -86,8 +83,6 @@
   void* lStore = zorba::StoreManager::getStore();
   Zorba* lZorba = Zorba::getInstance(lStore);
 
-  zorba::Properties::load(0, NULL);
-
   std::cout << "executing test 1" << std::endl;
   if (!plan_serializer1(lZorba))
     return 1;

=== modified file 'test/unit/staticcollectionmanager.cpp'
--- test/unit/staticcollectionmanager.cpp	2013-10-10 04:25:12 +0000
+++ test/unit/staticcollectionmanager.cpp	2014-02-10 00:46:59 +0000
@@ -25,8 +25,6 @@
 #include <zorba/singleton_item_sequence.h>
 #include <zorba/static_collection_manager.h>
 
-#include "system/properties.h"
-
 using namespace zorba;
 
 bool
@@ -534,8 +532,6 @@
   void* store = zorba::StoreManager::getStore();
   zorba::Zorba* z = zorba::Zorba::getInstance(store);
 
-  zorba::Properties::load(0, NULL);
-
   std::cout << "executing example 1" << std::endl;
   if (!staticcollectionamanger1(z))
     return 1;

=== modified file 'test/unit/streamable_string.cpp'
--- test/unit/streamable_string.cpp	2013-02-07 17:24:36 +0000
+++ test/unit/streamable_string.cpp	2014-02-10 00:46:59 +0000
@@ -29,8 +29,6 @@
 #include <zorba/xquery_exception.h>
 #include <zorba/diagnostic_list.h>
 
-#include "system/properties.h"
-
 
 using namespace zorba;
 


Follow ups