xmscore  1.0
utility.h
Go to the documentation of this file.
1 #pragma once
2 //------------------------------------------------------------------------------
7 //------------------------------------------------------------------------------
8 
9 #include <sstream>
10 #include <utility>
11 
12 namespace xms
13 {
14 //----- pairs ------------------------------------------------------------------
15 
16 typedef std::pair<int, int> PAIR_I_I;
17 
18 //------------------------------------------------------------------------------
23 //------------------------------------------------------------------------------
24 template <class _T, class _U>
25 std::ostream& operator<<(std::ostream& a_output, const std::pair<_T, _U>& a_value)
26 {
27  a_output << ",size=" << a_value.size();
28  // add loop here like std::vector
29  return a_output;
30 }
31 //------------------------------------------------------------------------------
36 //------------------------------------------------------------------------------
37 template <typename T>
38 void VecToStream(std::stringstream& a_ss, const T& a_v, std::string a_label)
39 {
40  // if (!a_v.empty() && !a_ss.str().empty()) { a_ss << ","; }
41  for (size_t i = 0; i < a_v.size(); ++i)
42  {
43  if (i > 0)
44  a_ss << " ";
45  a_ss << a_v[i];
46  }
47  a_ss << "=" << a_label << " ";
48  a_ss << "\n";
49 } // VecToStream
50 
51 } // namespace xms {
void VecToStream(std::stringstream &a_ss, const T &a_v, std::string a_label)
Export a vector or bitset to a stringstream.
Definition: utility.h:38
std::pair< int, int > PAIR_I_I
short rename
Definition: utility.h:16