parameters.cpp
Go to the documentation of this file.
00001 #include "cpr/parameters.h"
00002 
00003 #include <initializer_list>
00004 #include <string>
00005 
00006 #include "cpr/util.h"
00007 
00008 namespace cpr {
00009 
00010 Parameters::Parameters(const std::initializer_list<Parameter>& parameters) {
00011     for (const auto& parameter : parameters) {
00012         AddParameter(parameter);
00013     }
00014 }
00015 
00016 void Parameters::AddParameter(const Parameter& parameter) {
00017     if (!content.empty()) {
00018         content += "&";
00019     }
00020 
00021     auto escapedKey = cpr::util::urlEncode(parameter.key);
00022     if (parameter.value.empty()) {
00023         content += escapedKey;
00024     } else {
00025         auto escapedValue = cpr::util::urlEncode(parameter.value);
00026         content += escapedKey + "=" + escapedValue;
00027     }
00028 }
00029 
00030 } // namespace cpr


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:05