/* ----------------------------------------------------------------------------- * See the LICENSE file for information on copyright, usage and redistribution * of SWIG, and the README file for authors - http://www.swig.org/release.html. * * std_vector.i * ----------------------------------------------------------------------------- */ %include %{ #include #include %} // C module specific: $tt expands to the type the template is instantiated %typemap(ctype) std::vector "$tt" %typemap(in) std::vector "$1 = ($1_ltype) $input;" %typemap(out) std::vector "$result = ($1_ltype) $1;" %typemap(cppouttype) std::vector "$1_ltype" namespace std { template class vector { public: typedef size_t size_type; typedef T value_type; typedef const value_type& const_reference; vector(); vector(size_type n); size_type size() const; size_type capacity() const; void reserve(size_type n); bool empty() const; void clear(); void push_back(const value_type& x); const_reference at(size_type i); }; %define specialize_std_vector(T) template<> class vector { public: typedef size_t size_type; typedef T value_type; vector(); vector(size_type n); size_type size() const; size_type capacity() const; void reserve(size_type n); bool empty() const; void clear(); void push_back(T x) { this->push_back(x); } T at(size_type i) { return this->at(i); } }; %enddef specialize_std_vector(int); specialize_std_vector(bool); /*specialize_std_vector(long); specialize_std_vector(char); specialize_std_vector(double); specialize_std_vector(int*); specialize_std_vector(char*);*/ }