本文整理汇总了C++中ProgramOptions::has方法的典型用法代码示例。如果您正苦于以下问题:C++ ProgramOptions::has方法的具体用法?C++ ProgramOptions::has怎么用?C++ ProgramOptions::has使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProgramOptions
的用法示例。
在下文中一共展示了ProgramOptions::has方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addPort
bool ApplicationHttpServer::parsePhase2 (ProgramOptions& options) {
if (options.has("server.require-keep-alive")) {
_requireKeepAlive= true;
}
for (vector<string>::const_iterator i = _httpPorts.begin(); i != _httpPorts.end(); ++i) {
addPort(*i);
}
return true;
}
示例2: addPort
bool ApplicationHttpsServer::parsePhase2 (ProgramOptions& options) {
// check keep alive
if (options.has("server.secure-require-keep-alive")) {
_requireKeepAlive= true;
}
// add ports
for (vector<string>::const_iterator i = _httpsPorts.begin(); i != _httpsPorts.end(); ++i) {
addPort(*i);
}
// create the ssl context (if possible)
bool ok = createSslContext();
if (! ok) {
return false;
}
// and return
return true;
}
示例3: parse
void ArangoClient::parse (ProgramOptions& options,
ProgramOptionsDescription& description,
string const& example,
int argc,
char* argv[],
string const& initFilename) {
// if options are invalid, exit directly
if (! options.parse(description, argc, argv)) {
LOG_FATAL_AND_EXIT("%s", options.lastError().c_str());
}
// setup the logging
TRI_SetLogLevelLogging(_logLevel.c_str());
TRI_CreateLogAppenderFile("-", 0, TRI_LOG_SEVERITY_UNKNOWN, false);
TRI_SetLineNumberLogging(false);
TRI_SetThreadIdentifierLogging(false);
// parse config file
string configFile = "";
bool allowLocal = false;
if (! _configFile.empty()) {
if (StringUtils::tolower(_configFile) == string("none")) {
LOG_DEBUG("using no init file at all");
}
else {
configFile = _configFile;
}
}
else {
char* d = TRI_LocateConfigDirectory();
if (d != 0) {
string sysDir = string(d) + initFilename;
TRI_FreeString(TRI_CORE_MEM_ZONE, d);
if (FileUtils::exists(sysDir)) {
configFile = sysDir;
allowLocal = true;
}
else {
LOG_DEBUG("no system init file '%s'", sysDir.c_str());
}
}
}
if (! configFile.empty()) {
if (allowLocal) {
string localConfigFile = configFile + ".local";
if (FileUtils::exists(localConfigFile)) {
LOG_DEBUG("using init override file '%s'", localConfigFile.c_str());
if (! options.parse(description, localConfigFile)) {
LOG_FATAL_AND_EXIT("cannot parse config file '%s': %s", localConfigFile.c_str(), options.lastError().c_str());
}
}
}
LOG_DEBUG("using init file '%s'", configFile.c_str());
if (! options.parse(description, configFile)) {
LOG_FATAL_AND_EXIT("cannot parse config file '%s': %s", configFile.c_str(), options.lastError().c_str());
}
}
// configuration is parsed and valid if we got to this point
// check for --help
set<string> help = options.needHelp("help");
if (! help.empty()) {
if (! example.empty()) {
cout << "USAGE: " << argv[0] << " " << example << endl << endl;
}
cout << description.usage(help) << endl;
// --help always returns success
TRI_EXIT_FUNCTION(EXIT_SUCCESS, NULL);
}
// set temp path
if (options.has("temp-path")) {
TRI_SetUserTempPath((char*) _tempPath.c_str());
}
if (options.has("server.username")) {
// if a username is specified explicitly, assume authentication is desired
_disableAuthentication = false;
}
// check if have a password
_hasPassword = options.has("server.password")
|| _disableAuthentication
|| options.has("jslint")
|| options.has("javascript.unit-tests");
// set colors
//.........这里部分代码省略.........
示例4: parse
void ArangoClient::parse (ProgramOptions& options,
ProgramOptionsDescription& description,
int argc,
char* argv[],
string const& initFilename) {
if (! options.parse(description, argc, argv)) {
cerr << options.lastError() << "\n";
exit(EXIT_FAILURE);
}
// check for help
set<string> help = options.needHelp("help");
if (! help.empty()) {
cout << description.usage(help) << endl;
exit(EXIT_SUCCESS);
}
// setup the logging
TRI_SetLogLevelLogging(_logLevel.c_str());
TRI_CreateLogAppenderFile("-");
TRI_SetLineNumberLogging(false);
TRI_SetThreadIdentifierLogging(false);
// parse config file
string configFile = "";
if (! _configFile.empty()) {
if (StringUtils::tolower(_configFile) == string("none")) {
LOGGER_INFO << "using no init file at all";
}
else {
configFile = _configFile;
}
}
#ifdef _SYSCONFDIR_
else {
string sysDir = string(_SYSCONFDIR_);
string systemConfigFile = initFilename;
if (! sysDir.empty()) {
if (sysDir[sysDir.size() - 1] != '/') {
sysDir += "/" + systemConfigFile;
}
else {
sysDir += systemConfigFile;
}
if (FileUtils::exists(sysDir)) {
configFile = sysDir;
}
else {
LOGGER_DEBUG << "no system init file '" << sysDir << "'";
}
}
}
#endif
if (! configFile.empty()) {
LOGGER_DEBUG << "using init file '" << configFile << "'";
if (! options.parse(description, configFile)) {
cout << "cannot parse config file '" << configFile << "': " << options.lastError() << endl;
exit(EXIT_FAILURE);
}
}
// check if have a password
_hasPassword = options.has("server.password") || options.has("server.disable-authentication");
// set colors
if (options.has("colors")) {
_noColors = false;
}
if (options.has("no-colors")) {
_noColors = true;
}
// set auto-completion
if (options.has("auto-complete")) {
_noAutoComplete = false;
}
if (options.has("no-auto-complete")) {
_noAutoComplete = true;
}
// set pretty print
if (options.has("pretty-print")) {
_prettyPrint = true;
}
if (options.has("no-pretty-print")) {
_prettyPrint = false;
}
//.........这里部分代码省略.........