JODA  0.13.1 (59b41972)
JSON On-Demand Analysis
infix_iterator.h
Go to the documentation of this file.
1 //
2 // Created by Nico Schäfer on 11/2/17.
3 //
4 
5 #ifndef JODA_INFIX_ITERATOR_H
6 #define JODA_INFIX_ITERATOR_H
7 #include <iterator>
8 #include <ostream>
9 template <class T, class charT = char, class traits = std::char_traits<charT> >
11  : public std::iterator<std::output_iterator_tag, void, void, void, void> {
12  std::basic_ostream<charT, traits> *os;
13  charT const *delimiter;
14  bool first_elem;
15 
16  public:
17  typedef charT char_type;
18  typedef traits traits_type;
19  typedef std::basic_ostream<charT, traits> ostream_type;
21  : os(&s), delimiter(0), first_elem(true) {}
23  : os(&s), delimiter(d), first_elem(true) {}
25  // Here's the only real change from ostream_iterator:
26  // Normally, the '*os << item;' would come before the 'if'.
27  if (!first_elem && delimiter != 0) *os << delimiter;
28  *os << item;
29  first_elem = false;
30  return *this;
31  }
35 };
36 #endif // JODA_INFIX_ITERATOR_H
Definition: infix_iterator.h:11
infix_ostream_iterator(ostream_type &s)
Definition: infix_iterator.h:20
charT char_type
Definition: infix_iterator.h:17
infix_ostream_iterator< T, charT, traits > & operator*()
Definition: infix_iterator.h:32
std::basic_ostream< charT, traits > ostream_type
Definition: infix_iterator.h:19
infix_ostream_iterator< T, charT, traits > & operator++()
Definition: infix_iterator.h:33
infix_ostream_iterator< T, charT, traits > & operator++(int)
Definition: infix_iterator.h:34
traits traits_type
Definition: infix_iterator.h:18
infix_ostream_iterator< T, charT, traits > & operator=(T const &item)
Definition: infix_iterator.h:24
infix_ostream_iterator(ostream_type &s, charT const *d)
Definition: infix_iterator.h:22