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

Method parse_rule_step

src/erasure-code/lrc/ErasureCodeLrc.cc:454–492  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

452}
453
454int ErasureCodeLrc::parse_rule_step(const string &description_string,
455 json_spirit::mArray description,
456 ostream *ss)
457{
458 stringstream json_string;
459 json_spirit::write(description, json_string);
460 string op;
461 string type;
462 int n = 0;
463 int position = 0;
464 for (vector<json_spirit::mValue>::iterator i = description.begin();
465 i != description.end();
466 ++i, position++) {
467 if ((position == 0 || position == 1) &&
468 i->type() != json_spirit::str_type) {
469 *ss << "element " << position << " of the array "
470 << json_string.str() << " found in " << description_string
471 << " must be a JSON string but is of type "
472 << i->type() << " instead" << std::endl;
473 return position == 0 ? ERROR_LRC_RULE_OP : ERROR_LRC_RULE_TYPE;
474 }
475 if (position == 2 && i->type() != json_spirit::int_type) {
476 *ss << "element " << position << " of the array "
477 << json_string.str() << " found in " << description_string
478 << " must be a JSON int but is of type "
479 << i->type() << " instead" << std::endl;
480 return ERROR_LRC_RULE_N;
481 }
482
483 if (position == 0)
484 op = i->get_str();
485 if (position == 1)
486 type = i->get_str();
487 if (position == 2)
488 n = i->get_int();
489 }
490 rule_steps.push_back(Step(op, type, n));
491 return 0;
492}
493
494int ErasureCodeLrc::init(ErasureCodeProfile &profile,
495 ostream *ss)

Callers

nothing calls this directly

Calls 9

StepClass · 0.85
writeFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
typeMethod · 0.45
strMethod · 0.45
get_strMethod · 0.45
get_intMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected