payload.h
Go to the documentation of this file.
00001 #ifndef CPR_PAYLOAD_H
00002 #define CPR_PAYLOAD_H
00003 
00004 #include <cstdint>
00005 #include <initializer_list>
00006 #include <memory>
00007 #include <string>
00008 
00009 #include "defines.h"
00010 
00011 namespace cpr {
00012 
00013 struct Pair {
00014     template <typename KeyType, typename ValueType,
00015               typename std::enable_if<!std::is_integral<ValueType>::value, bool>::type = true>
00016     Pair(KeyType&& p_key, ValueType&& p_value)
00017             : key{CPR_FWD(p_key)}, value{CPR_FWD(p_value)} {}
00018     template <typename KeyType>
00019     Pair(KeyType&& p_key, const std::int32_t& p_value)
00020             : key{CPR_FWD(p_key)}, value{std::to_string(p_value)} {}
00021 
00022     std::string key;
00023     std::string value;
00024 };
00025 
00026 class Payload {
00027   public:
00028     template <class It>
00029     Payload(const It begin, const It end) {
00030         for (It pair = begin; pair != end; ++pair) {
00031             AddPair(*pair);
00032         }
00033     }
00034     Payload(const std::initializer_list<Pair>& pairs);
00035 
00036     void AddPair(const Pair& pair);
00037 
00038     std::string content;
00039 };
00040 
00041 } // namespace cpr
00042 
00043 #endif


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