foursome.hpp
1: #ifndef FOURSOME_HPP
2: #define FOURSOME_HPP
3: /*------------------------------------------------------------------------------
4:
5: Author: Andy Rushton, from an original by Dan Milton
6: Copyright: (c) Andy Rushton, 2004
7: License: BSD License, see ../docs/license.html
8:
9: The next in the series pair->triple->foursome
10:
11: Originally called quadruple but that clashed (as did quad) with system
12: libraries on some operating systems
13:
14: ------------------------------------------------------------------------------*/
15:
16: #include "os_fixes.hpp"
17: #include "persistent.hpp"
18:
19: ////////////////////////////////////////////////////////////////////////////////
20: // the foursome class
21:
22: template<typename T1, typename T2, typename T3, typename T4>
23: struct foursome
24: {
25: typedef T1 first_type;
26: typedef T2 second_type;
27: typedef T3 third_type;
28: typedef T4 fourth_type;
29:
30: T1 first;
31: T2 second;
32: T3 third;
33: T4 fourth;
34:
35: foursome(void);
36: foursome(const T1& p1, const T2& p2, const T3& p3, const T4& p4);
37: foursome(const foursome<T1,T2,T3,T4>& t2);
38: };
39:
40: ////////////////////////////////////////////////////////////////////////////////
41: // creation
42:
43: template<typename T1, typename T2, typename T3, typename T4>
44: foursome<T1,T2,T3,T4> make_foursome(const T1& first, const T2& second, const T3& third, const T4& fourth);
45:
46: ////////////////////////////////////////////////////////////////////////////////
47: // comparison
48:
49: template<typename T1, typename T2, typename T3, typename T4>
50: bool operator == (const foursome<T1,T2,T3,T4>& left, const foursome<T1,T2,T3,T4>& right);
51:
52: template<typename T1, typename T2, typename T3, typename T4>
53: bool operator < (const foursome<T1,T2,T3,T4>& left, const foursome<T1,T2,T3,T4>& right);
54:
55: ////////////////////////////////////////////////////////////////////////////////
56: // string utilities
57:
58: template<typename T1, typename T2, typename T3, typename T4>
59: std::string foursome_to_string(const foursome<T1,T2,T3,T4>& values, const std::string& separator);
60:
61: template<typename T1, typename T2, typename T3, typename T4>
62: otext& print_foursome(otext& str, const foursome<T1,T2,T3,T4>& values, const std::string& separator);
63:
64: template<typename T1, typename T2, typename T3, typename T4>
65: otext& print_foursome(otext& str, const foursome<T1,T2,T3,T4>& values, const std::string& separator, unsigned indent);
66:
67: ////////////////////////////////////////////////////////////////////////////////
68: // data persistence
69:
70: template<typename T1, typename T2, typename T3, typename T4>
71: void dump_foursome(dump_context& str, const foursome<T1,T2,T3,T4>& data) throw(persistent_dump_failed);
72:
73: template<typename T1, typename T2, typename T3, typename T4>
74: void restore_foursome(restore_context& str, foursome<T1,T2,T3,T4>& data) throw(persistent_restore_failed);
75:
76: ////////////////////////////////////////////////////////////////////////////////
77: #include "foursome.tpp"
78: #endif