Library of Assembled Shared Sources
extended_io.h
Go to the documentation of this file.
1/** @file
2 * @author Bram de Greve (bram@cocamware.com)
3 * @author Tom De Muer (tom@cocamware.com)
4 *
5 * *** BEGIN LICENSE INFORMATION ***
6 *
7 * The contents of this file are subject to the Common Public Attribution License
8 * Version 1.0 (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
10 * http://lass.sourceforge.net/cpal-license. The License is based on the
11 * Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover
12 * use of software over a computer network and provide for limited attribution for
13 * the Original Developer. In addition, Exhibit A has been modified to be consistent
14 * with Exhibit B.
15 *
16 * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
17 * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
18 * language governing rights and limitations under the License.
19 *
20 * The Original Code is LASS - Library of Assembled Shared Sources.
21 *
22 * The Initial Developer of the Original Code is Bram de Greve and Tom De Muer.
23 * The Original Developer is the Initial Developer.
24 *
25 * All portions of the code written by the Initial Developer are:
26 * Copyright (C) 2004-2011 the Initial Developer.
27 * All Rights Reserved.
28 *
29 * Contributor(s):
30 *
31 * Alternatively, the contents of this file may be used under the terms of the
32 * GNU General Public License Version 2 or later (the GPL), in which case the
33 * provisions of GPL are applicable instead of those above. If you wish to allow use
34 * of your version of this file only under the terms of the GPL and not to allow
35 * others to use your version of this file under the CPAL, indicate your decision by
36 * deleting the provisions above and replace them with the notice and other
37 * provisions required by the GPL License. If you do not delete the provisions above,
38 * a recipient may use your version of this file under either the CPAL or the GPL.
39 *
40 * *** END LICENSE INFORMATION ***
41 */
42
43
44
45/** @defgroup extended_io
46 * @brief extra insertors and extractors.
47 * @author Bram de Greve [BdG]
48 *
49 * ExtendedIo groups additional stream operators for @c std::pair and standard containers like
50 * @c std::vector, @c std::list, ... By including this header, it will possible to output
51 * these types to a stream, just like a regular float.
52 *
53 * Currently, the containers only have output operators, only std::pair has both the output
54 * and input operator. This will probably change in the future when there's a need for it.
55 *
56 * The supported standard containers are @c std::vector, @c std::list, @c std::deque,
57 * @c std::map, @c std::multimap, @c std::set, @c std::multiset.
58 *
59 * STLport specific: in case @c std::slist is detected as included, it is supported as well.
60 *
61 * @code
62 * std::pair<int, std::string> a(5, "hello");
63 * std::cout << a; // (5, hello)
64 * std::cin >> a;
65 *
66 * std::vector<int> b;
67 * b.push_back(1);
68 * b.push_back(2);
69 * b.push_back(3);
70 * std::cout << b; // [1, 2, 3]
71 *
72 * std::map<std::string, int> c;
73 * c["foo"] = 1;
74 * c["bar"] = 2;
75 * c["spam"] = 3;
76 * c << map; // {bar: 2, foo: 1, spam: 3}
77 *
78 * std::set<std::string> d;
79 * d.insert("foo");
80 * d.insert("bar");
81 * d.insert("spam");
82 * stream << d; // {bar, foo, spam}
83 * @endcode
84 *
85 * @note we need to inject all this stuff in the std namespace for the look up thingies to work.
86 */
87
88#ifndef LASS_GUARDIAN_OF_INCLUSION_STDE_EXTENDED_IO_H
89#define LASS_GUARDIAN_OF_INCLUSION_STDE_EXTENDED_IO_H
90
91#include "stde_common.h"
92
93namespace std
94{
95
96// output
97
98template <typename T1, typename T2, typename Char, typename Traits>
99std::basic_ostream<Char, Traits>&
100operator<<(std::basic_ostream<Char, Traits>& stream, const std::pair<T1, T2>& x);
101
102template <typename T, typename Alloc, typename Char, typename Traits>
103std::basic_ostream<Char, Traits>&
104operator<<(std::basic_ostream<Char, Traits>& stream, const std::vector<T, Alloc>& x);
105
106template <typename T, typename Alloc, typename Char, typename Traits>
107std::basic_ostream<Char, Traits>&
108operator<<(std::basic_ostream<Char, Traits>& stream, const std::list<T, Alloc>& x);
109
110template <typename T, typename Alloc, typename Char, typename Traits>
111std::basic_ostream<Char, Traits>&
112operator<<(std::basic_ostream<Char, Traits>& stream, const std::deque<T, Alloc>& x);
113
114template <typename Key, typename Data, typename Comp, typename Alloc, typename Char, typename Traits>
115std::basic_ostream<Char, Traits>&
116operator<<(std::basic_ostream<Char, Traits>& stream, const std::map<Key, Data, Comp, Alloc>& x);
117
118template <typename Key, typename Data, typename Comp, typename Alloc, typename Char, typename Traits>
119std::basic_ostream<Char, Traits>&
120operator<<(std::basic_ostream<Char, Traits>& stream, const std::multimap<Key, Data, Comp, Alloc>& x);
121
122template <typename Key, typename Comp, typename Alloc, typename Char, typename Traits>
123std::basic_ostream<Char, Traits>&
124operator<<(std::basic_ostream<Char, Traits>& stream, const std::set<Key, Comp, Alloc>& x);
125
126template <typename Key, typename Comp, typename Alloc, typename Char, typename Traits>
127std::basic_ostream<Char, Traits>&
128operator<<(std::basic_ostream<Char, Traits>& stream, const std::multiset<Key, Comp, Alloc>& x);
129
130
131
132// input
133/*
134template <typename T1, typename T2, typename Char, typename Traits>
135std::basic_istream<Char, Traits>&
136operator>>(std::basic_istream<Char, Traits>& stream, std::pair<T1, T2>& x);
137
138template <typename T, typename Alloc, typename Char, typename Traits>
139std::basic_istream<Char, Traits>&
140operator>>(std::basic_istream<Char, Traits>& stream, std::vector<T, Alloc>& x);
141
142template <typename T, typename Alloc, typename Char, typename Traits>
143std::basic_istream<Char, Traits>&
144operator>>(std::basic_istream<Char, Traits>& stream, std::list<T, Alloc>& x);
145
146template <typename T, typename Alloc, typename Char, typename Traits>
147std::basic_istream<Char, Traits>&
148operator>>(std::basic_istream<Char, Traits>& stream, std::deque<T, Alloc>& x);
149*/
150}
151
152#include "extended_io.inl"
153
154#endif
155
156// EOF