kv.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <utility>
4 #include <string>
5 #include <vector>
6 #include <sstream>
7 #include <iterator>
8 
9 class KV : public std::pair<std::string, std::string>
10 {
11  template <typename T>
12  static std::string make_list(bool first, const T& t)
13  {
14  std::stringstream s;
15  if (!first)
16  s << ";";
17  s << t;
18  return s.str();
19  }
20 
21  template <typename T, typename... Ts>
22  static std::string make_list(bool first, const T& t, Ts&&... list)
23  {
24  std::stringstream s;
25  s << make_list(first, t);
26  s << make_list(false, list...);
27  return s.str();
28  }
29 
30  static std::string make_list(bool first, std::vector<std::string> list)
31  {
32  std::stringstream s;
33  std::copy(list.begin(), list.end() - 1, std::ostream_iterator<std::string>(s, ";"));
34  s << list.back();
35 
36  return s.str();
37  }
38 
39 public:
40  template <typename... Ts>
41  KV(const std::string& k, const Ts&... list) : std::pair<std::string, std::string>(k, make_list(true, list...))
42  {
43  }
44 };
static std::string make_list(bool first, const T &t, Ts &&... list)
Definition: kv.h:22
XmlRpcServer s
KV(const std::string &k, const Ts &... list)
Definition: kv.h:41
static std::string make_list(bool first, std::vector< std::string > list)
Definition: kv.h:30
static std::string make_list(bool first, const T &t)
Definition: kv.h:12
Definition: kv.h:9


pf_driver
Author(s): Harsh Deshpande
autogenerated on Fri Feb 24 2023 03:59:35