MCPcopy Create free account
hub / github.com/ceph/ceph / cmd_getval

Function cmd_getval

src/common/cmdparse.cc:692–724  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

690}
691
692bool cmd_getval(const cmdmap_t& cmdmap,
693 std::string_view k, bool& val)
694{
695 /*
696 * Specialized getval for booleans. CephBool didn't exist before Nautilus,
697 * so earlier clients are sent a CephChoices argdesc instead, and will
698 * send us a "--foo-bar" value string for boolean arguments.
699 */
700 auto found = cmdmap.find(k);
701 if (found == cmdmap.end()) {
702 return false;
703 }
704 try {
705 val = boost::get<bool>(found->second);
706 return true;
707 } catch (boost::bad_get&) {
708 try {
709 std::string expected{"--"};
710 expected += k;
711 std::replace(expected.begin(), expected.end(), '_', '-');
712
713 std::string v_str = boost::get<std::string>(found->second);
714 if (v_str == expected) {
715 val = true;
716 return true;
717 } else {
718 throw bad_cmd_get(k, cmdmap);
719 }
720 } catch (boost::bad_get&) {
721 throw bad_cmd_get(k, cmdmap);
722 }
723 }
724}
725
726bool cmd_getval_compat_cephbool(
727 const cmdmap_t& cmdmap,

Callers 3

validate_boolFunction · 0.70
validate_argFunction · 0.70

Calls 5

replaceFunction · 0.85
bad_cmd_getClass · 0.85
findMethod · 0.45
endMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected