Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Public Attributes
Arc::ServerOptions Class Reference

#include <options.h>

Inheritance diagram for Arc::ServerOptions:
Inheritance graph
[legend]
Collaboration diagram for Arc::ServerOptions:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ServerOptions ()
void AddOption (const char shortOpt, const std::string &longOpt, const std::string &optDesc, bool &val)
void AddOption (const char shortOpt, const std::string &longOpt, const std::string &optDesc, const std::string &argDesc, int &val)
void AddOption (const char shortOpt, const std::string &longOpt, const std::string &optDesc, const std::string &argDesc, std::string &val)
void AddOption (const char shortOpt, const std::string &longOpt, const std::string &optDesc, const std::string &argDesc, std::list< std::string > &val)
std::list< std::string > Parse (int argc, char **argv)

Public Attributes

bool foreground
bool version
std::string xml_config_file
std::string ini_config_file
std::string pid_file
std::string user
std::string group
bool config_dump
std::string schema_file

Detailed Description

Definition at line 8 of file options.h.


Constructor & Destructor Documentation

Definition at line 9 of file options.cpp.

    : OptionParser() {

    foreground = false;
    AddOption('f', "foreground", "run daemon in foreground", foreground);
    AddOption('c', "xml-config", "full path of XML config file", "path", xml_config_file);
    AddOption('i', "ini-config", "full path of InI config file", "path", ini_config_file);
    config_dump = false;
    AddOption('d', "config-dump", "dump generated XML config", config_dump);
    AddOption('p', "pid-file", "full path of pid file", "path", pid_file);
    AddOption('u', "user", "user name", "user", user);
    AddOption('g', "group", "group name", "group", group);
    AddOption('s', "schema", "full path of XML schema file", "path", schema_file);
    version = false;
    AddOption('v', "version", "print version information", version);
#ifdef WIN32
    install = false;
    AddOption('a', "install", "install windows service", install);
    uninstall = false;
    AddOption('r', "uninstall", "uninstall windows service", uninstall);
#endif
  }

Here is the call graph for this function:


Member Function Documentation

void Arc::OptionParser::AddOption ( const char  shortOpt,
const std::string &  longOpt,
const std::string &  optDesc,
bool &  val 
) [inherited]

Definition at line 188 of file OptionParser.cpp.

                                            {
    options.push_back(new BoolOption(shortOpt, longOpt,
                                     optDesc, "", value));
  }

Here is the caller graph for this function:

void Arc::OptionParser::AddOption ( const char  shortOpt,
const std::string &  longOpt,
const std::string &  optDesc,
const std::string &  argDesc,
int &  val 
) [inherited]

Definition at line 196 of file OptionParser.cpp.

                                           {
    options.push_back(new IntOption(shortOpt, longOpt,
                                    optDesc, argDesc, value));
  }
void Arc::OptionParser::AddOption ( const char  shortOpt,
const std::string &  longOpt,
const std::string &  optDesc,
const std::string &  argDesc,
std::string &  val 
) [inherited]

Definition at line 205 of file OptionParser.cpp.

                                                 {
    options.push_back(new StringOption(shortOpt, longOpt,
                                       optDesc, argDesc, value));
  }
void Arc::OptionParser::AddOption ( const char  shortOpt,
const std::string &  longOpt,
const std::string &  optDesc,
const std::string &  argDesc,
std::list< std::string > &  val 
) [inherited]

Definition at line 214 of file OptionParser.cpp.

                                                          {
    options.push_back(new StringListOption(shortOpt, longOpt,
                                           optDesc, argDesc, value));
  }
std::list< std::string > Arc::OptionParser::Parse ( int  argc,
char **  argv 
) [inherited]

Definition at line 281 of file OptionParser.cpp.

                                                              {

    struct option *longoptions = new struct option[options.size() + 3];
    int i = 0;
    std::string optstring;
    for (std::list<OptionBase*>::iterator it = options.begin();
         it != options.end(); it++) {
      setopt(longoptions[i++], (*it)->longOpt.c_str(),
             (*it)->argDesc.empty() ? no_argument : required_argument,
             NULL, (*it)->shortOpt);
      optstring += (*it)->shortOpt;
      if (!(*it)->argDesc.empty())
        optstring += ':';
    }
    setopt(longoptions[i++], "help", no_argument, NULL, 'h');
    optstring += 'h';
    setopt(longoptions[i++], "help", no_argument, NULL, '?');
    optstring += '?';
    setopt(longoptions[i++], NULL, no_argument, NULL, '\0');

    char *argv0save = argv[0];
    argv[0] = strrchr(argv[0], '/');
    if (argv[0])
      argv[0]++;
    else
      argv[0] = argv0save;

    int opt = 0;
    while (opt != -1) {
#ifdef HAVE_GETOPT_LONG_ONLY
      opt = getopt_long_only(argc, argv, optstring.c_str(), longoptions, NULL);
#else
      opt = getopt_long(argc, argv, optstring.c_str(), longoptions, NULL);
#endif

      if (opt == -1)
        continue;
      if ((opt == '?') || (opt == ':') || (opt == 'h')) {
        if (optopt) {
          delete longoptions;
          exit(1);
        }
        std::cout << IString("Usage:") << std::endl;
        std::cout << "  " << argv[0];
        if (!options.empty())
          std::cout << " [" << IString("OPTION...") << "]";
        if (!arguments.empty())
          std::cout << " " << IString(arguments);
        std::cout << std::endl << std::endl;
        if (!summary.empty())
          std::cout << IString(summary) << std::endl << std::endl;
        std::cout << IString("Help Options:") << std::endl;
        std::cout << "  -h, -?, --help    " << IString("Show help options")
                  << std::endl << std::endl;
        std::cout << IString("Application Options:") << std::endl;
        for (std::list<OptionBase*>::iterator it = options.begin();
             it != options.end(); it++) {
          std::cout << "  -" << (*it)->shortOpt << ", --" << (*it)->longOpt;
          if (!(*it)->argDesc.empty())
            std::cout << "=" << IString((*it)->argDesc);
          std::cout << "    " << IString((*it)->optDesc) << std::endl;
        }
        std::cout << std::endl;
        if (!description.empty())
          std::cout << IString(description) << std::endl;
        delete longoptions;
        exit(0);
      }
      for (std::list<OptionBase*>::iterator it = options.begin();
           it != options.end(); it++)
        if (opt == (*it)->shortOpt) {
          if (!(*it)->Set(optarg ? optarg : "")) {
            delete longoptions;
            exit(1);
          }
          break;
        }
    }

    delete[] longoptions;
    argv[0] = argv0save;

    std::list<std::string> params;
    while (argc > optind)
      params.push_back(argv[optind++]);
    return params;
  }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 20 of file options.h.

Definition at line 13 of file options.h.

Definition at line 19 of file options.h.

Definition at line 16 of file options.h.

Definition at line 17 of file options.h.

Definition at line 21 of file options.h.

Definition at line 18 of file options.h.

Definition at line 14 of file options.h.

Definition at line 15 of file options.h.


The documentation for this class was generated from the following files: