summaryrefslogtreecommitdiff
path: root/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/stringizers.h
blob: 79a416de33d6416f2ea3239d1c06495f849f9bda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//          Copyright Joakim Karlsson & Kim Gräsman 2010-2012.
// Distributed under the Boost Software License, Version 1.0.
//    (See accompanying file LICENSE_1_0.txt or copy at
//          http://www.boost.org/LICENSE_1_0.txt)

#ifndef IGLOO_STRINGIZERS_H
#define IGLOO_STRINGIZERS_H

namespace snowhouse
{

  namespace detail
  {

    template<typename Container>
      struct SequentialContainerStringizer
      {
        static std::string
        ToString(const Container& cont)
        {
          std::ostringstream stm;
          typedef typename Container::const_iterator Iterator;

          stm << "[ ";
          for (Iterator it = cont.begin(); it != cont.end();)
          {
            stm << snowhouse::Stringize(*it);

            if (++it != cont.end())
            {
              stm << ", ";
            }
          }
          stm << " ]";
          return stm.str();
        }
      };
  }

  template<typename T>
    struct Stringizer<std::vector<T> > : detail::SequentialContainerStringizer<
        std::vector<T> >
    {
    };

  template<typename T>
    struct Stringizer<std::deque<T> > : detail::SequentialContainerStringizer<
        std::deque<T> >
    {
    };

  template<typename T>
    struct Stringizer<std::list<T> > : detail::SequentialContainerStringizer<
        std::list<T> >
    {
    };
}

#endif