paludis Version 3.0.2
The one true package mangler
map.hh
Go to the documentation of this file.
1/* vim: set sw=4 sts=4 et foldmethod=syntax : */
2
3/*
4 * Copyright (c) 2007, 2009, 2010, 2011 Ciaran McCreesh
5 *
6 * This file is part of the Paludis package manager. Paludis is free software;
7 * you can redistribute it and/or modify it under the terms of the GNU General
8 * Public License version 2, as published by the Free Software Foundation.
9 *
10 * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
11 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17 * Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#ifndef PALUDIS_GUARD_PALUDIS_UTIL_MAP_HH
21#define PALUDIS_GUARD_PALUDIS_UTIL_MAP_HH 1
22
25#include <paludis/util/pimp.hh>
26#include <paludis/util/wrapped_output_iterator-fwd.hh>
27#include <paludis/util/wrapped_forward_iterator.hh>
28#include <string>
29#include <utility>
30
31/** \file
32 * Declarations for the Map<> class.
33 *
34 * \ingroup g_data_structures
35 *
36 * \section Examples
37 *
38 * - None at this time.
39 */
40
41namespace paludis
42{
43 /**
44 * A wrapper around a map, avoiding the need to include lots of STL bloat
45 * everywhere.
46 *
47 * \ingroup g_data_structures
48 * \since 0.26
49 * \nosubgrouping
50 */
51 template <typename K_, typename V_, typename C_>
53 {
54 private:
56
57 public:
58 ///\name Basic operations
59 ///\{
60
61 Map();
62 ~Map();
63
64 Map(const Map &) = delete;
65 Map & operator= (const Map &) = delete;
66
67 ///\}
68
69 ///\name Standard library typedefs
70 ///\{
71
72 typedef std::pair<const K_, V_> value_type;
73 typedef std::pair<const K_, V_> & reference;
74 typedef const reference const_reference;
75
76 ///\}
77
78 ///\name Iteration
79 ///\{
80
81 typedef MapConstIteratorTag<K_, V_, C_> ConstIteratorTag;
83 ConstIterator begin() const PALUDIS_ATTRIBUTE((warn_unused_result));
84 ConstIterator end() const PALUDIS_ATTRIBUTE((warn_unused_result));
85 ConstIterator find(const K_ &) const PALUDIS_ATTRIBUTE((warn_unused_result));
86
87 typedef MapInserterTag<K_, V_, C_> InserterTag;
89 Inserter inserter() PALUDIS_ATTRIBUTE((warn_unused_result));
90
91 ///\}
92
93 ///\name Content information
94 ///\{
95
96 bool empty() const PALUDIS_ATTRIBUTE((warn_unused_result));
97 unsigned size() const PALUDIS_ATTRIBUTE((warn_unused_result));
98
99 ///\}
100
101 ///\name Content modification
102 ///\{
103
104 void insert(const K_ &, const V_ &);
105 void erase(const ConstIterator &);
106 void erase(const K_ &);
107
108 ///\}
109 };
110
112 extern template class PALUDIS_VISIBLE WrappedForwardIterator<Map<std::string, std::string>::ConstIteratorTag, const std::pair<const std::string, std::string> >;
113}
114
115#endif
Definition map.hh:53
Definition pimp.hh:52
Definition wrapped_forward_iterator.hh:42
Definition wrapped_output_iterator.hh:38
#define PALUDIS_ATTRIBUTE(x)
Definition attributes.hh:53
#define PALUDIS_VISIBLE
Definition attributes.hh:59
Definition about_metadata-fwd.hh:24
Definition map-fwd.hh:38
Definition map-fwd.hh:41