ESA JPIP server  0.1
base.h
Go to the documentation of this file.
1 #ifndef _BASE_H_
2 #define _BASE_H_
3 
4 
5 #include <map>
6 #include <vector>
7 #include <sstream>
8 
9 
13 struct base
14 {
15 
20  template<typename TYPE> static std::string to_string(TYPE val)
21  {
22  std::ostringstream oss;
23  oss << val;
24  return oss.str();
25  }
26 
30  template<typename T> static void copy(std::vector<T>& dest, const std::vector<T>& src)
31  {
32  dest.clear();
33  for (typename std::vector<T>::const_iterator i = src.begin(); i != src.end(); i++)
34  dest.push_back(*i);
35  }
36 
40  template<typename T> static void copy(std::vector< std::vector<T> >& dest, const std::vector< std::vector<T> >& src)
41  {
42  int n = 0;
43  dest.clear();
44  dest.resize(src.size());
45  for (typename std::vector< std::vector<T> >::const_iterator i = src.begin(); i != src.end(); i++)
46  base::copy(dest[n++], *i);
47  }
48 
52  template<typename T1, typename T2> static void copy(std::multimap<T1, T2>& dest, const std::multimap<T1, T2>& src)
53  {
54  dest.clear();
55  for (typename std::multimap<T1, T2>::const_iterator i = src.begin(); i != src.end(); i++)
56  dest.insert(*i);
57  }
58 
59 };
60 
61 
62 #endif /* _BASE_H_ */
static void copy(std::vector< T > &dest, const std::vector< T > &src)
Copies a vector.
Definition: base.h:30
static void copy(std::vector< std::vector< T > > &dest, const std::vector< std::vector< T > > &src)
Copies a vector of vectors.
Definition: base.h:40
static void copy(std::multimap< T1, T2 > &dest, const std::multimap< T1, T2 > &src)
Copies a multimap.
Definition: base.h:52
static std::string to_string(TYPE val)
Converts a value to a string.
Definition: base.h:20
Contains a set of useful static methods used by the application.
Definition: base.h:13