------------------------------------------------------------------------------
| 165 | |
| 166 | //------------------------------------------------------------------------------ |
| 167 | void vtkObjectManager::Export(const std::string& filename, int indent, char indentChar) |
| 168 | { |
| 169 | std::string objectStatesFileName = filename, blobsFileName = filename + ".blobs.json"; |
| 170 | if (!vtksys::SystemTools::StringEndsWith(filename, ".json")) |
| 171 | { |
| 172 | objectStatesFileName = filename + ".states.json"; |
| 173 | blobsFileName = filename + ".blobs.json"; |
| 174 | } |
| 175 | { |
| 176 | std::ofstream ofs(objectStatesFileName); |
| 177 | try |
| 178 | { |
| 179 | ofs << this->Context->States().dump(indent, indentChar); |
| 180 | } |
| 181 | catch (nlohmann::json::type_error& e) |
| 182 | { |
| 183 | vtkErrorMacro(<< "Failed to dump json. message=" << e.what()); |
| 184 | } |
| 185 | } |
| 186 | { |
| 187 | std::ofstream ofs(blobsFileName); |
| 188 | try |
| 189 | { |
| 190 | ofs << this->Context->Blobs().dump(indent, indentChar); |
| 191 | } |
| 192 | catch (nlohmann::json::type_error& e) |
| 193 | { |
| 194 | vtkErrorMacro(<< "Failed to dump json. message=" << e.what()); |
| 195 | } |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | //------------------------------------------------------------------------------ |
| 200 | std::vector<vtkTypeUInt32> vtkObjectManager::ImportFromJSON(const nlohmann::json& importJson) |