1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
/**
* @file BaseCmd.h
*
* Base structure for commandline parser class definition
* Copyright (C) 2005. Licensed under the terms of the
* GNU GPL, v2 or later.
*/
#ifndef BASECMD_H
#define BASECMD_H
#ifdef __APPLE__
#pragma GCC visibility push(default)
#endif
#include <vector>
#include <string>
#include <boost/program_options.hpp>
/**
* @brief Commandline parser
*/
class BaseCmd
{
public:
BaseCmd(int argc, char* argv[]);
~BaseCmd();
/// Get the script, or demofile given on cmdline
std::string GetInputFile();
/**
* @brief usage
* @param program name of the program
* @param version version of this program
*/
void PrintUsage(std::string program, std::string version);
/**
* @brief add options
* @param shortopt the short (single character) to use (0 for none)
* @param longopt the long (full string) to use (required)
* @param desc a short, human-readable description of this parameter
*/
void AddSwitch(const char shortopt, std::string longopt, std::string desc);
void AddString(const char shortopt, std::string longopt, std::string desc);
void AddInt(const char shortopt, std::string longopt, std::string desc);
/**
* @brief parse
*
* This will read the parameters and search for recognized strings.
*/
void Parse();
/**
* @brief check if commandline flag was set
* @param var the longopt-name of the config flag
*/
bool IsSet(const std::string& var) const;
/**
* @brief Commandline argument as string
* @param var the longopt-name of the config flag
*/
std::string GetString(const std::string& var) const;
/**
* @brief Commandline argument as int
* @param var the longopt-name of the config flag
*/
int GetInt(const std::string& var) const;
protected:
/**
* @brief argument count
*
* Stores the argument count specified at initialization
*/
int argc;
/**
* @brief arguments
*
* Stores the C string array given at initialization
*/
char **argv;
boost::program_options::variables_map vm;
boost::program_options::options_description desc;
boost::program_options::options_description all;
};
#endif
#ifdef __APPLE__
#pragma GCC visibility pop
#endif
|