comparison Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp @ 284:64bf8914f02e

sync + no more need of "-DORTHANC_FRAMEWORK_ADDITIONAL_LIBRARIES" to dynamically link against system-wide orthanc framework
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 12 Jun 2021 08:49:52 +0200
parents c7dc70a0a477
children 1280b40d6696
comparison
equal deleted inserted replaced
283:e7678a7b10bb 284:64bf8914f02e
2724 { 2724 {
2725 assert(*it != NULL); 2725 assert(*it != NULL);
2726 delete *it; 2726 delete *it;
2727 } 2727 }
2728 2728
2729 size_ = 0;
2729 content_.clear(); 2730 content_.clear();
2730 } 2731 }
2731 2732
2732 void Flatten(std::string& target) const 2733 /**
2734 * Since Orthanc 1.9.3, this function also clears the content of
2735 * the ChunkedBuffer in order to mimic the behavior of the
2736 * original class "Orthanc::ChunkedBuffer". This prevents the
2737 * forgetting of calling "Clear()" in order to reduce memory
2738 * consumption.
2739 **/
2740 void Flatten(std::string& target)
2733 { 2741 {
2734 target.resize(size_); 2742 target.resize(size_);
2735 2743
2736 size_t pos = 0; 2744 size_t pos = 0;
2737 2745
2743 if (s != 0) 2751 if (s != 0)
2744 { 2752 {
2745 memcpy(&target[pos], (*it)->c_str(), s); 2753 memcpy(&target[pos], (*it)->c_str(), s);
2746 pos += s; 2754 pos += s;
2747 } 2755 }
2756
2757 delete *it;
2748 } 2758 }
2749 2759
2750 assert(size_ == 0 || 2760 assert(pos == target.size());
2751 pos == target.size()); 2761
2762 size_ = 0;
2763 content_.clear();
2752 } 2764 }
2753 2765
2754 void AddChunk(const void* data, 2766 void AddChunk(const void* data,
2755 size_t size) 2767 size_t size)
2756 { 2768 {
2777 const HttpClient::HttpHeaders& GetHeaders() const 2789 const HttpClient::HttpHeaders& GetHeaders() const
2778 { 2790 {
2779 return headers_; 2791 return headers_;
2780 } 2792 }
2781 2793
2782 const ChunkedBuffer& GetBody() const 2794 ChunkedBuffer& GetBody()
2783 { 2795 {
2784 return body_; 2796 return body_;
2785 } 2797 }
2786 2798
2787 virtual void AddHeader(const std::string& key, 2799 virtual void AddHeader(const std::string& key,