Class for reading configuration from command line and/or file(s) into a Google Protocol Buffers message. You will likely want to use ProtobufConfigurator rather than using this class directly.
More...
#include <goby/middleware/application/configuration_reader.h>
|
static int | read_cfg (int argc, char *argv[], google::protobuf::Message *message, std::string *application_name, std::string *binary_name, boost::program_options::options_description *od_all, boost::program_options::variables_map *var_map, bool check_required_configuration=true) |
| Read the configuration into a Protobuf message using the command line parameters. More...
|
|
static void | check_required_cfg (const google::protobuf::Message &message, const std::string &binary) |
| Checks that all required fields are set (either via the command line or the configuration file) in the Protobuf message. More...
|
|
static void | get_protobuf_program_options (std::map< goby::GobyFieldOptions::ConfigurationOptions::ConfigAction, boost::program_options::options_description > &od_map, const google::protobuf::Descriptor *desc, std::map< std::string, std::string > &environmental_var_map) |
|
static void | get_positional_options (const google::protobuf::Descriptor *desc, std::vector< PositionalOption > &positional_options) |
|
static void | set_protobuf_program_option (const boost::program_options::variables_map &vm, google::protobuf::Message &message, const std::string &full_name, const boost::program_options::variable_value &value, bool overwrite_if_exists) |
|
static void | get_example_cfg_file (google::protobuf::Message *message, std::ostream *human_desc_ss, const std::string &indent="", goby::GobyFieldOptions::ConfigurationOptions::ConfigAction action=goby::GobyFieldOptions::ConfigurationOptions::ALWAYS) |
|
Class for reading configuration from command line and/or file(s) into a Google Protocol Buffers message. You will likely want to use ProtobufConfigurator rather than using this class directly.
- Todo:
- Rewrite to clean this up
Definition at line 66 of file configuration_reader.h.
◆ check_required_cfg()
static void goby::middleware::ConfigReader::check_required_cfg |
( |
const google::protobuf::Message & |
message, |
|
|
const std::string & |
binary |
|
) |
| |
|
static |
Checks that all required
fields are set (either via the command line or the configuration file) in the Protobuf message.
- Parameters
-
- Exceptions
-
◆ get_example_cfg_file()
◆ get_positional_options()
static void goby::middleware::ConfigReader::get_positional_options |
( |
const google::protobuf::Descriptor * |
desc, |
|
|
std::vector< PositionalOption > & |
positional_options |
|
) |
| |
|
static |
◆ get_protobuf_program_options()
static void goby::middleware::ConfigReader::get_protobuf_program_options |
( |
std::map< goby::GobyFieldOptions::ConfigurationOptions::ConfigAction, boost::program_options::options_description > & |
od_map, |
|
|
const google::protobuf::Descriptor * |
desc, |
|
|
std::map< std::string, std::string > & |
environmental_var_map |
|
) |
| |
|
static |
◆ read_cfg()
static int goby::middleware::ConfigReader::read_cfg |
( |
int |
argc, |
|
|
char * |
argv[], |
|
|
google::protobuf::Message * |
message, |
|
|
std::string * |
application_name, |
|
|
std::string * |
binary_name, |
|
|
boost::program_options::options_description * |
od_all, |
|
|
boost::program_options::variables_map * |
var_map, |
|
|
bool |
check_required_configuration = true |
|
) |
| |
|
static |
Read the configuration into a Protobuf message using the command line parameters.
- Parameters
-
argc | Argument count |
argv | Command line arguments |
message | Pointer to Protobuf message to populate with the configuration |
application_name | Pointer to string to populate with the application name (defaults to filename of argv[0], can be overridden with –app_name) |
od_all | Pointer to boost::program::options_description that will be populated with all the available command-line options |
var_map | Pointer to boost::program_options::variables_map that will be populated with the variables read from the command line |
check_required_configuration | If true, check_required_cfg will be called after populating the message |
- Returns
- maximum argc value read (if using tool_mode this may be less than argc)
◆ set_protobuf_program_option()
static void goby::middleware::ConfigReader::set_protobuf_program_option |
( |
const boost::program_options::variables_map & |
vm, |
|
|
google::protobuf::Message & |
message, |
|
|
const std::string & |
full_name, |
|
|
const boost::program_options::variable_value & |
value, |
|
|
bool |
overwrite_if_exists |
|
) |
| |
|
static |
The documentation for this class was generated from the following file: