4 #include <SimoxUtility/json/json.hpp>
9 std::optional<armarx::motion::mdb::arondto::MDBReference>
createFromFile(
const std::filesystem::path& pathToInfoJson)
11 if (std::filesystem::exists(pathToInfoJson) && std::filesystem::is_regular_file(pathToInfoJson))
13 std::ifstream ifs(pathToInfoJson);
14 std::string file_content((std::istreambuf_iterator<char>(ifs)), (std::istreambuf_iterator<char>()));
16 armarx::motion::mdb::arondto::MDBReference motionReference;
17 auto json = nlohmann::json::parse(file_content);
19 motionReference.id = json[
"id"];
20 motionReference.associatedInstitution = json[
"associatedInstitution"];
21 motionReference.associatedProject = json[
"associatedProject"];
22 motionReference.comment = json[
"comment"];
24 motionReference.createdUser = json[
"createdUser"];
26 motionReference.modifiedUser = json[
"modifiedUser"];
27 motionReference.date = json[
"date"];
28 for (
auto it = json[
"attachedFiles"].begin(); it != json[
"attachedFiles"].end(); ++it)
30 const auto& key = it.key();
31 const auto&
value = it.value();
33 for (
const auto& attachedFile :
value)
35 armarx::motion::mdb::arondto::FileReference fileRef;
36 fileRef.attachedToId = attachedFile[
"attachedToId"];
38 fileRef.createdUser = attachedFile[
"createdUser"];
39 fileRef.description = attachedFile[
"description"];
40 fileRef.fileName = attachedFile[
"fileName"];
42 motionReference.attachedFiles[key].emplace_back(fileRef);
45 return motionReference;