X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fstlplus%2Fstrings%2Fprint_sequence.tpp;fp=src%2Fstlplus%2Fstrings%2Fprint_sequence.tpp;h=cea8056e2296a9ec90c865c4aaa644d5c3e3fd4c;hb=6b0a0d0efafe34d48ab344fca3b479553bd4e62c;hp=0000000000000000000000000000000000000000;hpb=85783316365181491a3e3c0c63659972477cebba;p=chaz%2Fyoink diff --git a/src/stlplus/strings/print_sequence.tpp b/src/stlplus/strings/print_sequence.tpp new file mode 100644 index 0000000..cea8056 --- /dev/null +++ b/src/stlplus/strings/print_sequence.tpp @@ -0,0 +1,50 @@ +//////////////////////////////////////////////////////////////////////////////// + +// Author: Andy Rushton +// Copyright: (c) Southampton University 1999-2004 +// (c) Andy Rushton 2004-2009 +// License: BSD License, see ../docs/license.html + +//////////////////////////////////////////////////////////////////////////////// +#include "print_pair.hpp" + +namespace stlplus +{ + + //////////////////////////////////////////////////////////////////////////////// + // any forward iterator sequence + + template + void print_sequence(std::ostream& device, + I begin, I end, + S print_fn, + const std::string& separator) + { + for (I i = begin; i != end; i++) + { + if (i != begin) device << separator; + print_fn(device, *i); + } + } + + //////////////////////////////////////////////////////////////////////////////// + // any sequence where the value is a pair + + template + void print_pair_sequence(std::ostream& device, + I begin, I end, + S1 print_fn1, + S2 print_fn2, + const std::string& pair_separator, + const std::string& separator) + { + for (I i = begin; i != end; i++) + { + if (i != begin) device << separator; + print_pair(device, *i, print_fn1, print_fn2, pair_separator); + } + } + + //////////////////////////////////////////////////////////////////////////////// + +} // end namespace stlplus