| 190 | } |
| 191 | |
| 192 | Result Model::save(std::ostream& out) { |
| 193 | if (!out.good()) { |
| 194 | return Result(ResultType::UNABLE_TO_OPEN_FILE, |
| 195 | "unable to open file for write"); |
| 196 | } |
| 197 | |
| 198 | // Before saving the model, always downgrade the specification version to |
| 199 | // the minimal version supporting everything this model needs |
| 200 | downgradeSpecificationVersion(); |
| 201 | |
| 202 | // validate on save |
| 203 | Result r = validate(); |
| 204 | if (!r.good()) { |
| 205 | return r; |
| 206 | } |
| 207 | |
| 208 | return saveSpecification(*m_spec, out); |
| 209 | } |
| 210 | |
| 211 | Result Model::save(const std::string& path) { |
| 212 | std::ofstream out(path, std::ios::binary); |