The Mace parameter class is an alternative (though may be used in addition to getopt. I personally do not like the getopt style option parsing, because all option handling must be done in main. Instead, the params::Params class loads parameters in what amounts to a map, then allows code anywhere in Mace to query the parameter values.
This file contains the params::Params class (which should not directly be used), a singleton which implements the parameters, several constants which define standard Mace parameters that various libraries and services use, and the params:: interface.
Definition in file params.h.
#include <string>
#include <iostream>
#include <boost/lexical_cast.hpp>
#include "massert.h"
#include "mdeque.h"
#include "m_map.h"
#include "mset.h"
#include "MaceTypes.h"
Go to the source code of this file.
Namespaces | |
namespace | params |
Classes | |
class | params::Params |
Do not use directly. Use params: : methods instead. More... | |
Functions | |
int | params::loadparams (int &argc, char **&argv, bool requireFile=false) |
Loads the parameters as though from the command line. | |
int | params::loadfile (const char *filename, bool allRequired=false) |
void | params::addRequired (const std::string &name, const std::string &desc="") |
Adds a required parameter of name name and description desc . | |
int | params::print (FILE *ostream) |
Prints all the parameters to a FILE* such as stdout . | |
int | params::print (std::ostream &os) |
Prints all the parameters to a ostream such as cout . | |
void | params::getBootstrapPeers (const mace::MaceKey &laddr, NodeSet &peers, bool &autoBootstrap) |
Returns either MACE_AUTO_BOOTSTRAP_PEERS or MACE_BOOTSTRAP_PEERS, parsed as a set of IPV4 nodes. | |
Variables | |
static const std::string | params::MACE_LOCAL_ADDRESS = "MACE_LOCAL_ADDRESS" |
Allows to override the detected local address. | |
static const std::string | params::MACE_PORT = "MACE_PORT" |
Sets the default port for addresses. | |
static const std::string | params::MACE_BIND_LOCAL_ADDRESS = "MACE_BIND_LOCAL_ADDRESS" |
1 or 0, sets whether to additionally bind to the local address rather than inaddr any. | |
static const std::string | params::MACE_TRANSPORT_DISABLE_TRANSLATION = "MACE_TRANSPORT_DISABLE_TRANSLATION" |
1 or 0, sets whether to have the transport re-write source addresses for hosts using the auto-forwarding transport features. | |
static const std::string | params::MACE_ALL_HOSTS_REACHABLE = "MACE_ALL_HOSTS_REACHABLE" |
When set allows the transport to skip overhead when not doing NAT. | |
static const std::string | params::MACE_CERT_FILE = "MACE_CERT_FILE" |
Tell the transport where the certificate file is. | |
static const std::string | params::MACE_PRIVATE_KEY_FILE = "MACE_PRIVATE_KEY_FILE" |
Tell the transport where the private key is. | |
static const std::string | params::MACE_CA_FILE = "MACE_CA_FILE" |
Tell the transport where the CA certificate to trust is. | |
static const std::string | params::MACE_NO_VERIFY_HOSTNAMES = "MACE_NO_VERIFY_HOSTNAMES" |
Tell the transport to ignore hostnames in certificates. | |
static const std::string | params::MACE_PRINT_HOSTNAME_ONLY = "MACE_PRINT_HOSTNAME_ONLY" |
In outputting logs, don't print prefix or IP, just hostname. | |
static const std::string | params::MACE_LOG_AUTO_SELECTORS = "MACE_LOG_AUTO_SELECTORS" |
These will be passed to Log::autoAdd. | |
static const std::string | params::MACE_LOG_TIMESTAMP_HUMAN = "MACE_LOG_TIMESTAMP_HUMAN" |
If true, configured logging will use human timestamps. | |
static const std::string | params::MACE_LOG_LEVEL = "MACE_LOG_LEVEL" |
Calls Log::setLevel. | |
static const std::string | params::MACE_LOG_AUTO_ALL = "MACE_LOG_AUTO_ALL" |
Enables all logging via Log::autoAddAll. | |
static const std::string | params::MACE_LOG_FILE = "MACE_LOG_FILE" |
Default file to write configured logs to. | |
static const std::string | params::MACE_LOG_PATH = "MACE_LOG_PATH" |
Default path for log files. | |
static const std::string | params::MACE_LOG_PREFIX = "MACE_LOG_PREFIX" |
Prefix for log files. | |
static const std::string | params::MACE_LOG_APPEND = "MACE_LOG_APPEND" |
Don't truncate MACE_LOG_FILE. | |
static const std::string | params::MACE_LOG_DISABLE_WARNING = "MACE_LOG_DISABLE_WARNING" |
During configuration, disable default warning logs. | |
static const std::string | params::MACE_LOG_AUTO_BINARY = "MACE_LOG_AUTO_BINARY" |
Like MACE_LOG_AUTO_SELECTORS, but adds as binary logs. | |
static const std::string | params::MACE_BIN_LOG_FILE = "MACE_BIN_LOG_FILE" |
File for writing the binary logs. | |
static const std::string | params::MACE_BOOTSTRAP_PEERS = "MACE_BOOTSTRAP_PEERS" |
sets autoBootstrap to false, but will return from params::getBootstrapPeers | |
static const std::string | params::MACE_AUTO_BOOTSTRAP_PEERS = "MACE_AUTO_BOOTSTRAP_PEERS" |
Will return for getBootstrapPeers, and set autoBootstrap to true. | |
static const std::string | params::MACE_ADDRESS_ALLOW_LOOPBACK = "MACE_ADDRESS_ALLOW_LOOPBACK" |
Enable the transport to use the loopback as a local address. Disabled by default to prevent bad address detection. |