1899
|
1 /**
|
|
2 * @file std_queue.i
|
|
3 * @date Sun May 6 01:48:07 2007
|
|
4 *
|
|
5 * @brief A wrapping of std::queue for Ruby.
|
|
6 *
|
|
7 *
|
|
8 */
|
|
9
|
|
10 %include <std_container.i>
|
|
11
|
|
12 // Queue
|
|
13
|
|
14 %define %std_queue_methods(queue...)
|
|
15 queue();
|
|
16 queue( const _Sequence& );
|
|
17
|
|
18 bool empty() const;
|
|
19 size_type size() const;
|
|
20 const value_type& front() const;
|
|
21 const value_type& back() const;
|
|
22 void pop();
|
|
23 void push( const value_type& );
|
|
24 %enddef
|
|
25
|
|
26 %define %std_queue_methods_val(queue...)
|
|
27 %std_queue_methods(queue)
|
|
28 %enddef
|
|
29
|
|
30 // ------------------------------------------------------------------------
|
|
31 // std::queue
|
|
32 //
|
|
33 // const declarations are used to guess the intent of the function being
|
|
34 // exported; therefore, the following rationale is applied:
|
|
35 //
|
|
36 // -- f(std::queue<T>), f(const std::queue<T>&):
|
|
37 // the parameter being read-only, either a sequence or a
|
|
38 // previously wrapped std::queue<T> can be passed.
|
|
39 // -- f(std::queue<T>&), f(std::queue<T>*):
|
|
40 // the parameter may be modified; therefore, only a wrapped std::queue
|
|
41 // can be passed.
|
|
42 // -- std::queue<T> f(), const std::queue<T>& f():
|
|
43 // the queue is returned by copy; therefore, a sequence of T:s
|
|
44 // is returned which is most easily used in other functions
|
|
45 // -- std::queue<T>& f(), std::queue<T>* f():
|
|
46 // the queue is returned by reference; therefore, a wrapped std::queue
|
|
47 // is returned
|
|
48 // -- const std::queue<T>* f(), f(const std::queue<T>*):
|
|
49 // for consistency, they expect and return a plain queue pointer.
|
|
50 // ------------------------------------------------------------------------
|
|
51
|
|
52 %{
|
|
53 #include <queue>
|
|
54 %}
|
|
55
|
|
56 // exported classes
|
|
57
|
|
58 namespace std {
|
|
59
|
|
60 template<class _Tp, class _Sequence = std::deque<_Tp> >
|
|
61 class queue {
|
|
62 public:
|
|
63 typedef size_t size_type;
|
|
64 typedef _Tp value_type;
|
|
65 typedef value_type& reference;
|
|
66 typedef const value_type& const_reference;
|
|
67 typedef _Sequence container_type;
|
|
68
|
|
69 %traits_swigtype(_Tp);
|
|
70
|
|
71 %fragment(SWIG_Traits_frag(std::queue<_Tp, _Sequence >), "header",
|
|
72 fragment=SWIG_Traits_frag(_Tp),
|
|
73 fragment="StdQueueTraits") {
|
|
74 namespace swig {
|
|
75 template <> struct traits<std::queue<_Tp, _Sequence > > {
|
|
76 typedef pointer_category category;
|
|
77 static const char* type_name() {
|
|
78 return "std::queue<" #_Tp "," #_Sequence " >";
|
|
79 }
|
|
80 };
|
|
81 }
|
|
82 }
|
|
83
|
|
84 %typemap_traits_ptr(SWIG_TYPECHECK_QUEUE, std::queue<_Tp, _Sequence >);
|
|
85
|
|
86 #ifdef %swig_queue_methods
|
|
87 // Add swig/language extra methods
|
|
88 %swig_queue_methods(std::queue<_Tp, _Sequence >);
|
|
89 #endif
|
|
90
|
|
91 %std_queue_methods(queue);
|
|
92 };
|
|
93
|
|
94 template<class _Tp, class _Sequence >
|
|
95 class queue<_Tp*, _Sequence > {
|
|
96 public:
|
|
97 typedef size_t size_type;
|
|
98 typedef _Tp value_type;
|
|
99 typedef value_type& reference;
|
|
100 typedef const value_type& const_reference;
|
|
101 typedef _Sequence container_type;
|
|
102
|
|
103 %traits_swigtype(_Tp);
|
|
104
|
|
105 %fragment(SWIG_Traits_frag(std::queue<_Tp*, _Sequence >), "header",
|
|
106 fragment=SWIG_Traits_frag(_Tp),
|
|
107 fragment="StdQueueTraits") {
|
|
108 namespace swig {
|
|
109 template <> struct traits<std::queue<_Tp*, _Sequence > > {
|
|
110 typedef value_category category;
|
|
111 static const char* type_name() {
|
|
112 return "std::queue<" #_Tp "," #_Sequence " * >";
|
|
113 }
|
|
114 };
|
|
115 }
|
|
116 }
|
|
117
|
|
118 %typemap_traits_ptr(SWIG_TYPECHECK_QUEUE, std::queue<_Tp*, _Sequence >);
|
|
119
|
|
120 #ifdef %swig_queue_methods_val
|
|
121 // Add swig/language extra methods
|
|
122 %swig_queue_methods_val(std::queue<_Tp*, _Sequence >);
|
|
123 #endif
|
|
124
|
|
125 %std_queue_methods_val(std::queue<_Tp*, _Sequence >);
|
|
126 };
|
|
127
|
|
128 }
|
|
129
|