SST/macro
stl_string.h
Go to the documentation of this file.
1 #ifndef STL_STRING_H
2 #define STL_STRING_H
3 
4 #include <set>
5 #include <vector>
6 #include <list>
7 #include <map>
8 #include <sstream>
9 
10 template <class Container>
11 std::string
12 one_dim_string(const Container& c, const char* open, const char* close){
13  std::stringstream sstr;
14  typename Container::const_iterator it, end = c.end();
15  sstr << open;
16  for (it=c.begin(); it != end; ++it){
17  sstr << " " << *it;
18  }
19  sstr << " " << close;
20  return sstr.str();
21 }
22 
23 template <class T>
24 std::string
25 stl_string(const std::set<T>& t){
26  return one_dim_string(t, "{", "}");
27 }
28 
29 template <class T>
30 std::string
31 stl_string(const std::vector<T>& t){
32  return one_dim_string(t, "[", "]");
33 }
34 
35 template <class T>
36 std::string
37 stl_string(const std::list<T>& t){
38  return one_dim_string(t, "<", ">");
39 }
40 
41 #endif // STL_STRING_H
std::string stl_string(const std::set< T > &t)
Definition: stl_string.h:25
std::string one_dim_string(const Container &c, const char *open, const char *close)
Definition: stl_string.h:12