mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 08:47:17 +01:00
4a6bfc086c
Switched to POCO library for unified platform/library interface. Deprecated the external module API. It was creating more problems than solving. Removed most built-in libraries in favor of system libraries for easier maintenance. Cleaned and secured code with help from static analyzers.
60 lines
1.6 KiB
C++
60 lines
1.6 KiB
C++
#include "cpr/curl_container.h"
|
|
|
|
|
|
namespace cpr {
|
|
template <class T>
|
|
CurlContainer<T>::CurlContainer(const std::initializer_list<T>& containerList)
|
|
: containerList_(containerList) {}
|
|
|
|
template <class T>
|
|
void CurlContainer<T>::Add(const std::initializer_list<T>& containerList) {
|
|
for (const T& element : containerList) {
|
|
containerList_.push_back(std::move(element));
|
|
}
|
|
}
|
|
|
|
template <class T>
|
|
void CurlContainer<T>::Add(const T& element) {
|
|
containerList_.push_back(std::move(element));
|
|
}
|
|
|
|
template <>
|
|
const std::string CurlContainer<Parameter>::GetContent(const CurlHolder& holder) const {
|
|
std::string content{};
|
|
for (const Parameter& parameter : containerList_) {
|
|
if (!content.empty()) {
|
|
content += "&";
|
|
}
|
|
|
|
std::string escapedKey = holder.urlEncode(parameter.key);
|
|
if (parameter.value.empty()) {
|
|
content += escapedKey;
|
|
} else {
|
|
std::string escapedValue = holder.urlEncode(parameter.value);
|
|
content += escapedKey + "=";
|
|
content += escapedValue;
|
|
}
|
|
};
|
|
|
|
return content;
|
|
}
|
|
|
|
template <>
|
|
const std::string CurlContainer<Pair>::GetContent(const CurlHolder& holder) const {
|
|
std::string content{};
|
|
for (const cpr::Pair& element : containerList_) {
|
|
if (!content.empty()) {
|
|
content += "&";
|
|
}
|
|
std::string escaped = holder.urlEncode(element.value);
|
|
content += element.key + "=" + escaped;
|
|
}
|
|
|
|
return content;
|
|
}
|
|
|
|
template class CurlContainer<Pair>;
|
|
template class CurlContainer<Parameter>;
|
|
|
|
} // namespace cpr
|