]> Dogcows Code - chaz/yoink/blob - src/stlplus/strings/string_sequence.tpp
build system enhancements
[chaz/yoink] / src / stlplus / strings / string_sequence.tpp
1 ////////////////////////////////////////////////////////////////////////////////
2
3 // Author: Andy Rushton
4 // Copyright: (c) Southampton University 1999-2004
5 // (c) Andy Rushton 2004-2009
6 // License: BSD License, see ../docs/license.html
7
8 ////////////////////////////////////////////////////////////////////////////////
9 #include "string_pair.hpp"
10
11 namespace stlplus
12 {
13
14 ////////////////////////////////////////////////////////////////////////////////
15 // any forward iterator sequence
16
17 template <typename I, typename S>
18 std::string sequence_to_string(I begin,
19 I end,
20 S to_string,
21 const std::string& separator)
22 {
23 std::string result;
24 for (I i = begin; i != end; i++)
25 {
26 if (i != begin) result += separator;
27 result += to_string(*i);
28 }
29 return result;
30 }
31
32 ////////////////////////////////////////////////////////////////////////////////
33 // any sequence where the value is a pair
34
35 template <typename I, typename S1, typename S2>
36 std::string pair_sequence_to_string(I begin,
37 I end,
38 S1 to_string_fn1,
39 S2 to_string_fn2,
40 const std::string& pair_separator,
41 const std::string& separator)
42 {
43 std::string result;
44 for (I i = begin; i != end; i++)
45 {
46 if (i != begin) result += separator;
47 result += pair_to_string(*i, to_string_fn1, to_string_fn2, pair_separator);
48 }
49 return result;
50 }
51
52 ////////////////////////////////////////////////////////////////////////////////
53
54 } // end namespace stlplus
This page took 0.031045 seconds and 4 git commands to generate.