c++ - How to set a default value to flagfile in gflags? -
i set flagfile this:
declare_string(flagfile); int main(int argc, char** argv) { flags_flagfile = "./conf/default.conf" parsecommandlineflags(&argc, &argv, true); .... }
then change flagfile command line
./main --flagfile=./conf/another.conf
but flagfile still "./conf/default.conf"
how set flagfile's default value , accept changes command line?
you can check parameters before calling parsecommandlineflags
function.
for example like:
std::regex flag_regex("--flagfile=(.+.conf)") std::smatch reg_match; if(std::regex_match(std::string(argv[1]), reg_match, flag_regex){ flags_flagfile = reg_match[0]; }
that way use other configuration file. can change regex match differently depending on need.
Comments
Post a Comment