#include <swcdb/core/config/Settings.h>
Classes | |
struct | DynFile |
Public Types | |
typedef std::shared_ptr< Settings > | Ptr |
typedef void | init_option_t(Settings *) |
Public Member Functions | |
Settings () | |
~Settings () noexcept | |
void | init (int argc, char *argv[], init_option_t app, init_option_t post_cmd_args) |
void | init_options () |
void | parse_args (int argc, char *argv[]) |
void | load_files_by (const char *fileprop, bool allow_unregistered) |
void | parse_file (const std::string &fname, const char *onchg) |
void | init_process (bool with_pid_file, const char *port_cfg=nullptr) |
std::string | usage_str (const char *usage=nullptr) |
void | check_dynamic_files () noexcept |
![]() | |
SWC_CAN_INLINE | Properties () noexcept |
SWC_CAN_INLINE | ~Properties () noexcept |
void | reset () noexcept |
void | load_from (const Config::Parser::Options &opts, bool only_guarded=false) |
void | load (const std::string &fname, const Config::ParserConfig &filedesc, const Config::ParserConfig &cmddesc, bool allow_unregistered=false, bool only_guarded=false) |
void | reload (const std::string &fname, const Config::ParserConfig &filedesc, const Config::ParserConfig &cmddesc) |
void | alias (const char *primary, const char *secondary) |
void | set (const char *name, Property::Value::Ptr p) |
bool SWC_PURE_FUNC | has (const char *name) const noexcept |
bool | defaulted (const char *name) const |
std::string | to_string (const char *name) const |
void | get_names (Strings &names) const |
void | remove (const char *name) |
Property::Value::Ptr | get_ptr (const char *name, bool null_ok=false) const |
template<typename T > | |
SWC_SHOULD_NOT_INLINE T * | get (const char *name) const |
std::string | get_str (const char *name) const |
std::string | get_str (const char *name, const std::string &v) const |
Strings | get_strs (const char *name) const |
bool | get_bool (const char *name) const |
bool | get_bool (const char *name, bool v) const |
bool | get_gbool (const char *name) const |
int32_t | get_enum (const char *name) const |
int32_t | get_genum (const char *name) const |
uint8_t | get_i8 (const char *name) const |
uint16_t | get_i16 (const char *name) const |
uint16_t | get_i16 (const char *name, uint16_t v) const |
int32_t | get_i32 (const char *name) const |
int32_t | get_i32 (const char *name, int32_t v) const |
int64_t | get_i64 (const char *name) const |
void | print (std::ostream &out, bool include_default=false) const |
Public Attributes | |
ParserConfig | cmdline_desc |
ParserConfig | file_desc |
std::string | install_path |
std::string | executable |
![]() | |
Core::MutexSptd | mutex |
Private Attributes | |
Parser::Options | m_cmd_args |
Core::Vector< DynFile > | m_dyn_files |
Definition at line 25 of file Settings.h.
typedef void SWC::Config::Settings::init_option_t(Settings *) |
Definition at line 30 of file Settings.h.
typedef std::shared_ptr<Settings> SWC::Config::Settings::Ptr |
Definition at line 29 of file Settings.h.
SWC_SHOULD_NOT_INLINE SWC::Config::Settings::Settings | ( | ) |
Definition at line 37 of file Settings.cc.
References cmdline_desc, SWC::Config::ParserConfig::definition(), and usage_str().
|
noexcept |
Definition at line 41 of file Settings.cc.
|
noexcept |
Definition at line 394 of file Settings.cc.
References cmdline_desc, file_desc, SWC::LOG_DEBUG, m_dyn_files, SWC::Config::Properties::mutex, SWC::Config::Properties::reload(), SWC_LOG_CURRENT_EXCEPTION, and SWC_LOGF.
SWC_SHOULD_NOT_INLINE void SWC::Config::Settings::init | ( | int | argc, |
char * | argv[], | ||
Settings::init_option_t | init_app_options, | ||
Settings::init_option_t | init_post_cmd_args | ||
) |
Definition at line 44 of file Settings.cc.
References executable, SWC::Config::Properties::get_bool(), SWC::Config::Properties::has(), SWC::Config::init_app_options(), init_options(), SWC::Config::init_post_cmd_args(), install_path, SWC::LOG_DEBUG, SWC::LOG_ERROR, parse_args(), SWC::Error::print(), SWC_LOG_OSTREAM, SWC_LOG_OUT, SWC_PRINT, SWC_PRINT_CLOSE, SWC_QUICK_EXIT, and swcdb_copyrights().
SWC_SHOULD_NOT_INLINE void SWC::Config::Settings::init_options | ( | ) |
Definition at line 97 of file Settings.cc.
References SWC::Config::ParserConfig::add_options(), SWC::Config::boo(), cmdline_desc, SWC::Core::LogWriter::from_string(), SWC::Config::g_boo(), SWC::Config::g_enum(), install_path, SWC::LOG_INFO, SWC::Core::logger, SWC::Core::LogWriter::repr(), SWC::Core::LogWriter::set_level(), SWC::Config::str(), SWC::Config::strs(), USE_SWC_PATH_ETC, USE_SWC_PATH_LOG, and SWC::Config::Property::Value::zero_token().
Referenced by init().
SWC_SHOULD_NOT_INLINE void SWC::Config::Settings::init_process | ( | bool | with_pid_file, |
const char * | port_cfg = nullptr |
||
) |
Definition at line 334 of file Settings.cc.
References SWC::Core::LogWriter::daemon(), SWC::Config::Properties::defaulted(), executable, SWC::Config::Properties::get_gbool(), SWC::Config::Properties::get_i16(), SWC::Config::Properties::get_str(), SWC::Config::Properties::has(), SWC::Core::LogWriter::initialize(), install_path, SWC::Core::logger, SWC_QUICK_EXIT, and SWC::Core::to_string().
SWC_SHOULD_NOT_INLINE void SWC::Config::Settings::load_files_by | ( | const char * | fileprop, |
bool | allow_unregistered | ||
) |
Definition at line 190 of file Settings.cc.
References SWC::Core::Vector< T, SizeT, GROW_SZ >::cbegin(), SWC::Core::Vector< T, SizeT, GROW_SZ >::cend(), cmdline_desc, file_desc, SWC::Config::Properties::get_str(), SWC::Config::Properties::has(), SWC::Config::Properties::load(), SWC::LOG_WARN, m_dyn_files, SWC::Config::Properties::mutex, SWC_CURRENT_EXCEPTION, SWC_LOG_OSTREAM, and SWC_LOG_OUT.
Referenced by parse_file().
SWC_SHOULD_NOT_INLINE void SWC::Config::Settings::parse_args | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 137 of file Settings.cc.
References SWC::Config::ParserConfig::add(), cmdline_desc, SWC::Config::Parser::config, file_desc, SWC::Config::Parser::get_options(), SWC::Config::Properties::get_str(), SWC::Config::Properties::has(), SWC::Config::Properties::load_from(), m_cmd_args, SWC::Config::Parser::own_options(), SWC::Config::Parser::parse_cmdline(), parse_file(), SWC_PRINT, SWC_PRINT_CLOSE, SWC_QUICK_EXIT, swcdb_copyrights(), and swcdb_version().
Referenced by init().
SWC_SHOULD_NOT_INLINE void SWC::Config::Settings::parse_file | ( | const std::string & | fname, |
const char * | onchg | ||
) |
Definition at line 171 of file Settings.cc.
References cmdline_desc, SWC::Comm::Protocol::FsBroker::Handler::exists(), file_desc, SWC::Config::Properties::get_str(), SWC::Config::Properties::load(), load_files_by(), SWC::Config::Properties::load_from(), m_cmd_args, and SWC_THROWF.
Referenced by SWC::Config::init_post_cmd_args(), and parse_args().
std::string SWC::Config::Settings::usage_str | ( | const char * | usage = nullptr | ) |
Definition at line 365 of file Settings.cc.
References executable, SWC::format(), and swcdb_copyrights().
Referenced by SWC::Config::init_app_options(), and Settings().
ParserConfig SWC::Config::Settings::cmdline_desc |
Definition at line 32 of file Settings.h.
Referenced by check_dynamic_files(), SWC::Config::init_app_options(), SWC::Config::init_client_options(), init_options(), load_files_by(), parse_args(), parse_file(), and Settings().
std::string SWC::Config::Settings::executable |
Definition at line 36 of file Settings.h.
Referenced by init(), init_process(), and usage_str().
ParserConfig SWC::Config::Settings::file_desc |
Definition at line 33 of file Settings.h.
Referenced by check_dynamic_files(), SWC::Config::init_comm_options(), SWC::Config::init_fs_options(), load_files_by(), parse_args(), and parse_file().
std::string SWC::Config::Settings::install_path |
Definition at line 35 of file Settings.h.
Referenced by init(), init_options(), and init_process().
|
private |
Definition at line 61 of file Settings.h.
Referenced by parse_args(), and parse_file().
|
private |
Definition at line 81 of file Settings.h.
Referenced by check_dynamic_files(), and load_files_by().