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

Function validate_cmd

src/common/cmdparse.cc:650–690  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

648} // anonymous namespace
649
650bool validate_cmd(const std::string& desc,
651 const cmdmap_t& cmdmap,
652 std::ostream& os)
653{
654 return !find_first_in(desc, " ", [&](auto desc) {
655 auto arg_desc = cmddesc_get_args(desc);
656 if (arg_desc.empty()) {
657 return false;
658 }
659 ceph_assert(arg_desc.count("name"));
660 ceph_assert(arg_desc.count("type"));
661 auto name = arg_desc["name"];
662 auto type = arg_desc["type"];
663 if (arg_desc.count("n")) {
664 if (type == "CephInt") {
665 return !validate_arg<true, int64_t>(cmdmap, arg_desc,
666 name, type, os);
667 } else if (type == "CephFloat") {
668 return !validate_arg<true, double>(cmdmap, arg_desc,
669 name, type, os);
670 } else {
671 return !validate_arg<true, string>(cmdmap, arg_desc,
672 name, type, os);
673 }
674 } else {
675 if (type == "CephInt") {
676 return !validate_arg<false, int64_t>(cmdmap, arg_desc,
677 name, type, os);
678 } else if (type == "CephFloat") {
679 return !validate_arg<false, double>(cmdmap, arg_desc,
680 name, type, os);
681 } else if (type == "CephBool") {
682 return !validate_bool(cmdmap, arg_desc,
683 name, type, os);
684 } else {
685 return !validate_arg<false, string>(cmdmap, arg_desc,
686 name, type, os);
687 }
688 }
689 });
690}
691
692bool cmd_getval(const cmdmap_t& cmdmap,
693 std::string_view k, bool& val)

Callers 2

find_matched_hookMethod · 0.85
execute_commandMethod · 0.85

Calls 5

find_first_inFunction · 0.85
cmddesc_get_argsFunction · 0.85
validate_boolFunction · 0.85
emptyMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected