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

Function validate_str_arg

src/common/cmdparse.cc:550–579  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

548}
549
550bool validate_str_arg(std::string_view value,
551 std::string_view type,
552 const arg_desc_t& desc,
553 std::ostream& os)
554{
555 if (type == "CephIPAddr") {
556 entity_addr_t addr;
557 if (addr.parse(value)) {
558 return true;
559 } else {
560 os << "failed to parse addr '" << value << "', should be ip:[port]";
561 return false;
562 }
563 } else if (type == "CephChoices") {
564 auto choices = desc.find("strings");
565 ceph_assert(choices != end(desc));
566 auto strings = choices->second;
567 if (find_first_in(strings, "|", [=](auto choice) {
568 return (value == choice);
569 })) {
570 return true;
571 } else {
572 os << "'" << value << "' not belong to '" << strings << "'";
573 return false;
574 }
575 } else {
576 // CephString or other types like CephPgid
577 return true;
578 }
579}
580
581bool validate_bool(const cmdmap_t& cmdmap,
582 const arg_desc_t& desc,

Callers 1

validate_argFunction · 0.85

Calls 4

find_first_inFunction · 0.85
endFunction · 0.50
parseMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected