static bool ReadFile(std::string& result, const std::string& path) { OrthancPluginMemoryBuffer tmp; if (OrthancPluginReadFile(context_, &tmp, path.c_str())) { return false; } else { result.assign(reinterpret_cast<const char*>(tmp.data), tmp.size); OrthancPluginFreeMemoryBuffer(context_, &tmp); return true; } }
static bool GetQueryDicom(Json::Value& value, const OrthancPluginWorklistQuery* query) { OrthancPluginMemoryBuffer dicom; if (OrthancPluginWorklistGetDicomQuery(context_, &dicom, query)) { return false; } char* json = OrthancPluginDicomBufferToJson(context_, reinterpret_cast<const char*>(dicom.data), dicom.size, OrthancPluginDicomToJsonFormat_Short, static_cast<OrthancPluginDicomToJsonFlags>(0), 0); OrthancPluginFreeMemoryBuffer(context_, &dicom); return ConvertToJson(value, json); }
void OrthancContext::GetDicomForInstance(std::string& result, const std::string& instanceId) { Check(); OrthancPluginMemoryBuffer buffer; if (OrthancPluginGetDicomForInstance(context_, &buffer, instanceId.c_str())) { throw std::runtime_error("No DICOM instance with Orthanc ID: " + instanceId); } if (buffer.size == 0) { result.clear(); } else { result.assign(reinterpret_cast<char*>(buffer.data), buffer.size); } OrthancPluginFreeMemoryBuffer(context_, &buffer); }