| 109 | } |
| 110 | |
| 111 | int ErasureCodeLrc::layers_description(const ErasureCodeProfile &profile, |
| 112 | json_spirit::mArray *description, |
| 113 | ostream *ss) const |
| 114 | { |
| 115 | if (profile.count("layers") == 0) { |
| 116 | *ss << "could not find 'layers' in " << profile << std::endl; |
| 117 | return ERROR_LRC_DESCRIPTION; |
| 118 | } |
| 119 | string str = profile.find("layers")->second; |
| 120 | try { |
| 121 | json_spirit::mValue json; |
| 122 | json_spirit::read_or_throw(str, json); |
| 123 | |
| 124 | if (json.type() != json_spirit::array_type) { |
| 125 | *ss << "layers='" << str |
| 126 | << "' must be a JSON array but is of type " |
| 127 | << json.type() << " instead" << std::endl; |
| 128 | return ERROR_LRC_ARRAY; |
| 129 | } |
| 130 | *description = json.get_array(); |
| 131 | } catch (json_spirit::Error_position &e) { |
| 132 | *ss << "failed to parse layers='" << str << "'" |
| 133 | << " at line " << e.line_ << ", column " << e.column_ |
| 134 | << " : " << e.reason_ << std::endl; |
| 135 | return ERROR_LRC_PARSE_JSON; |
| 136 | } |
| 137 | return 0; |
| 138 | } |
| 139 | |
| 140 | int ErasureCodeLrc::layers_parse(const string &description_string, |
| 141 | json_spirit::mArray description, |