Mercurial > hg > orthanc-python
comparison Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp @ 132:4cf3c2bc119f
sync
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 30 Aug 2023 11:55:33 +0200 |
parents | 5a60cbbe9bb0 |
children | 93c6f12bf339 |
comparison
equal
deleted
inserted
replaced
131:c55b0583084b | 132:4cf3c2bc119f |
---|---|
251 } | 251 } |
252 | 252 |
253 // helper class to convert std::map of headers to the plugin SDK C structure | 253 // helper class to convert std::map of headers to the plugin SDK C structure |
254 class PluginHttpHeaders | 254 class PluginHttpHeaders |
255 { | 255 { |
256 private: | |
256 std::vector<const char*> headersKeys_; | 257 std::vector<const char*> headersKeys_; |
257 std::vector<const char*> headersValues_; | 258 std::vector<const char*> headersValues_; |
259 | |
258 public: | 260 public: |
259 | 261 explicit PluginHttpHeaders(const std::map<std::string, std::string>& httpHeaders) |
260 PluginHttpHeaders(const std::map<std::string, std::string>& httpHeaders) | |
261 { | 262 { |
262 for (std::map<std::string, std::string>::const_iterator | 263 for (std::map<std::string, std::string>::const_iterator |
263 it = httpHeaders.begin(); it != httpHeaders.end(); it++) | 264 it = httpHeaders.begin(); it != httpHeaders.end(); ++it) |
264 { | 265 { |
265 headersKeys_.push_back(it->first.c_str()); | 266 headersKeys_.push_back(it->first.c_str()); |
266 headersValues_.push_back(it->second.c_str()); | 267 headersValues_.push_back(it->second.c_str()); |
267 } | 268 } |
268 } | 269 } |
1667 { | 1668 { |
1668 // Assume compatibility with the mainline | 1669 // Assume compatibility with the mainline |
1669 return true; | 1670 return true; |
1670 } | 1671 } |
1671 | 1672 |
1673 #ifdef _MSC_VER | |
1674 #define ORTHANC_SCANF sscanf_s | |
1675 #else | |
1676 #define ORTHANC_SCANF sscanf | |
1677 #endif | |
1678 | |
1672 // Parse the version | 1679 // Parse the version |
1673 int aa, bb, cc; | 1680 int aa, bb, cc = 0; |
1674 if ( | 1681 if ((ORTHANC_SCANF(version, "%4d.%4d.%4d", &aa, &bb, &cc) != 3 && |
1675 #ifdef _MSC_VER | 1682 ORTHANC_SCANF(version, "%4d.%4d", &aa, &bb) != 2) || |
1676 sscanf_s | |
1677 #else | |
1678 sscanf | |
1679 #endif | |
1680 (version, "%4d.%4d.%4d", &aa, &bb, &cc) != 3 || | |
1681 aa < 0 || | 1683 aa < 0 || |
1682 bb < 0 || | 1684 bb < 0 || |
1683 cc < 0) | 1685 cc < 0) |
1684 { | 1686 { |
1685 return false; | 1687 return false; |
3734 size_t size, | 3736 size_t size, |
3735 const std::string& transferSyntax) | 3737 const std::string& transferSyntax) |
3736 { | 3738 { |
3737 OrthancPluginDicomInstance* instance = OrthancPluginTranscodeDicomInstance( | 3739 OrthancPluginDicomInstance* instance = OrthancPluginTranscodeDicomInstance( |
3738 GetGlobalContext(), buffer, size, transferSyntax.c_str()); | 3740 GetGlobalContext(), buffer, size, transferSyntax.c_str()); |
3741 | |
3742 if (instance == NULL) | |
3743 { | |
3744 ORTHANC_PLUGINS_THROW_EXCEPTION(Plugin); | |
3745 } | |
3746 else | |
3747 { | |
3748 boost::movelib::unique_ptr<DicomInstance> result(new DicomInstance(instance)); | |
3749 result->toFree_ = true; | |
3750 return result.release(); | |
3751 } | |
3752 } | |
3753 #endif | |
3754 | |
3755 | |
3756 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 1) | |
3757 DicomInstance* DicomInstance::Load(const std::string& instanceId, | |
3758 OrthancPluginLoadDicomInstanceMode mode) | |
3759 { | |
3760 OrthancPluginDicomInstance* instance = OrthancPluginLoadDicomInstance( | |
3761 GetGlobalContext(), instanceId.c_str(), mode); | |
3739 | 3762 |
3740 if (instance == NULL) | 3763 if (instance == NULL) |
3741 { | 3764 { |
3742 ORTHANC_PLUGINS_THROW_EXCEPTION(Plugin); | 3765 ORTHANC_PLUGINS_THROW_EXCEPTION(Plugin); |
3743 } | 3766 } |