// This code was generated by CLI, a command line interface
// compiler for C++.
//

#include <odb/options.hxx>

#include <map>
#include <set>
#include <string>
#include <vector>
#include <ostream>
#include <sstream>
#include <cstring>
#include <fstream>

namespace cli
{
  // unknown_option
  //
  unknown_option::
  ~unknown_option () throw ()
  {
  }

  void unknown_option::
  print (std::ostream& os) const
  {
    os << "unknown option '" << option () << "'";
  }

  const char* unknown_option::
  what () const throw ()
  {
    return "unknown option";
  }

  // unknown_argument
  //
  unknown_argument::
  ~unknown_argument () throw ()
  {
  }

  void unknown_argument::
  print (std::ostream& os) const
  {
    os << "unknown argument '" << argument () << "'";
  }

  const char* unknown_argument::
  what () const throw ()
  {
    return "unknown argument";
  }

  // missing_value
  //
  missing_value::
  ~missing_value () throw ()
  {
  }

  void missing_value::
  print (std::ostream& os) const
  {
    os << "missing value for option '" << option () << "'";
  }

  const char* missing_value::
  what () const throw ()
  {
    return "missing option value";
  }

  // invalid_value
  //
  invalid_value::
  ~invalid_value () throw ()
  {
  }

  void invalid_value::
  print (std::ostream& os) const
  {
    os << "invalid value '" << value () << "' for option '"
       << option () << "'";
  }

  const char* invalid_value::
  what () const throw ()
  {
    return "invalid option value";
  }

  // eos_reached
  //
  void eos_reached::
  print (std::ostream& os) const
  {
    os << what ();
  }

  const char* eos_reached::
  what () const throw ()
  {
    return "end of argument stream reached";
  }

  // file_io_failure
  //
  file_io_failure::
  ~file_io_failure () throw ()
  {
  }

  void file_io_failure::
  print (std::ostream& os) const
  {
    os << "unable to open file '" << file () << "' or read failure";
  }

  const char* file_io_failure::
  what () const throw ()
  {
    return "unable to open file or read failure";
  }

  // unmatched_quote
  //
  unmatched_quote::
  ~unmatched_quote () throw ()
  {
  }

  void unmatched_quote::
  print (std::ostream& os) const
  {
    os << "unmatched quote in argument '" << argument () << "'";
  }

  const char* unmatched_quote::
  what () const throw ()
  {
    return "unmatched quote";
  }

  // scanner
  //
  scanner::
  ~scanner ()
  {
  }

  // argv_scanner
  //
  bool argv_scanner::
  more ()
  {
    return i_ < argc_;
  }

  const char* argv_scanner::
  peek ()
  {
    if (i_ < argc_)
      return argv_[i_];
    else
      throw eos_reached ();
  }

  const char* argv_scanner::
  next ()
  {
    if (i_ < argc_)
    {
      const char* r (argv_[i_]);

      if (erase_)
      {
        for (int i (i_ + 1); i < argc_; ++i)
          argv_[i - 1] = argv_[i];

        --argc_;
        argv_[argc_] = 0;
      }
      else
        ++i_;

      return r;
    }
    else
      throw eos_reached ();
  }

  void argv_scanner::
  skip ()
  {
    if (i_ < argc_)
      ++i_;
    else
      throw eos_reached ();
  }

  // argv_file_scanner
  //
  bool argv_file_scanner::
  more ()
  {
    if (!args_.empty ())
      return true;

    while (base::more ())
    {
      // See if the next argument is the file option.
      //
      const char* a (base::peek ());
      const option_info* oi;

      if (!skip_ && (oi = find (a)))
      {
        base::next ();

        if (!base::more ())
          throw missing_value (oi->option);

        if (oi->search_func != 0)
        {
          std::string f (oi->search_func (base::next (), oi->arg));

          if (!f.empty ())
            load (f);
        }
        else
          load (base::next ());

        if (!args_.empty ())
          return true;
      }
      else
      {
        if (!skip_)
          skip_ = (std::strcmp (a, "--") == 0);

        return true;
      }
    }

    return false;
  }

  const char* argv_file_scanner::
  peek ()
  {
    if (!more ())
      throw eos_reached ();

    return args_.empty () ? base::peek () : args_.front ().c_str ();
  }

  const char* argv_file_scanner::
  next ()
  {
    if (!more ())
      throw eos_reached ();

    if (args_.empty ())
      return base::next ();
    else
    {
      hold_.swap (args_.front ());
      args_.pop_front ();
      return hold_.c_str ();
    }
  }

  void argv_file_scanner::
  skip ()
  {
    if (!more ())
      throw eos_reached ();

    if (args_.empty ())
      return base::skip ();
    else
      args_.pop_front ();
  }

  const argv_file_scanner::option_info* argv_file_scanner::
  find (const char* a) const
  {
    for (std::size_t i (0); i < options_count_; ++i)
      if (std::strcmp (a, options_[i].option) == 0)
        return &options_[i];

    return 0;
  }

  void argv_file_scanner::
  load (const std::string& file)
  {
    using namespace std;

    ifstream is (file.c_str ());

    if (!is.is_open ())
      throw file_io_failure (file);

    while (!is.eof ())
    {
      string line;
      getline (is, line);

      if (is.fail () && !is.eof ())
        throw file_io_failure (file);

      string::size_type n (line.size ());

      // Trim the line from leading and trailing whitespaces.
      //
      if (n != 0)
      {
        const char* f (line.c_str ());
        const char* l (f + n);

        const char* of (f);
        while (f < l && (*f == ' ' || *f == '\t' || *f == '\r'))
          ++f;

        --l;

        const char* ol (l);
        while (l > f && (*l == ' ' || *l == '\t' || *l == '\r'))
          --l;

        if (f != of || l != ol)
          line = f <= l ? string (f, l - f + 1) : string ();
      }

      // Ignore empty lines, those that start with #.
      //
      if (line.empty () || line[0] == '#')
        continue;

      string::size_type p (line.find (' '));

      if (p == string::npos)
      {
        if (!skip_)
          skip_ = (line == "--");

        args_.push_back (line);
      }
      else
      {
        string s1 (line, 0, p);

        // Skip leading whitespaces in the argument.
        //
        n = line.size ();
        for (++p; p < n; ++p)
        {
          char c (line[p]);

          if (c != ' ' && c != '\t' && c != '\r')
            break;
        }

        string s2 (line, p);

        // If the string is wrapped in quotes, remove them.
        //
        n = s2.size ();
        char cf (s2[0]), cl (s2[n - 1]);

        if (cf == '"' || cf == '\'' || cl == '"' || cl == '\'')
        {
          if (n == 1 || cf != cl)
            throw unmatched_quote (s2);

          s2 = string (s2, 1, n - 2);
        }

        const option_info* oi;
        if (!skip_ && (oi = find (s1.c_str ())))
        {
          if (s2.empty ())
            throw missing_value (oi->option);

          if (oi->search_func != 0)
          {
            std::string f (oi->search_func (s2.c_str (), oi->arg));

            if (!f.empty ())
              load (f);
          }
          else
            load (s2);
        }
        else
        {
          args_.push_back (s1);
          args_.push_back (s2);
        }
      }
    }
  }

  void options::
  push_back (const option& o)
  {
    container_type::size_type n (size ());
    container_type::push_back (o);
    map_[o.name ()] = n;

    for (option_names::const_iterator i (o.aliases ().begin ());
         i != o.aliases ().end (); ++i)
      map_[*i] = n;
  }

  template <typename X>
  struct parser
  {
    static void
    parse (X& x, bool& xs, scanner& s)
    {
      std::string o (s.next ());

      if (s.more ())
      {
        std::string v (s.next ());
        std::istringstream is (v);
        if (!(is >> x && is.eof ()))
          throw invalid_value (o, v);
      }
      else
        throw missing_value (o);

      xs = true;
    }
  };

  template <>
  struct parser<bool>
  {
    static void
    parse (bool& x, scanner& s)
    {
      s.next ();
      x = true;
    }
  };

  template <>
  struct parser<std::string>
  {
    static void
    parse (std::string& x, bool& xs, scanner& s)
    {
      const char* o (s.next ());

      if (s.more ())
        x = s.next ();
      else
        throw missing_value (o);

      xs = true;
    }
  };

  template <typename X>
  struct parser<std::vector<X> >
  {
    static void
    parse (std::vector<X>& c, bool& xs, scanner& s)
    {
      X x;
      bool dummy;
      parser<X>::parse (x, dummy, s);
      c.push_back (x);
      xs = true;
    }
  };

  template <typename X>
  struct parser<std::set<X> >
  {
    static void
    parse (std::set<X>& c, bool& xs, scanner& s)
    {
      X x;
      bool dummy;
      parser<X>::parse (x, dummy, s);
      c.insert (x);
      xs = true;
    }
  };

  template <typename K, typename V>
  struct parser<std::map<K, V> >
  {
    static void
    parse (std::map<K, V>& m, bool& xs, scanner& s)
    {
      std::string o (s.next ());

      if (s.more ())
      {
        std::string ov (s.next ());
        std::string::size_type p = ov.find ('=');

        if (p == std::string::npos)
        {
          K k = K ();

          if (!ov.empty ())
          {
            std::istringstream ks (ov);

            if (!(ks >> k && ks.eof ()))
              throw invalid_value (o, ov);
          }

          m[k] = V ();
        }
        else
        {
          K k = K ();
          V v = V ();
          std::string kstr (ov, 0, p);
          std::string vstr (ov, p + 1);

          if (!kstr.empty ())
          {
            std::istringstream ks (kstr);

            if (!(ks >> k && ks.eof ()))
              throw invalid_value (o, ov);
          }

          if (!vstr.empty ())
          {
            std::istringstream vs (vstr);

            if (!(vs >> v && vs.eof ()))
              throw invalid_value (o, ov);
          }

          m[k] = v;
        }
      }
      else
        throw missing_value (o);

      xs = true;
    }
  };

  template <typename X, typename T, T X::*M>
  void
  thunk (X& x, scanner& s)
  {
    parser<T>::parse (x.*M, s);
  }

  template <typename X, typename T, T X::*M, bool X::*S>
  void
  thunk (X& x, scanner& s)
  {
    parser<T>::parse (x.*M, x.*S, s);
  }
}

#include <map>
#include <cstring>

// options
//

options::
options (int& argc,
         char** argv,
         bool erase,
         ::cli::unknown_mode opt,
         ::cli::unknown_mode arg)
: help_ (),
  version_ (),
  I_ (),
  I_specified_ (false),
  D_ (),
  D_specified_ (false),
  U_ (),
  U_specified_ (false),
  database_ (),
  database_specified_ (false),
  generate_query_ (),
  generate_schema_ (),
  schema_format_ (),
  schema_format_specified_ (false),
  schema_name_ (""),
  schema_name_specified_ (false),
  default_pointer_ ("*"),
  default_pointer_specified_ (false),
  profile_ (),
  profile_specified_ (false),
  schema_ (),
  schema_specified_ (false),
  table_prefix_ (),
  table_prefix_specified_ (false),
  output_dir_ (),
  output_dir_specified_ (false),
  odb_file_suffix_ ("-odb"),
  odb_file_suffix_specified_ (false),
  hxx_suffix_ (".hxx"),
  hxx_suffix_specified_ (false),
  ixx_suffix_ (".ixx"),
  ixx_suffix_specified_ (false),
  cxx_suffix_ (".cxx"),
  cxx_suffix_specified_ (false),
  sql_suffix_ (".sql"),
  sql_suffix_specified_ (false),
  hxx_prologue_ (),
  hxx_prologue_specified_ (false),
  ixx_prologue_ (),
  ixx_prologue_specified_ (false),
  cxx_prologue_ (),
  cxx_prologue_specified_ (false),
  sql_prologue_ (),
  sql_prologue_specified_ (false),
  hxx_epilogue_ (),
  hxx_epilogue_specified_ (false),
  ixx_epilogue_ (),
  ixx_epilogue_specified_ (false),
  cxx_epilogue_ (),
  cxx_epilogue_specified_ (false),
  sql_epilogue_ (),
  sql_epilogue_specified_ (false),
  hxx_prologue_file_ (),
  hxx_prologue_file_specified_ (false),
  ixx_prologue_file_ (),
  ixx_prologue_file_specified_ (false),
  cxx_prologue_file_ (),
  cxx_prologue_file_specified_ (false),
  sql_prologue_file_ (),
  sql_prologue_file_specified_ (false),
  hxx_epilogue_file_ (),
  hxx_epilogue_file_specified_ (false),
  ixx_epilogue_file_ (),
  ixx_epilogue_file_specified_ (false),
  cxx_epilogue_file_ (),
  cxx_epilogue_file_specified_ (false),
  sql_epilogue_file_ (),
  sql_epilogue_file_specified_ (false),
  odb_prologue_ (),
  odb_prologue_specified_ (false),
  odb_prologue_file_ (),
  odb_prologue_file_specified_ (false),
  odb_epilogue_ (),
  odb_epilogue_specified_ (false),
  odb_epilogue_file_ (),
  odb_epilogue_file_specified_ (false),
  include_with_brackets_ (),
  include_prefix_ (),
  include_prefix_specified_ (false),
  include_regex_ (),
  include_regex_specified_ (false),
  include_regex_trace_ (),
  guard_prefix_ (),
  guard_prefix_specified_ (false),
  options_file_ (),
  options_file_specified_ (false),
  x_ (),
  x_specified_ (false),
  v_ (),
  trace_ (),
  mssql_server_version_ (10, 0),
  mssql_server_version_specified_ (false),
  mssql_short_limit_ (1024),
  mssql_short_limit_specified_ (false),
  mysql_engine_ ("InnoDB"),
  mysql_engine_specified_ (false),
  oracle_client_version_ (10, 1),
  oracle_client_version_specified_ (false),
  sqlite_lax_auto_id_ ()
{
  ::cli::argv_scanner s (argc, argv, erase);
  _parse (s, opt, arg);
}

options::
options (int start,
         int& argc,
         char** argv,
         bool erase,
         ::cli::unknown_mode opt,
         ::cli::unknown_mode arg)
: help_ (),
  version_ (),
  I_ (),
  I_specified_ (false),
  D_ (),
  D_specified_ (false),
  U_ (),
  U_specified_ (false),
  database_ (),
  database_specified_ (false),
  generate_query_ (),
  generate_schema_ (),
  schema_format_ (),
  schema_format_specified_ (false),
  schema_name_ (""),
  schema_name_specified_ (false),
  default_pointer_ ("*"),
  default_pointer_specified_ (false),
  profile_ (),
  profile_specified_ (false),
  schema_ (),
  schema_specified_ (false),
  table_prefix_ (),
  table_prefix_specified_ (false),
  output_dir_ (),
  output_dir_specified_ (false),
  odb_file_suffix_ ("-odb"),
  odb_file_suffix_specified_ (false),
  hxx_suffix_ (".hxx"),
  hxx_suffix_specified_ (false),
  ixx_suffix_ (".ixx"),
  ixx_suffix_specified_ (false),
  cxx_suffix_ (".cxx"),
  cxx_suffix_specified_ (false),
  sql_suffix_ (".sql"),
  sql_suffix_specified_ (false),
  hxx_prologue_ (),
  hxx_prologue_specified_ (false),
  ixx_prologue_ (),
  ixx_prologue_specified_ (false),
  cxx_prologue_ (),
  cxx_prologue_specified_ (false),
  sql_prologue_ (),
  sql_prologue_specified_ (false),
  hxx_epilogue_ (),
  hxx_epilogue_specified_ (false),
  ixx_epilogue_ (),
  ixx_epilogue_specified_ (false),
  cxx_epilogue_ (),
  cxx_epilogue_specified_ (false),
  sql_epilogue_ (),
  sql_epilogue_specified_ (false),
  hxx_prologue_file_ (),
  hxx_prologue_file_specified_ (false),
  ixx_prologue_file_ (),
  ixx_prologue_file_specified_ (false),
  cxx_prologue_file_ (),
  cxx_prologue_file_specified_ (false),
  sql_prologue_file_ (),
  sql_prologue_file_specified_ (false),
  hxx_epilogue_file_ (),
  hxx_epilogue_file_specified_ (false),
  ixx_epilogue_file_ (),
  ixx_epilogue_file_specified_ (false),
  cxx_epilogue_file_ (),
  cxx_epilogue_file_specified_ (false),
  sql_epilogue_file_ (),
  sql_epilogue_file_specified_ (false),
  odb_prologue_ (),
  odb_prologue_specified_ (false),
  odb_prologue_file_ (),
  odb_prologue_file_specified_ (false),
  odb_epilogue_ (),
  odb_epilogue_specified_ (false),
  odb_epilogue_file_ (),
  odb_epilogue_file_specified_ (false),
  include_with_brackets_ (),
  include_prefix_ (),
  include_prefix_specified_ (false),
  include_regex_ (),
  include_regex_specified_ (false),
  include_regex_trace_ (),
  guard_prefix_ (),
  guard_prefix_specified_ (false),
  options_file_ (),
  options_file_specified_ (false),
  x_ (),
  x_specified_ (false),
  v_ (),
  trace_ (),
  mssql_server_version_ (10, 0),
  mssql_server_version_specified_ (false),
  mssql_short_limit_ (1024),
  mssql_short_limit_specified_ (false),
  mysql_engine_ ("InnoDB"),
  mysql_engine_specified_ (false),
  oracle_client_version_ (10, 1),
  oracle_client_version_specified_ (false),
  sqlite_lax_auto_id_ ()
{
  ::cli::argv_scanner s (start, argc, argv, erase);
  _parse (s, opt, arg);
}

options::
options (int& argc,
         char** argv,
         int& end,
         bool erase,
         ::cli::unknown_mode opt,
         ::cli::unknown_mode arg)
: help_ (),
  version_ (),
  I_ (),
  I_specified_ (false),
  D_ (),
  D_specified_ (false),
  U_ (),
  U_specified_ (false),
  database_ (),
  database_specified_ (false),
  generate_query_ (),
  generate_schema_ (),
  schema_format_ (),
  schema_format_specified_ (false),
  schema_name_ (""),
  schema_name_specified_ (false),
  default_pointer_ ("*"),
  default_pointer_specified_ (false),
  profile_ (),
  profile_specified_ (false),
  schema_ (),
  schema_specified_ (false),
  table_prefix_ (),
  table_prefix_specified_ (false),
  output_dir_ (),
  output_dir_specified_ (false),
  odb_file_suffix_ ("-odb"),
  odb_file_suffix_specified_ (false),
  hxx_suffix_ (".hxx"),
  hxx_suffix_specified_ (false),
  ixx_suffix_ (".ixx"),
  ixx_suffix_specified_ (false),
  cxx_suffix_ (".cxx"),
  cxx_suffix_specified_ (false),
  sql_suffix_ (".sql"),
  sql_suffix_specified_ (false),
  hxx_prologue_ (),
  hxx_prologue_specified_ (false),
  ixx_prologue_ (),
  ixx_prologue_specified_ (false),
  cxx_prologue_ (),
  cxx_prologue_specified_ (false),
  sql_prologue_ (),
  sql_prologue_specified_ (false),
  hxx_epilogue_ (),
  hxx_epilogue_specified_ (false),
  ixx_epilogue_ (),
  ixx_epilogue_specified_ (false),
  cxx_epilogue_ (),
  cxx_epilogue_specified_ (false),
  sql_epilogue_ (),
  sql_epilogue_specified_ (false),
  hxx_prologue_file_ (),
  hxx_prologue_file_specified_ (false),
  ixx_prologue_file_ (),
  ixx_prologue_file_specified_ (false),
  cxx_prologue_file_ (),
  cxx_prologue_file_specified_ (false),
  sql_prologue_file_ (),
  sql_prologue_file_specified_ (false),
  hxx_epilogue_file_ (),
  hxx_epilogue_file_specified_ (false),
  ixx_epilogue_file_ (),
  ixx_epilogue_file_specified_ (false),
  cxx_epilogue_file_ (),
  cxx_epilogue_file_specified_ (false),
  sql_epilogue_file_ (),
  sql_epilogue_file_specified_ (false),
  odb_prologue_ (),
  odb_prologue_specified_ (false),
  odb_prologue_file_ (),
  odb_prologue_file_specified_ (false),
  odb_epilogue_ (),
  odb_epilogue_specified_ (false),
  odb_epilogue_file_ (),
  odb_epilogue_file_specified_ (false),
  include_with_brackets_ (),
  include_prefix_ (),
  include_prefix_specified_ (false),
  include_regex_ (),
  include_regex_specified_ (false),
  include_regex_trace_ (),
  guard_prefix_ (),
  guard_prefix_specified_ (false),
  options_file_ (),
  options_file_specified_ (false),
  x_ (),
  x_specified_ (false),
  v_ (),
  trace_ (),
  mssql_server_version_ (10, 0),
  mssql_server_version_specified_ (false),
  mssql_short_limit_ (1024),
  mssql_short_limit_specified_ (false),
  mysql_engine_ ("InnoDB"),
  mysql_engine_specified_ (false),
  oracle_client_version_ (10, 1),
  oracle_client_version_specified_ (false),
  sqlite_lax_auto_id_ ()
{
  ::cli::argv_scanner s (argc, argv, erase);
  _parse (s, opt, arg);
  end = s.end ();
}

options::
options (int start,
         int& argc,
         char** argv,
         int& end,
         bool erase,
         ::cli::unknown_mode opt,
         ::cli::unknown_mode arg)
: help_ (),
  version_ (),
  I_ (),
  I_specified_ (false),
  D_ (),
  D_specified_ (false),
  U_ (),
  U_specified_ (false),
  database_ (),
  database_specified_ (false),
  generate_query_ (),
  generate_schema_ (),
  schema_format_ (),
  schema_format_specified_ (false),
  schema_name_ (""),
  schema_name_specified_ (false),
  default_pointer_ ("*"),
  default_pointer_specified_ (false),
  profile_ (),
  profile_specified_ (false),
  schema_ (),
  schema_specified_ (false),
  table_prefix_ (),
  table_prefix_specified_ (false),
  output_dir_ (),
  output_dir_specified_ (false),
  odb_file_suffix_ ("-odb"),
  odb_file_suffix_specified_ (false),
  hxx_suffix_ (".hxx"),
  hxx_suffix_specified_ (false),
  ixx_suffix_ (".ixx"),
  ixx_suffix_specified_ (false),
  cxx_suffix_ (".cxx"),
  cxx_suffix_specified_ (false),
  sql_suffix_ (".sql"),
  sql_suffix_specified_ (false),
  hxx_prologue_ (),
  hxx_prologue_specified_ (false),
  ixx_prologue_ (),
  ixx_prologue_specified_ (false),
  cxx_prologue_ (),
  cxx_prologue_specified_ (false),
  sql_prologue_ (),
  sql_prologue_specified_ (false),
  hxx_epilogue_ (),
  hxx_epilogue_specified_ (false),
  ixx_epilogue_ (),
  ixx_epilogue_specified_ (false),
  cxx_epilogue_ (),
  cxx_epilogue_specified_ (false),
  sql_epilogue_ (),
  sql_epilogue_specified_ (false),
  hxx_prologue_file_ (),
  hxx_prologue_file_specified_ (false),
  ixx_prologue_file_ (),
  ixx_prologue_file_specified_ (false),
  cxx_prologue_file_ (),
  cxx_prologue_file_specified_ (false),
  sql_prologue_file_ (),
  sql_prologue_file_specified_ (false),
  hxx_epilogue_file_ (),
  hxx_epilogue_file_specified_ (false),
  ixx_epilogue_file_ (),
  ixx_epilogue_file_specified_ (false),
  cxx_epilogue_file_ (),
  cxx_epilogue_file_specified_ (false),
  sql_epilogue_file_ (),
  sql_epilogue_file_specified_ (false),
  odb_prologue_ (),
  odb_prologue_specified_ (false),
  odb_prologue_file_ (),
  odb_prologue_file_specified_ (false),
  odb_epilogue_ (),
  odb_epilogue_specified_ (false),
  odb_epilogue_file_ (),
  odb_epilogue_file_specified_ (false),
  include_with_brackets_ (),
  include_prefix_ (),
  include_prefix_specified_ (false),
  include_regex_ (),
  include_regex_specified_ (false),
  include_regex_trace_ (),
  guard_prefix_ (),
  guard_prefix_specified_ (false),
  options_file_ (),
  options_file_specified_ (false),
  x_ (),
  x_specified_ (false),
  v_ (),
  trace_ (),
  mssql_server_version_ (10, 0),
  mssql_server_version_specified_ (false),
  mssql_short_limit_ (1024),
  mssql_short_limit_specified_ (false),
  mysql_engine_ ("InnoDB"),
  mysql_engine_specified_ (false),
  oracle_client_version_ (10, 1),
  oracle_client_version_specified_ (false),
  sqlite_lax_auto_id_ ()
{
  ::cli::argv_scanner s (start, argc, argv, erase);
  _parse (s, opt, arg);
  end = s.end ();
}

options::
options (::cli::scanner& s,
         ::cli::unknown_mode opt,
         ::cli::unknown_mode arg)
: help_ (),
  version_ (),
  I_ (),
  I_specified_ (false),
  D_ (),
  D_specified_ (false),
  U_ (),
  U_specified_ (false),
  database_ (),
  database_specified_ (false),
  generate_query_ (),
  generate_schema_ (),
  schema_format_ (),
  schema_format_specified_ (false),
  schema_name_ (""),
  schema_name_specified_ (false),
  default_pointer_ ("*"),
  default_pointer_specified_ (false),
  profile_ (),
  profile_specified_ (false),
  schema_ (),
  schema_specified_ (false),
  table_prefix_ (),
  table_prefix_specified_ (false),
  output_dir_ (),
  output_dir_specified_ (false),
  odb_file_suffix_ ("-odb"),
  odb_file_suffix_specified_ (false),
  hxx_suffix_ (".hxx"),
  hxx_suffix_specified_ (false),
  ixx_suffix_ (".ixx"),
  ixx_suffix_specified_ (false),
  cxx_suffix_ (".cxx"),
  cxx_suffix_specified_ (false),
  sql_suffix_ (".sql"),
  sql_suffix_specified_ (false),
  hxx_prologue_ (),
  hxx_prologue_specified_ (false),
  ixx_prologue_ (),
  ixx_prologue_specified_ (false),
  cxx_prologue_ (),
  cxx_prologue_specified_ (false),
  sql_prologue_ (),
  sql_prologue_specified_ (false),
  hxx_epilogue_ (),
  hxx_epilogue_specified_ (false),
  ixx_epilogue_ (),
  ixx_epilogue_specified_ (false),
  cxx_epilogue_ (),
  cxx_epilogue_specified_ (false),
  sql_epilogue_ (),
  sql_epilogue_specified_ (false),
  hxx_prologue_file_ (),
  hxx_prologue_file_specified_ (false),
  ixx_prologue_file_ (),
  ixx_prologue_file_specified_ (false),
  cxx_prologue_file_ (),
  cxx_prologue_file_specified_ (false),
  sql_prologue_file_ (),
  sql_prologue_file_specified_ (false),
  hxx_epilogue_file_ (),
  hxx_epilogue_file_specified_ (false),
  ixx_epilogue_file_ (),
  ixx_epilogue_file_specified_ (false),
  cxx_epilogue_file_ (),
  cxx_epilogue_file_specified_ (false),
  sql_epilogue_file_ (),
  sql_epilogue_file_specified_ (false),
  odb_prologue_ (),
  odb_prologue_specified_ (false),
  odb_prologue_file_ (),
  odb_prologue_file_specified_ (false),
  odb_epilogue_ (),
  odb_epilogue_specified_ (false),
  odb_epilogue_file_ (),
  odb_epilogue_file_specified_ (false),
  include_with_brackets_ (),
  include_prefix_ (),
  include_prefix_specified_ (false),
  include_regex_ (),
  include_regex_specified_ (false),
  include_regex_trace_ (),
  guard_prefix_ (),
  guard_prefix_specified_ (false),
  options_file_ (),
  options_file_specified_ (false),
  x_ (),
  x_specified_ (false),
  v_ (),
  trace_ (),
  mssql_server_version_ (10, 0),
  mssql_server_version_specified_ (false),
  mssql_short_limit_ (1024),
  mssql_short_limit_specified_ (false),
  mysql_engine_ ("InnoDB"),
  mysql_engine_specified_ (false),
  oracle_client_version_ (10, 1),
  oracle_client_version_specified_ (false),
  sqlite_lax_auto_id_ ()
{
  _parse (s, opt, arg);
}

void options::
print_usage (::std::ostream& os)
{
  os << "--help                      Print usage information and exit." << ::std::endl;

  os << "--version                   Print version and exit." << ::std::endl;

  os << "-I <dir>                    Add <dir> to the beginning of the list of" << ::std::endl
     << "                            directories to be searched for included header" << ::std::endl
     << "                            files." << ::std::endl;

  os << "-D <name>[=<def>]           Define macro <name> with definition <def>." << ::std::endl;

  os << "-U <name>                   Cancel any previous definitions of macro <name>," << ::std::endl
     << "                            either built-in or provided with the '-D' option." << ::std::endl;

  os << "--database|-d <db>          Generate code for the <db> database." << ::std::endl;

  os << "--generate-query|-q         Generate query support code." << ::std::endl;

  os << "--generate-schema|-s        Generate the database schema." << ::std::endl;

  os << "--schema-format <format>    Generate the database schema in the specified" << ::std::endl
     << "                            format." << ::std::endl;

  os << "--schema-name <name>        Use <name> as the database schema name." << ::std::endl;

  os << "--default-pointer <ptr>     Use <ptr> as the default pointer for persistent" << ::std::endl
     << "                            objects and views." << ::std::endl;

  os << "--profile|-p <name>         Specify a profile that should be used during" << ::std::endl
     << "                            compilation." << ::std::endl;

  os << "--schema <schema>           Specify a database schema (database namespace) that" << ::std::endl
     << "                            should be assigned to the persistent classes in the" << ::std::endl
     << "                            file being compiled." << ::std::endl;

  os << "--table-prefix <prefix>     Add <prefix> to table and index names." << ::std::endl;

  os << "--output-dir|-o <dir>       Write the generated files to <dir> instead of the" << ::std::endl
     << "                            current directory." << ::std::endl;

  os << "--odb-file-suffix <suffix>  Use <suffix> instead of the default '-odb' to" << ::std::endl
     << "                            construct the names of the generated C++ files." << ::std::endl;

  os << "--hxx-suffix <suffix>       Use <suffix> instead of the default '.hxx' to" << ::std::endl
     << "                            construct the name of the generated C++ header" << ::std::endl
     << "                            file." << ::std::endl;

  os << "--ixx-suffix <suffix>       Use <suffix> instead of the default '.ixx' to" << ::std::endl
     << "                            construct the name of the generated C++ inline" << ::std::endl
     << "                            file." << ::std::endl;

  os << "--cxx-suffix <suffix>       Use <suffix> instead of the default '.cxx' to" << ::std::endl
     << "                            construct the name of the generated C++ source" << ::std::endl
     << "                            file." << ::std::endl;

  os << "--sql-suffix <suffix>       Use <suffix> instead of the default '.sql' to" << ::std::endl
     << "                            construct the name of the generated database schema" << ::std::endl
     << "                            file." << ::std::endl;

  os << "--hxx-prologue <text>       Insert <text> at the beginning of the generated C++" << ::std::endl
     << "                            header file." << ::std::endl;

  os << "--ixx-prologue <text>       Insert <text> at the beginning of the generated C++" << ::std::endl
     << "                            inline file." << ::std::endl;

  os << "--cxx-prologue <text>       Insert <text> at the beginning of the generated C++" << ::std::endl
     << "                            source file." << ::std::endl;

  os << "--sql-prologue <text>       Insert <text> at the beginning of the generated" << ::std::endl
     << "                            database schema file." << ::std::endl;

  os << "--hxx-epilogue <text>       Insert <text> at the end of the generated C++" << ::std::endl
     << "                            header file." << ::std::endl;

  os << "--ixx-epilogue <text>       Insert <text> at the end of the generated C++" << ::std::endl
     << "                            inline file." << ::std::endl;

  os << "--cxx-epilogue <text>       Insert <text> at the end of the generated C++" << ::std::endl
     << "                            source file." << ::std::endl;

  os << "--sql-epilogue <text>       Insert <text> at the end of the generated database" << ::std::endl
     << "                            schema file." << ::std::endl;

  os << "--hxx-prologue-file <file>  Insert the content of <file> at the beginning of" << ::std::endl
     << "                            the generated C++ header file." << ::std::endl;

  os << "--ixx-prologue-file <file>  Insert the content of <file> at the beginning of" << ::std::endl
     << "                            the generated C++ inline file." << ::std::endl;

  os << "--cxx-prologue-file <file>  Insert the content of <file> at the beginning of" << ::std::endl
     << "                            the generated C++ source file." << ::std::endl;

  os << "--sql-prologue-file <file>  Insert the content of <file> at the beginning of" << ::std::endl
     << "                            the generated database schema file." << ::std::endl;

  os << "--hxx-epilogue-file <file>  Insert the content of <file> at the end of the" << ::std::endl
     << "                            generated C++ header file." << ::std::endl;

  os << "--ixx-epilogue-file <file>  Insert the content of <file> at the end of the" << ::std::endl
     << "                            generated C++ inline file." << ::std::endl;

  os << "--cxx-epilogue-file <file>  Insert the content of <file> at the end of the" << ::std::endl
     << "                            generated C++ source file." << ::std::endl;

  os << "--sql-epilogue-file <file>  Insert the content of <file> at the end of the" << ::std::endl
     << "                            generated database schema file." << ::std::endl;

  os << "--odb-prologue <text>       Compile <text> before the input header file." << ::std::endl;

  os << "--odb-prologue-file <file>  Compile <file> contents before the input header" << ::std::endl
     << "                            file." << ::std::endl;

  os << "--odb-epilogue <text>       Compile <text> after the input header file." << ::std::endl;

  os << "--odb-epilogue-file <file>  Compile <file> contents after the input header" << ::std::endl
     << "                            file." << ::std::endl;

  os << "--include-with-brackets     Use angle brackets (<>) instead of quotes (\"\") in" << ::std::endl
     << "                            the generated '#include' directives." << ::std::endl;

  os << "--include-prefix <prefix>   Add <prefix> to the generated '#include' directive" << ::std::endl
     << "                            paths." << ::std::endl;

  os << "--include-regex <regex>     Add <regex> to the list of regular expressions used" << ::std::endl
     << "                            to transform generated '#include' directive paths." << ::std::endl;

  os << "--include-regex-trace       Trace the process of applying regular expressions" << ::std::endl
     << "                            specified with the '--include-regex' option." << ::std::endl;

  os << "--guard-prefix <prefix>     Add <prefix> to the generated header inclusion" << ::std::endl
     << "                            guards." << ::std::endl;

  os << "--options-file <file>       Read additional options from <file> with each" << ::std::endl
     << "                            option appearing on a separate line optionally" << ::std::endl
     << "                            followed by space and an option value." << ::std::endl;

  os << "-x <option>                 Pass <option> to the underlying C++ compiler" << ::std::endl
     << "                            ('g++')." << ::std::endl;

  os << "-v                          Print the commands executed to run the stages of" << ::std::endl
     << "                            compilation." << ::std::endl;

  os << "--trace                     Trace the compilation process." << ::std::endl;

  os << "--mssql-server-version <v>  Specify the minimum SQL Server server version with" << ::std::endl
     << "                            which the generated C++ code will be used." << ::std::endl;

  os << "--mssql-short-limit <size>  Specify the short data size limit." << ::std::endl;

  os << "--mysql-engine <engine>     Use <engine> instead of the default 'InnoDB' in the" << ::std::endl
     << "                            generated database schema file." << ::std::endl;

  os << "--oracle-client-version <v> Specify the minimum Oracle client library (OCI)" << ::std::endl
     << "                            version with which the generated C++ code will be" << ::std::endl
     << "                            linked." << ::std::endl;

  os << "--sqlite-lax-auto-id        Do not force monotonically increasing" << ::std::endl
     << "                            automatically-assigned object ids." << ::std::endl;
}

static ::cli::options _cli_options_desc_;

struct _cli_options_desc_init
{
  _cli_options_desc_init (::cli::options& os)
  {
    // --help
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--help", a, true, dv);
      os.push_back (o);
    }

    // --version
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--version", a, true, dv);
      os.push_back (o);
    }

    // -I
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("-I", a, false, dv);
      os.push_back (o);
    }

    // -D
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("-D", a, false, dv);
      os.push_back (o);
    }

    // -U
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("-U", a, false, dv);
      os.push_back (o);
    }

    // --database
    //
    {
      ::cli::option_names a;
      a.push_back ("-d");
      std::string dv;
      ::cli::option o ("--database", a, false, dv);
      os.push_back (o);
    }

    // --generate-query
    //
    {
      ::cli::option_names a;
      a.push_back ("-q");
      std::string dv;
      ::cli::option o ("--generate-query", a, true, dv);
      os.push_back (o);
    }

    // --generate-schema
    //
    {
      ::cli::option_names a;
      a.push_back ("-s");
      std::string dv;
      ::cli::option o ("--generate-schema", a, true, dv);
      os.push_back (o);
    }

    // --schema-format
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--schema-format", a, false, dv);
      os.push_back (o);
    }

    // --schema-name
    //
    {
      ::cli::option_names a;
      std::string dv ("");
      ::cli::option o ("--schema-name", a, false, dv);
      os.push_back (o);
    }

    // --default-pointer
    //
    {
      ::cli::option_names a;
      std::string dv ("*");
      ::cli::option o ("--default-pointer", a, false, dv);
      os.push_back (o);
    }

    // --profile
    //
    {
      ::cli::option_names a;
      a.push_back ("-p");
      std::string dv;
      ::cli::option o ("--profile", a, false, dv);
      os.push_back (o);
    }

    // --schema
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--schema", a, false, dv);
      os.push_back (o);
    }

    // --table-prefix
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--table-prefix", a, false, dv);
      os.push_back (o);
    }

    // --output-dir
    //
    {
      ::cli::option_names a;
      a.push_back ("-o");
      std::string dv;
      ::cli::option o ("--output-dir", a, false, dv);
      os.push_back (o);
    }

    // --odb-file-suffix
    //
    {
      ::cli::option_names a;
      std::string dv ("-odb");
      ::cli::option o ("--odb-file-suffix", a, false, dv);
      os.push_back (o);
    }

    // --hxx-suffix
    //
    {
      ::cli::option_names a;
      std::string dv (".hxx");
      ::cli::option o ("--hxx-suffix", a, false, dv);
      os.push_back (o);
    }

    // --ixx-suffix
    //
    {
      ::cli::option_names a;
      std::string dv (".ixx");
      ::cli::option o ("--ixx-suffix", a, false, dv);
      os.push_back (o);
    }

    // --cxx-suffix
    //
    {
      ::cli::option_names a;
      std::string dv (".cxx");
      ::cli::option o ("--cxx-suffix", a, false, dv);
      os.push_back (o);
    }

    // --sql-suffix
    //
    {
      ::cli::option_names a;
      std::string dv (".sql");
      ::cli::option o ("--sql-suffix", a, false, dv);
      os.push_back (o);
    }

    // --hxx-prologue
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--hxx-prologue", a, false, dv);
      os.push_back (o);
    }

    // --ixx-prologue
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--ixx-prologue", a, false, dv);
      os.push_back (o);
    }

    // --cxx-prologue
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--cxx-prologue", a, false, dv);
      os.push_back (o);
    }

    // --sql-prologue
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--sql-prologue", a, false, dv);
      os.push_back (o);
    }

    // --hxx-epilogue
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--hxx-epilogue", a, false, dv);
      os.push_back (o);
    }

    // --ixx-epilogue
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--ixx-epilogue", a, false, dv);
      os.push_back (o);
    }

    // --cxx-epilogue
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--cxx-epilogue", a, false, dv);
      os.push_back (o);
    }

    // --sql-epilogue
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--sql-epilogue", a, false, dv);
      os.push_back (o);
    }

    // --hxx-prologue-file
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--hxx-prologue-file", a, false, dv);
      os.push_back (o);
    }

    // --ixx-prologue-file
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--ixx-prologue-file", a, false, dv);
      os.push_back (o);
    }

    // --cxx-prologue-file
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--cxx-prologue-file", a, false, dv);
      os.push_back (o);
    }

    // --sql-prologue-file
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--sql-prologue-file", a, false, dv);
      os.push_back (o);
    }

    // --hxx-epilogue-file
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--hxx-epilogue-file", a, false, dv);
      os.push_back (o);
    }

    // --ixx-epilogue-file
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--ixx-epilogue-file", a, false, dv);
      os.push_back (o);
    }

    // --cxx-epilogue-file
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--cxx-epilogue-file", a, false, dv);
      os.push_back (o);
    }

    // --sql-epilogue-file
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--sql-epilogue-file", a, false, dv);
      os.push_back (o);
    }

    // --odb-prologue
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--odb-prologue", a, false, dv);
      os.push_back (o);
    }

    // --odb-prologue-file
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--odb-prologue-file", a, false, dv);
      os.push_back (o);
    }

    // --odb-epilogue
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--odb-epilogue", a, false, dv);
      os.push_back (o);
    }

    // --odb-epilogue-file
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--odb-epilogue-file", a, false, dv);
      os.push_back (o);
    }

    // --include-with-brackets
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--include-with-brackets", a, true, dv);
      os.push_back (o);
    }

    // --include-prefix
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--include-prefix", a, false, dv);
      os.push_back (o);
    }

    // --include-regex
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--include-regex", a, false, dv);
      os.push_back (o);
    }

    // --include-regex-trace
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--include-regex-trace", a, true, dv);
      os.push_back (o);
    }

    // --guard-prefix
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--guard-prefix", a, false, dv);
      os.push_back (o);
    }

    // --options-file
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--options-file", a, false, dv);
      os.push_back (o);
    }

    // -x
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("-x", a, false, dv);
      os.push_back (o);
    }

    // -v
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("-v", a, true, dv);
      os.push_back (o);
    }

    // --trace
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--trace", a, true, dv);
      os.push_back (o);
    }

    // --mssql-server-version
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--mssql-server-version", a, false, dv);
      os.push_back (o);
    }

    // --mssql-short-limit
    //
    {
      ::cli::option_names a;
      std::string dv ("1024");
      ::cli::option o ("--mssql-short-limit", a, false, dv);
      os.push_back (o);
    }

    // --mysql-engine
    //
    {
      ::cli::option_names a;
      std::string dv ("InnoDB");
      ::cli::option o ("--mysql-engine", a, false, dv);
      os.push_back (o);
    }

    // --oracle-client-version
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--oracle-client-version", a, false, dv);
      os.push_back (o);
    }

    // --sqlite-lax-auto-id
    //
    {
      ::cli::option_names a;
      std::string dv;
      ::cli::option o ("--sqlite-lax-auto-id", a, true, dv);
      os.push_back (o);
    }
  }
};

static _cli_options_desc_init _cli_options_desc_init_ (_cli_options_desc_);

const ::cli::options& options::
description ()
{
  return _cli_options_desc_;
};

typedef
std::map<std::string, void (*) (options&, ::cli::scanner&)>
_cli_options_map;

static _cli_options_map _cli_options_map_;

struct _cli_options_map_init
{
  _cli_options_map_init ()
  {
    _cli_options_map_["--help"] = 
    &::cli::thunk< options, bool, &options::help_ >;
    _cli_options_map_["--version"] = 
    &::cli::thunk< options, bool, &options::version_ >;
    _cli_options_map_["-I"] = 
    &::cli::thunk< options, std::vector<std::string>, &options::I_,
      &options::I_specified_ >;
    _cli_options_map_["-D"] = 
    &::cli::thunk< options, std::vector<std::string>, &options::D_,
      &options::D_specified_ >;
    _cli_options_map_["-U"] = 
    &::cli::thunk< options, std::vector<std::string>, &options::U_,
      &options::U_specified_ >;
    _cli_options_map_["--database"] = 
    &::cli::thunk< options, ::database, &options::database_,
      &options::database_specified_ >;
    _cli_options_map_["-d"] = 
    &::cli::thunk< options, ::database, &options::database_,
      &options::database_specified_ >;
    _cli_options_map_["--generate-query"] = 
    &::cli::thunk< options, bool, &options::generate_query_ >;
    _cli_options_map_["-q"] = 
    &::cli::thunk< options, bool, &options::generate_query_ >;
    _cli_options_map_["--generate-schema"] = 
    &::cli::thunk< options, bool, &options::generate_schema_ >;
    _cli_options_map_["-s"] = 
    &::cli::thunk< options, bool, &options::generate_schema_ >;
    _cli_options_map_["--schema-format"] = 
    &::cli::thunk< options, std::set< ::schema_format>, &options::schema_format_,
      &options::schema_format_specified_ >;
    _cli_options_map_["--schema-name"] = 
    &::cli::thunk< options, std::string, &options::schema_name_,
      &options::schema_name_specified_ >;
    _cli_options_map_["--default-pointer"] = 
    &::cli::thunk< options, std::string, &options::default_pointer_,
      &options::default_pointer_specified_ >;
    _cli_options_map_["--profile"] = 
    &::cli::thunk< options, std::string, &options::profile_,
      &options::profile_specified_ >;
    _cli_options_map_["-p"] = 
    &::cli::thunk< options, std::string, &options::profile_,
      &options::profile_specified_ >;
    _cli_options_map_["--schema"] = 
    &::cli::thunk< options, qname, &options::schema_,
      &options::schema_specified_ >;
    _cli_options_map_["--table-prefix"] = 
    &::cli::thunk< options, std::string, &options::table_prefix_,
      &options::table_prefix_specified_ >;
    _cli_options_map_["--output-dir"] = 
    &::cli::thunk< options, std::string, &options::output_dir_,
      &options::output_dir_specified_ >;
    _cli_options_map_["-o"] = 
    &::cli::thunk< options, std::string, &options::output_dir_,
      &options::output_dir_specified_ >;
    _cli_options_map_["--odb-file-suffix"] = 
    &::cli::thunk< options, std::string, &options::odb_file_suffix_,
      &options::odb_file_suffix_specified_ >;
    _cli_options_map_["--hxx-suffix"] = 
    &::cli::thunk< options, std::string, &options::hxx_suffix_,
      &options::hxx_suffix_specified_ >;
    _cli_options_map_["--ixx-suffix"] = 
    &::cli::thunk< options, std::string, &options::ixx_suffix_,
      &options::ixx_suffix_specified_ >;
    _cli_options_map_["--cxx-suffix"] = 
    &::cli::thunk< options, std::string, &options::cxx_suffix_,
      &options::cxx_suffix_specified_ >;
    _cli_options_map_["--sql-suffix"] = 
    &::cli::thunk< options, std::string, &options::sql_suffix_,
      &options::sql_suffix_specified_ >;
    _cli_options_map_["--hxx-prologue"] = 
    &::cli::thunk< options, std::vector<std::string>, &options::hxx_prologue_,
      &options::hxx_prologue_specified_ >;
    _cli_options_map_["--ixx-prologue"] = 
    &::cli::thunk< options, std::vector<std::string>, &options::ixx_prologue_,
      &options::ixx_prologue_specified_ >;
    _cli_options_map_["--cxx-prologue"] = 
    &::cli::thunk< options, std::vector<std::string>, &options::cxx_prologue_,
      &options::cxx_prologue_specified_ >;
    _cli_options_map_["--sql-prologue"] = 
    &::cli::thunk< options, std::vector<std::string>, &options::sql_prologue_,
      &options::sql_prologue_specified_ >;
    _cli_options_map_["--hxx-epilogue"] = 
    &::cli::thunk< options, std::vector<std::string>, &options::hxx_epilogue_,
      &options::hxx_epilogue_specified_ >;
    _cli_options_map_["--ixx-epilogue"] = 
    &::cli::thunk< options, std::vector<std::string>, &options::ixx_epilogue_,
      &options::ixx_epilogue_specified_ >;
    _cli_options_map_["--cxx-epilogue"] = 
    &::cli::thunk< options, std::vector<std::string>, &options::cxx_epilogue_,
      &options::cxx_epilogue_specified_ >;
    _cli_options_map_["--sql-epilogue"] = 
    &::cli::thunk< options, std::vector<std::string>, &options::sql_epilogue_,
      &options::sql_epilogue_specified_ >;
    _cli_options_map_["--hxx-prologue-file"] = 
    &::cli::thunk< options, std::string, &options::hxx_prologue_file_,
      &options::hxx_prologue_file_specified_ >;
    _cli_options_map_["--ixx-prologue-file"] = 
    &::cli::thunk< options, std::string, &options::ixx_prologue_file_,
      &options::ixx_prologue_file_specified_ >;
    _cli_options_map_["--cxx-prologue-file"] = 
    &::cli::thunk< options, std::string, &options::cxx_prologue_file_,
      &options::cxx_prologue_file_specified_ >;
    _cli_options_map_["--sql-prologue-file"] = 
    &::cli::thunk< options, std::string, &options::sql_prologue_file_,
      &options::sql_prologue_file_specified_ >;
    _cli_options_map_["--hxx-epilogue-file"] = 
    &::cli::thunk< options, std::string, &options::hxx_epilogue_file_,
      &options::hxx_epilogue_file_specified_ >;
    _cli_options_map_["--ixx-epilogue-file"] = 
    &::cli::thunk< options, std::string, &options::ixx_epilogue_file_,
      &options::ixx_epilogue_file_specified_ >;
    _cli_options_map_["--cxx-epilogue-file"] = 
    &::cli::thunk< options, std::string, &options::cxx_epilogue_file_,
      &options::cxx_epilogue_file_specified_ >;
    _cli_options_map_["--sql-epilogue-file"] = 
    &::cli::thunk< options, std::string, &options::sql_epilogue_file_,
      &options::sql_epilogue_file_specified_ >;
    _cli_options_map_["--odb-prologue"] = 
    &::cli::thunk< options, std::vector<std::string>, &options::odb_prologue_,
      &options::odb_prologue_specified_ >;
    _cli_options_map_["--odb-prologue-file"] = 
    &::cli::thunk< options, std::vector<std::string>, &options::odb_prologue_file_,
      &options::odb_prologue_file_specified_ >;
    _cli_options_map_["--odb-epilogue"] = 
    &::cli::thunk< options, std::vector<std::string>, &options::odb_epilogue_,
      &options::odb_epilogue_specified_ >;
    _cli_options_map_["--odb-epilogue-file"] = 
    &::cli::thunk< options, std::vector<std::string>, &options::odb_epilogue_file_,
      &options::odb_epilogue_file_specified_ >;
    _cli_options_map_["--include-with-brackets"] = 
    &::cli::thunk< options, bool, &options::include_with_brackets_ >;
    _cli_options_map_["--include-prefix"] = 
    &::cli::thunk< options, std::string, &options::include_prefix_,
      &options::include_prefix_specified_ >;
    _cli_options_map_["--include-regex"] = 
    &::cli::thunk< options, std::vector<std::string>, &options::include_regex_,
      &options::include_regex_specified_ >;
    _cli_options_map_["--include-regex-trace"] = 
    &::cli::thunk< options, bool, &options::include_regex_trace_ >;
    _cli_options_map_["--guard-prefix"] = 
    &::cli::thunk< options, std::string, &options::guard_prefix_,
      &options::guard_prefix_specified_ >;
    _cli_options_map_["--options-file"] = 
    &::cli::thunk< options, std::string, &options::options_file_,
      &options::options_file_specified_ >;
    _cli_options_map_["-x"] = 
    &::cli::thunk< options, std::vector<std::string>, &options::x_,
      &options::x_specified_ >;
    _cli_options_map_["-v"] = 
    &::cli::thunk< options, bool, &options::v_ >;
    _cli_options_map_["--trace"] = 
    &::cli::thunk< options, bool, &options::trace_ >;
    _cli_options_map_["--mssql-server-version"] = 
    &::cli::thunk< options, ::mssql_version, &options::mssql_server_version_,
      &options::mssql_server_version_specified_ >;
    _cli_options_map_["--mssql-short-limit"] = 
    &::cli::thunk< options, unsigned int, &options::mssql_short_limit_,
      &options::mssql_short_limit_specified_ >;
    _cli_options_map_["--mysql-engine"] = 
    &::cli::thunk< options, std::string, &options::mysql_engine_,
      &options::mysql_engine_specified_ >;
    _cli_options_map_["--oracle-client-version"] = 
    &::cli::thunk< options, ::oracle_version, &options::oracle_client_version_,
      &options::oracle_client_version_specified_ >;
    _cli_options_map_["--sqlite-lax-auto-id"] = 
    &::cli::thunk< options, bool, &options::sqlite_lax_auto_id_ >;
  }
};

static _cli_options_map_init _cli_options_map_init_;

void options::
_parse (::cli::scanner& s,
        ::cli::unknown_mode opt_mode,
        ::cli::unknown_mode arg_mode)
{
  bool opt = true;

  while (s.more ())
  {
    const char* o = s.peek ();

    if (std::strcmp (o, "--") == 0)
    {
      s.skip ();
      opt = false;
      continue;
    }

    _cli_options_map::const_iterator i (
      opt ? _cli_options_map_.find (o) : _cli_options_map_.end ());

    if (i != _cli_options_map_.end ())
    {
      (*(i->second)) (*this, s);
    }
    else if (opt && std::strncmp (o, "-", 1) == 0 && o[1] != '\0')
    {
      switch (opt_mode)
      {
        case ::cli::unknown_mode::skip:
        {
          s.skip ();
          continue;
        }
        case ::cli::unknown_mode::stop:
        {
          break;
        }
        case ::cli::unknown_mode::fail:
        {
          throw ::cli::unknown_option (o);
        }
      }

      break;
    }
    else
    {
      switch (arg_mode)
      {
        case ::cli::unknown_mode::skip:
        {
          s.skip ();
          continue;
        }
        case ::cli::unknown_mode::stop:
        {
          break;
        }
        case ::cli::unknown_mode::fail:
        {
          throw ::cli::unknown_argument (o);
        }
      }

      break;
    }
  }
}

