~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/module/loader.cc

  • Committer: Monty Taylor
  • Date: 2010-06-18 19:20:32 UTC
  • mto: (1627.2.5 build)
  • mto: This revision was merged to the branch mainline in revision 1628.
  • Revision ID: mordred@inaugust.com-20100618192032-xw9xph0ayhvohqlu
Added support for program_options based commandline argument passing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#include <vector>
23
23
#include <map>
24
24
#include <algorithm>
 
25
#include <iostream>
25
26
 
26
27
#include <boost/program_options.hpp>
27
28
 
1672
1673
 
1673
1674
  if (test_module->getManifest().init_options != NULL)
1674
1675
  {
 
1676
    cout << "Calling init_options: " << test_module->getName() << endl;
1675
1677
    po::options_description module_options("Options used by plugins");
1676
1678
    module::option_context opt_ctx(test_module->getName(),
1677
1679
                                   module_options.add_options());
1678
1680
    test_module->getManifest().init_options(opt_ctx);
 
1681
 
 
1682
    po::variables_map vm;
 
1683
 
 
1684
    po::parsed_options parsed= po::command_line_parser(*argc, argv).
 
1685
      options(module_options).allow_unregistered().run();
 
1686
 
 
1687
    po::store(parsed, vm);
 
1688
 
 
1689
    vector<string> to_pass_further= po::collect_unrecognized(parsed.options,
 
1690
                                                             po::include_positional);
 
1691
 
 
1692
 
 
1693
    /* Copy the left over options back into argv for further processing.
 
1694
       Once the core is using program options, this whole thing will be done
 
1695
       differently.
 
1696
     */
 
1697
    for (vector<string>::iterator iter= to_pass_further.begin();
 
1698
         iter != to_pass_further.end();
 
1699
         ++iter)
 
1700
    {
 
1701
      size_t pos= iter-to_pass_further.begin()+1;
 
1702
      memcpy(argv[pos], (*iter).c_str(), (*iter).size()+1);
 
1703
      cout << "arg: *" << argv[pos] << "*" << endl;
 
1704
    }
 
1705
    *argc= to_pass_further.size() + 1;
 
1706
 
 
1707
    po::notify(vm);
1679
1708
  }
 
1709
  else
 
1710
  {
1680
1711
 
1681
1712
  for (opt= test_module->getManifest().system_vars; opt && *opt; opt++)
1682
1713
  {
1713
1744
      goto err;
1714
1745
    }
1715
1746
  }
 
1747
  }
1716
1748
 
1717
1749
  error= 1;
1718
1750