| 452 | } |
| 453 | |
| 454 | int 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 | |
| 494 | int ErasureCodeLrc::init(ErasureCodeProfile &profile, |
| 495 | ostream *ss) |