Crazy Eddie's GUI System  ${CEGUI_VERSION}
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
set.hpp
1 // This file has been generated by Py++.
2 
3 // Copyright (c) 2003 Raoul M. Gough
4 //
5 // Use, modification and distribution is subject to the Boost Software
6 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy
7 // at http://www.boost.org/LICENSE_1_0.txt)
8 //
9 // Header file set.hpp
10 //
11 // Indexing algorithms support for std::set instances
12 //
13 // History
14 // =======
15 // 2003/10/28 rmg File creation from algo_selector.hpp
16 // 2008/12/08 Roman Change indexing suite layout
17 // 2010/04/29 Roman Adding "__len__" method
18 //
19 // $Id: set.hpp,v 1.1.2.6 2004/02/08 18:57:42 raoulgough Exp $
20 //
21 
22 #ifndef BOOST_PYTHON_INDEXING_SET_HPP
23 #define BOOST_PYTHON_INDEXING_SET_HPP
24 
25 #include <indexing_suite/container_traits.hpp>
26 #include <indexing_suite/container_suite.hpp>
27 #include <indexing_suite/algorithms.hpp>
28 #include <boost/type_traits/is_const.hpp>
29 #include <set>
30 
31 namespace boost { namespace python { namespace indexing {
33  // ContainerTraits implementation for std::set instances
35 
36  template<typename Container>
37  class set_traits : public base_container_traits<Container>
38  {
40 
41  public:
42  typedef typename Container::key_type value_type; // probably unused
43  typedef typename Container::key_type index_type; // operator[]
44  typedef typename Container::key_type key_type; // find, count, ...
45 
46  typedef typename BOOST_PYTHON_INDEXING_CALL_TRAITS <value_type>::param_type
47  value_param;
48  typedef typename BOOST_PYTHON_INDEXING_CALL_TRAITS <key_type>::param_type
49  key_param;
50  typedef typename BOOST_PYTHON_INDEXING_CALL_TRAITS <index_type>::param_type
51  index_param;
52 
53  BOOST_STATIC_CONSTANT(
54  method_set_type,
55  supported_methods = (
56  method_iter
57  | method_getitem
58  | method_contains
59  | method_count
60  | method_has_key
61  | method_len
62 
64  base_class::is_mutable,
65  method_delitem
66  | method_insert
67  >::value
68  ));
69  };
70 
72  // Algorithms implementation for std::set instances
74 
75  template<typename ContainerTraits, typename Ovr = detail::no_override>
77  : public assoc_algorithms
78  <ContainerTraits,
79  typename detail::maybe_override
80  <set_algorithms<ContainerTraits, Ovr>, Ovr>
81  ::type>
82  {
84  typedef typename detail::maybe_override<self_type, Ovr>::type most_derived;
86 
87  public:
88  typedef typename Parent::container container;
89  typedef typename Parent::value_param value_param;
90  typedef typename Parent::index_param index_param;
91 
92  static void insert (container &, index_param);
93 
94  template<typename PythonClass, typename Policy>
95  static void visit_container_class( PythonClass &pyClass, Policy const &policy)
96  {
97  ContainerTraits::visit_container_class (pyClass, policy);
98  pyClass.def( "add", &self_type::insert );
99  }
100 
101  };
102 
103 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
104  namespace detail {
106  // algorithms support for std::set instances
108 
109  template <class Key, class Compare, class Allocator>
110  class algorithms_selector<std::set<Key, Compare, Allocator> >
111  {
112  typedef std::set<Key, Compare, Allocator> Container;
113 
116 
117  public:
120  };
121 
123  // algorithms support for std::multiset instances
125 
126  template <class Key, class Compare, class Allocator>
127  class algorithms_selector<std::multiset<Key, Compare, Allocator> >
128  {
129  typedef std::multiset<Key, Compare, Allocator> Container;
130 
133 
134  public:
137  };
138  }
139 #endif
140 
141  template<
142  class Container,
143  method_set_type MethodMask = all_methods,
144  class Traits = set_traits<Container>
145  >
146  struct set_suite
147  : container_suite<Container, MethodMask, set_algorithms<Traits> >
148  {
149  };
150 
152  // Insert an element into a set
154 
155  template<typename ContainerTraits, typename Ovr>
156  void
158  container &c, index_param ix)
159  {
160  c.insert (ix);
161  //~ Python set does not raise exception in this situation
162  //~ if (!c.insert (ix).second)
163  //~ {
164  //~ PyErr_SetString(
165  //~ PyExc_ValueError, "Set already holds value for insertion");
166 
167  //~ boost::python::throw_error_already_set ();
168  //~ }
169  }
170 } } }
171 
172 #endif // BOOST_PYTHON_INDEXING_SET_HPP
173 
174 
175 
Definition: algorithms.hpp:128
Definition: python_CEGUI.h:11
Definition: container_traits.hpp:59
Definition: proxy_iterator.hpp:155
Definition: container_suite.hpp:42
Definition: set.hpp:146