mirror of
https://github.com/nillerusr/source-engine.git
synced 2026-08-31 06:29:20 +00:00
1
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* C++ STD + STL
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
std_common.i general common code
|
||||
std_container.i general container code
|
||||
std_basic_string.i basic string
|
||||
std_char_traits.i char traits
|
||||
std_complex.i complex
|
||||
std_deque.i deque
|
||||
std_except.i exceptions
|
||||
std_ios.i ios
|
||||
std_iostream.i istream/ostream
|
||||
std_list.i list
|
||||
std_map.i map
|
||||
std_multimap.i multimap
|
||||
std_multiset.i multiset
|
||||
std_pair.i pair
|
||||
std_set.i set
|
||||
std_streambuf.i streambuf
|
||||
std_vector.i vector
|
||||
std_vectora.i vector + allocator
|
||||
@@ -0,0 +1,126 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* 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_deque.i
|
||||
*
|
||||
* This file contains a generic definition of std::deque along with
|
||||
* some helper functions. Specific language modules should include
|
||||
* this file to generate wrappers.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <std_except.i>
|
||||
|
||||
%{
|
||||
#include <deque>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
|
||||
/* This macro defines all of the standard methods for a deque. This
|
||||
is defined as a macro to simplify the task of specialization. For
|
||||
example,
|
||||
|
||||
template<> class deque<int> {
|
||||
public:
|
||||
%std_deque_methods(int);
|
||||
};
|
||||
*/
|
||||
|
||||
%define %std_deque_methods(T)
|
||||
typedef T &reference;
|
||||
typedef const T& const_reference;
|
||||
|
||||
deque();
|
||||
deque(unsigned int size, const T& value=T());
|
||||
deque(const deque<T> &);
|
||||
~deque();
|
||||
|
||||
void assign(unsigned int n, const T& value);
|
||||
void swap(deque<T> &x);
|
||||
unsigned int size() const;
|
||||
unsigned int max_size() const;
|
||||
void resize(unsigned int n, T c = T());
|
||||
bool empty() const;
|
||||
const_reference front();
|
||||
const_reference back();
|
||||
void push_front(const T& x);
|
||||
void push_back(const T& x);
|
||||
void pop_front();
|
||||
void pop_back();
|
||||
void clear();
|
||||
|
||||
/* Some useful extensions */
|
||||
%extend {
|
||||
const_reference getitem(int i) throw (std::out_of_range) {
|
||||
int size = int(self->size());
|
||||
if (i<0) i += size;
|
||||
if (i>=0 && i<size)
|
||||
return (*self)[i];
|
||||
else
|
||||
throw std::out_of_range("deque index out of range");
|
||||
}
|
||||
void setitem(int i, const T& x) throw (std::out_of_range) {
|
||||
int size = int(self->size());
|
||||
if (i<0) i+= size;
|
||||
if (i>=0 && i<size)
|
||||
(*self)[i] = x;
|
||||
else
|
||||
throw std::out_of_range("deque index out of range");
|
||||
}
|
||||
void delitem(int i) throw (std::out_of_range) {
|
||||
int size = int(self->size());
|
||||
if (i<0) i+= size;
|
||||
if (i>=0 && i<size) {
|
||||
self->erase(self->begin()+i);
|
||||
} else {
|
||||
throw std::out_of_range("deque index out of range");
|
||||
}
|
||||
}
|
||||
std::deque<T> getslice(int i, int j) {
|
||||
int size = int(self->size());
|
||||
if (i<0) i = size+i;
|
||||
if (j<0) j = size+j;
|
||||
if (i<0) i = 0;
|
||||
if (j>size) j = size;
|
||||
std::deque<T > tmp(j-i);
|
||||
std::copy(self->begin()+i,self->begin()+j,tmp.begin());
|
||||
return tmp;
|
||||
}
|
||||
void setslice(int i, int j, const std::deque<T>& v) {
|
||||
int size = int(self->size());
|
||||
if (i<0) i = size+i;
|
||||
if (j<0) j = size+j;
|
||||
if (i<0) i = 0;
|
||||
if (j>size) j = size;
|
||||
if (int(v.size()) == j-i) {
|
||||
std::copy(v.begin(),v.end(),self->begin()+i);
|
||||
} else {
|
||||
self->erase(self->begin()+i,self->begin()+j);
|
||||
if (i+1 <= size)
|
||||
self->insert(self->begin()+i+1,v.begin(),v.end());
|
||||
else
|
||||
self->insert(self->end(),v.begin(),v.end());
|
||||
}
|
||||
}
|
||||
void delslice(int i, int j) {
|
||||
int size = int(self->size());
|
||||
if (i<0) i = size+i;
|
||||
if (j<0) j = size+j;
|
||||
if (i<0) i = 0;
|
||||
if (j>size) j = size;
|
||||
self->erase(self->begin()+i,self->begin()+j);
|
||||
}
|
||||
};
|
||||
|
||||
%enddef
|
||||
|
||||
namespace std {
|
||||
template<class T> class deque {
|
||||
public:
|
||||
%std_deque_methods(T);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
namespace std
|
||||
{
|
||||
/**
|
||||
* @brief The "standard" allocator, as per [20.4].
|
||||
*
|
||||
* The private _Alloc is "SGI" style. (See comments at the top
|
||||
* of stl_alloc.h.)
|
||||
*
|
||||
* The underlying allocator behaves as follows.
|
||||
* - __default_alloc_template is used via two typedefs
|
||||
* - "__single_client_alloc" typedef does no locking for threads
|
||||
* - "__alloc" typedef is threadsafe via the locks
|
||||
* - __new_alloc is used for memory requests
|
||||
*
|
||||
* (See @link Allocators allocators info @endlink for more.)
|
||||
*/
|
||||
template<typename _Tp>
|
||||
class allocator
|
||||
{
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef _Tp* pointer;
|
||||
typedef const _Tp* const_pointer;
|
||||
typedef _Tp& reference;
|
||||
typedef const _Tp& const_reference;
|
||||
typedef _Tp value_type;
|
||||
|
||||
template<typename _Tp1>
|
||||
struct rebind;
|
||||
|
||||
allocator() throw();
|
||||
|
||||
allocator(const allocator&) throw();
|
||||
template<typename _Tp1>
|
||||
allocator(const allocator<_Tp1>&) throw();
|
||||
~allocator() throw();
|
||||
|
||||
|
||||
pointer
|
||||
address(reference __x) const;
|
||||
|
||||
|
||||
const_pointer
|
||||
address(const_reference __x) const;
|
||||
|
||||
|
||||
// NB: __n is permitted to be 0. The C++ standard says nothing
|
||||
// about what the return value is when __n == 0.
|
||||
_Tp*
|
||||
allocate(size_type __n, const void* = 0);
|
||||
|
||||
// __p is not permitted to be a null pointer.
|
||||
void
|
||||
deallocate(pointer __p, size_type __n);
|
||||
|
||||
size_type
|
||||
max_size() const throw();
|
||||
|
||||
void construct(pointer __p, const _Tp& __val);
|
||||
void destroy(pointer __p);
|
||||
};
|
||||
|
||||
template<>
|
||||
class allocator<void>
|
||||
{
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef void* pointer;
|
||||
typedef const void* const_pointer;
|
||||
typedef void value_type;
|
||||
|
||||
template<typename _Tp1>
|
||||
struct rebind;
|
||||
};
|
||||
} // namespace std
|
||||
@@ -0,0 +1,270 @@
|
||||
%include <exception.i>
|
||||
%include <std_container.i>
|
||||
%include <std_alloc.i>
|
||||
%include <std_char_traits.i>
|
||||
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
%}
|
||||
|
||||
namespace std
|
||||
{
|
||||
%naturalvar basic_string;
|
||||
}
|
||||
|
||||
|
||||
namespace std {
|
||||
|
||||
template <class _CharT, class _Traits = char_traits<_CharT>, typename _Alloc = allocator<_CharT> >
|
||||
class basic_string
|
||||
{
|
||||
#if !defined(SWIG_STD_MODERN_STL) || defined(SWIG_STD_NOMODERN_STL)
|
||||
%ignore push_back;
|
||||
%ignore clear;
|
||||
%ignore compare;
|
||||
%ignore append;
|
||||
#endif
|
||||
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef _CharT value_type;
|
||||
typedef value_type reference;
|
||||
typedef value_type const_reference;
|
||||
typedef _Alloc allocator_type;
|
||||
|
||||
static const size_type npos;
|
||||
|
||||
#ifdef SWIG_EXPORT_ITERATOR_METHODS
|
||||
class iterator;
|
||||
class reverse_iterator;
|
||||
class const_iterator;
|
||||
class const_reverse_iterator;
|
||||
#endif
|
||||
|
||||
|
||||
%traits_swigtype(_CharT);
|
||||
%fragment(SWIG_Traits_frag(_CharT));
|
||||
|
||||
|
||||
basic_string(const _CharT* __s, size_type __n);
|
||||
|
||||
// Capacity:
|
||||
|
||||
size_type length() const;
|
||||
|
||||
size_type max_size() const;
|
||||
|
||||
size_type capacity() const;
|
||||
|
||||
void reserve(size_type __res_arg = 0);
|
||||
|
||||
|
||||
// Modifiers:
|
||||
|
||||
basic_string&
|
||||
append(const basic_string& __str);
|
||||
|
||||
basic_string&
|
||||
append(const basic_string& __str, size_type __pos, size_type __n);
|
||||
|
||||
basic_string&
|
||||
append(const _CharT* __s, size_type __n);
|
||||
|
||||
basic_string&
|
||||
append(size_type __n, _CharT __c);
|
||||
|
||||
basic_string&
|
||||
assign(const basic_string& __str);
|
||||
|
||||
basic_string&
|
||||
assign(const basic_string& __str, size_type __pos, size_type __n);
|
||||
|
||||
basic_string&
|
||||
assign(const _CharT* __s, size_type __n);
|
||||
|
||||
basic_string&
|
||||
insert(size_type __pos1, const basic_string& __str);
|
||||
|
||||
basic_string&
|
||||
insert(size_type __pos1, const basic_string& __str,
|
||||
size_type __pos2, size_type __n);
|
||||
|
||||
basic_string&
|
||||
insert(size_type __pos, const _CharT* __s, size_type __n);
|
||||
|
||||
basic_string&
|
||||
insert(size_type __pos, size_type __n, _CharT __c);
|
||||
|
||||
basic_string&
|
||||
erase(size_type __pos = 0, size_type __n = npos);
|
||||
|
||||
basic_string&
|
||||
replace(size_type __pos, size_type __n, const basic_string& __str);
|
||||
|
||||
basic_string&
|
||||
replace(size_type __pos1, size_type __n1, const basic_string& __str,
|
||||
size_type __pos2, size_type __n2);
|
||||
|
||||
basic_string&
|
||||
replace(size_type __pos, size_type __n1, const _CharT* __s,
|
||||
size_type __n2);
|
||||
|
||||
basic_string&
|
||||
replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c);
|
||||
|
||||
|
||||
size_type
|
||||
copy(_CharT* __s, size_type __n, size_type __pos = 0) const;
|
||||
|
||||
// String operations:
|
||||
const _CharT* c_str() const;
|
||||
|
||||
size_type
|
||||
find(const _CharT* __s, size_type __pos, size_type __n) const;
|
||||
|
||||
size_type
|
||||
find(const basic_string& __str, size_type __pos = 0) const;
|
||||
|
||||
size_type
|
||||
find(_CharT __c, size_type __pos = 0) const;
|
||||
|
||||
size_type
|
||||
rfind(const basic_string& __str, size_type __pos = npos) const;
|
||||
|
||||
size_type
|
||||
rfind(const _CharT* __s, size_type __pos, size_type __n) const;
|
||||
|
||||
size_type
|
||||
rfind(_CharT __c, size_type __pos = npos) const;
|
||||
|
||||
size_type
|
||||
find_first_of(const basic_string& __str, size_type __pos = 0) const;
|
||||
|
||||
size_type
|
||||
find_first_of(const _CharT* __s, size_type __pos, size_type __n) const;
|
||||
|
||||
size_type
|
||||
find_first_of(_CharT __c, size_type __pos = 0) const;
|
||||
|
||||
size_type
|
||||
find_last_of(const basic_string& __str, size_type __pos = npos) const;
|
||||
|
||||
size_type
|
||||
find_last_of(const _CharT* __s, size_type __pos, size_type __n) const;
|
||||
|
||||
size_type
|
||||
find_last_of(_CharT __c, size_type __pos = npos) const;
|
||||
|
||||
size_type
|
||||
find_first_not_of(const basic_string& __str, size_type __pos = 0) const;
|
||||
|
||||
size_type
|
||||
find_first_not_of(const _CharT* __s, size_type __pos,
|
||||
size_type __n) const;
|
||||
|
||||
size_type
|
||||
find_first_not_of(_CharT __c, size_type __pos = 0) const;
|
||||
|
||||
size_type
|
||||
find_last_not_of(const basic_string& __str, size_type __pos = npos) const;
|
||||
|
||||
size_type
|
||||
find_last_not_of(const _CharT* __s, size_type __pos,
|
||||
size_type __n) const;
|
||||
|
||||
size_type
|
||||
find_last_not_of(_CharT __c, size_type __pos = npos) const;
|
||||
|
||||
basic_string
|
||||
substr(size_type __pos = 0, size_type __n = npos) const;
|
||||
|
||||
int
|
||||
compare(const basic_string& __str) const;
|
||||
|
||||
int
|
||||
compare(size_type __pos, size_type __n, const basic_string& __str) const;
|
||||
|
||||
int
|
||||
compare(size_type __pos1, size_type __n1, const basic_string& __str,
|
||||
size_type __pos2, size_type __n2) const;
|
||||
|
||||
|
||||
%ignore pop_back();
|
||||
%ignore front() const;
|
||||
%ignore back() const;
|
||||
%ignore basic_string(size_type n);
|
||||
%std_sequence_methods_val(basic_string);
|
||||
|
||||
|
||||
%ignore pop();
|
||||
|
||||
|
||||
#ifdef %swig_basic_string
|
||||
// Add swig/language extra methods
|
||||
%swig_basic_string(std::basic_string<_CharT, _Traits, _Alloc >);
|
||||
#endif
|
||||
|
||||
#ifdef SWIG_EXPORT_ITERATOR_METHODS
|
||||
|
||||
|
||||
class iterator;
|
||||
class reverse_iterator;
|
||||
class const_iterator;
|
||||
class const_reverse_iterator;
|
||||
|
||||
|
||||
void
|
||||
insert(iterator __p, size_type __n, _CharT __c);
|
||||
|
||||
basic_string&
|
||||
replace(iterator __i1, iterator __i2, const basic_string& __str);
|
||||
|
||||
basic_string&
|
||||
replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n);
|
||||
|
||||
basic_string&
|
||||
replace(iterator __i1, iterator __i2, size_type __n, _CharT __c);
|
||||
|
||||
|
||||
basic_string&
|
||||
replace(iterator __i1, iterator __i2, const _CharT* __k1, const _CharT* __k2);
|
||||
|
||||
basic_string&
|
||||
replace(iterator __i1, iterator __i2, const_iterator __k1, const_iterator __k2);
|
||||
#endif
|
||||
|
||||
basic_string& operator +=(const basic_string& v);
|
||||
|
||||
%newobject __add__;
|
||||
%newobject __radd__;
|
||||
%extend {
|
||||
|
||||
std::basic_string<_CharT,_Traits,_Alloc >* __add__(const basic_string& v) {
|
||||
std::basic_string<_CharT,_Traits,_Alloc >* res = new std::basic_string<_CharT,_Traits,_Alloc >(*self);
|
||||
*res += v;
|
||||
return res;
|
||||
}
|
||||
|
||||
std::basic_string<_CharT,_Traits,_Alloc >* __radd__(const basic_string& v) {
|
||||
std::basic_string<_CharT,_Traits,_Alloc >* res = new std::basic_string<_CharT,_Traits,_Alloc >(v);
|
||||
*res += *self;
|
||||
return res;
|
||||
}
|
||||
|
||||
std::basic_string<_CharT,_Traits,_Alloc > __str__() {
|
||||
return *self;
|
||||
}
|
||||
|
||||
std::basic_ostream<_CharT, std::char_traits<_CharT> >&
|
||||
__rlshift__(std::basic_ostream<_CharT, std::char_traits<_CharT> >& out) {
|
||||
out << *self;
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
%{
|
||||
#include <algorithm>
|
||||
%}
|
||||
|
||||
//
|
||||
// std::carray - is really an extension to the 'std' namespace.
|
||||
//
|
||||
// A simple fix C array wrapper, more or less as presented in
|
||||
//
|
||||
// "The C++ Standarf Library", by Nicolai M. Josuttis
|
||||
//
|
||||
// which is also derived from the example in
|
||||
//
|
||||
// "The C++ Programming Language", by Bjarne Stroustup.
|
||||
//
|
||||
|
||||
%inline %{
|
||||
namespace std {
|
||||
template <class _Type, size_t _Size>
|
||||
class carray
|
||||
{
|
||||
public:
|
||||
typedef _Type value_type;
|
||||
typedef size_t size_type;
|
||||
|
||||
typedef _Type * iterator;
|
||||
typedef const _Type * const_iterator;
|
||||
|
||||
carray() { }
|
||||
|
||||
carray(const carray& c) {
|
||||
std::copy(c.v, c.v + size(), v);
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
carray(_Iterator first, _Iterator last) {
|
||||
assign(first, last);
|
||||
}
|
||||
|
||||
iterator begin() { return v; }
|
||||
iterator end() { return v + _Size; }
|
||||
|
||||
const_iterator begin() const { return v; }
|
||||
const_iterator end() const { return v + _Size; }
|
||||
|
||||
_Type& operator[](size_t i) { return v[i]; }
|
||||
const _Type& operator[](size_t i) const { return v[i]; }
|
||||
|
||||
static size_t size() { return _Size; }
|
||||
|
||||
template <class _Iterator>
|
||||
void assign(_Iterator first, _Iterator last) {
|
||||
if (std::distance(first,last) == size()) {
|
||||
std::copy(first, last, v);
|
||||
} else {
|
||||
throw std::length_error("bad range length");
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
_Type v[_Size];
|
||||
};
|
||||
}
|
||||
%}
|
||||
@@ -0,0 +1,140 @@
|
||||
%include <std_common.i>
|
||||
#if defined(SWIG_WCHAR)
|
||||
%include <wchar.i>
|
||||
#endif
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
/// 21.1.2 Basis for explicit _Traits specialization
|
||||
/// NB: That for any given actual character type this definition is
|
||||
/// probably wrong.
|
||||
template<class _CharT>
|
||||
struct char_traits
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
/// 21.1.4 char_traits specializations
|
||||
template<>
|
||||
struct char_traits<char> {
|
||||
typedef char char_type;
|
||||
typedef int int_type;
|
||||
typedef streampos pos_type;
|
||||
typedef streamoff off_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
static void
|
||||
assign(char_type& __c1, const char_type& __c2);
|
||||
|
||||
static bool
|
||||
eq(const char_type& __c1, const char_type& __c2);
|
||||
|
||||
static bool
|
||||
lt(const char_type& __c1, const char_type& __c2);
|
||||
|
||||
static int
|
||||
compare(const char_type* __s1, const char_type* __s2, size_t __n);
|
||||
|
||||
static size_t
|
||||
length(const char_type* __s);
|
||||
|
||||
static const char_type*
|
||||
find(const char_type* __s, size_t __n, const char_type& __a);
|
||||
|
||||
static char_type*
|
||||
move(char_type* __s1, const char_type* __s2, size_t __n);
|
||||
|
||||
static char_type*
|
||||
copy(char_type* __s1, const char_type* __s2, size_t __n);
|
||||
|
||||
static char_type*
|
||||
assign(char_type* __s, size_t __n, char_type __a);
|
||||
|
||||
static char_type
|
||||
to_char_type(const int_type& __c);
|
||||
|
||||
// To keep both the byte 0xff and the eof symbol 0xffffffff
|
||||
// from ending up as 0xffffffff.
|
||||
static int_type
|
||||
to_int_type(const char_type& __c);
|
||||
|
||||
static bool
|
||||
eq_int_type(const int_type& __c1, const int_type& __c2);
|
||||
|
||||
static int_type
|
||||
eof() ;
|
||||
|
||||
static int_type
|
||||
not_eof(const int_type& __c);
|
||||
};
|
||||
|
||||
|
||||
#if defined(SWIG_WCHAR)
|
||||
template<>
|
||||
struct char_traits<wchar_t>
|
||||
{
|
||||
typedef wchar_t char_type;
|
||||
typedef wint_t int_type;
|
||||
typedef streamoff off_type;
|
||||
typedef wstreampos pos_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
static void
|
||||
assign(char_type& __c1, const char_type& __c2);
|
||||
|
||||
static bool
|
||||
eq(const char_type& __c1, const char_type& __c2);
|
||||
|
||||
static bool
|
||||
lt(const char_type& __c1, const char_type& __c2);
|
||||
|
||||
static int
|
||||
compare(const char_type* __s1, const char_type* __s2, size_t __n);
|
||||
|
||||
static size_t
|
||||
length(const char_type* __s);
|
||||
|
||||
static const char_type*
|
||||
find(const char_type* __s, size_t __n, const char_type& __a);
|
||||
|
||||
static char_type*
|
||||
move(char_type* __s1, const char_type* __s2, int_type __n);
|
||||
|
||||
static char_type*
|
||||
copy(char_type* __s1, const char_type* __s2, size_t __n);
|
||||
|
||||
static char_type*
|
||||
assign(char_type* __s, size_t __n, char_type __a);
|
||||
|
||||
static char_type
|
||||
to_char_type(const int_type& __c) ;
|
||||
|
||||
static int_type
|
||||
to_int_type(const char_type& __c) ;
|
||||
|
||||
static bool
|
||||
eq_int_type(const int_type& __c1, const int_type& __c2);
|
||||
|
||||
static int_type
|
||||
eof() ;
|
||||
|
||||
static int_type
|
||||
not_eof(const int_type& __c);
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace std {
|
||||
#ifndef SWIG_STL_WRAP_TRAITS
|
||||
%template() char_traits<char>;
|
||||
#if defined(SWIG_WCHAR)
|
||||
%template() char_traits<wchar_t>;
|
||||
#endif
|
||||
#else
|
||||
%template(char_traits_c) char_traits<char>;
|
||||
#if defined(SWIG_WCHAR)
|
||||
%template(char_traits_w) char_traits<wchar_t>;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,244 @@
|
||||
%include <std/std_except.i>
|
||||
|
||||
//
|
||||
// Use the following macro with modern STL implementations
|
||||
//
|
||||
//#define SWIG_STD_MODERN_STL
|
||||
//
|
||||
// Use this to deactive the previous definition, when using gcc-2.95
|
||||
// or similar old compilers.
|
||||
//
|
||||
//#define SWIG_STD_NOMODERN_STL
|
||||
|
||||
// Here, we identify compilers we now have problems with STL.
|
||||
%{
|
||||
|
||||
#if defined(__SUNPRO_CC) && defined(_RWSTD_VER)
|
||||
# define SWIG_STD_NOASSIGN_STL
|
||||
# define SWIG_STD_NOINSERT_TEMPLATE_STL
|
||||
# define SWIG_STD_NOITERATOR_TRAITS_STL
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
# if __GNUC__ == 2 && __GNUC_MINOR <= 96
|
||||
# define SWIG_STD_NOMODERN_STL
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
%}
|
||||
|
||||
//
|
||||
// Common code for supporting the STD C++ namespace
|
||||
//
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
|
||||
%fragment("StdIteratorTraits","header") %{
|
||||
#if !defined(SWIG_STD_NOITERATOR_TRAITS_STL)
|
||||
#include <iterator>
|
||||
#else
|
||||
namespace std {
|
||||
template <class Iterator>
|
||||
struct iterator_traits {
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef typename Iterator::value_type value_type;
|
||||
};
|
||||
|
||||
#if defined(__SUNPRO_CC) && defined(_RWSTD_VER)
|
||||
template <class Iterator, class Category,class T, class Reference, class Pointer, class Distance>
|
||||
struct iterator_traits<__reverse_bi_iterator<Iterator,Category,T,Reference,Pointer,Distance> > {
|
||||
typedef Distance difference_type;
|
||||
typedef T value_type;
|
||||
};
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
struct iterator_traits<T*> {
|
||||
typedef T value_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
};
|
||||
|
||||
template<typename _InputIterator>
|
||||
inline typename iterator_traits<_InputIterator>::difference_type
|
||||
distance(_InputIterator __first, _InputIterator __last)
|
||||
{
|
||||
typename iterator_traits<_InputIterator>::difference_type __n = 0;
|
||||
while (__first != __last) {
|
||||
++__first; ++__n;
|
||||
}
|
||||
return __n;
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
%}
|
||||
|
||||
%fragment("StdTraitsCommon","header") %{
|
||||
namespace swig {
|
||||
template <class Type>
|
||||
struct noconst_traits {
|
||||
typedef Type noconst_type;
|
||||
};
|
||||
|
||||
template <class Type>
|
||||
struct noconst_traits<const Type> {
|
||||
typedef Type noconst_type;
|
||||
};
|
||||
|
||||
/*
|
||||
type categories
|
||||
*/
|
||||
struct pointer_category { };
|
||||
struct value_category { };
|
||||
|
||||
/*
|
||||
General traits that provides type_name and type_info
|
||||
*/
|
||||
template <class Type> struct traits { };
|
||||
|
||||
template <class Type>
|
||||
inline const char* type_name() {
|
||||
return traits<typename noconst_traits<Type >::noconst_type >::type_name();
|
||||
}
|
||||
|
||||
template <class Type>
|
||||
struct traits_info {
|
||||
static swig_type_info *type_query(std::string name) {
|
||||
name += " *";
|
||||
return SWIG_TypeQuery(name.c_str());
|
||||
}
|
||||
static swig_type_info *type_info() {
|
||||
static swig_type_info *info = type_query(type_name<Type>());
|
||||
return info;
|
||||
}
|
||||
};
|
||||
|
||||
template <class Type>
|
||||
inline swig_type_info *type_info() {
|
||||
return traits_info<Type>::type_info();
|
||||
}
|
||||
|
||||
/*
|
||||
Partial specialization for pointers
|
||||
*/
|
||||
template <class Type> struct traits <Type *> {
|
||||
typedef pointer_category category;
|
||||
static std::string make_ptr_name(const char* name) {
|
||||
std::string ptrname = name;
|
||||
ptrname += " *";
|
||||
return ptrname;
|
||||
}
|
||||
static const char* type_name() {
|
||||
static std::string name = make_ptr_name(swig::type_name<Type>());
|
||||
return name.c_str();
|
||||
}
|
||||
};
|
||||
|
||||
template <class Type, class Category>
|
||||
struct traits_as { };
|
||||
|
||||
template <class Type, class Category>
|
||||
struct traits_check { };
|
||||
|
||||
}
|
||||
%}
|
||||
|
||||
/*
|
||||
Generate the traits for a swigtype
|
||||
*/
|
||||
|
||||
%define %traits_swigtype(Type...)
|
||||
%fragment(SWIG_Traits_frag(Type),"header",fragment="StdTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<Type > {
|
||||
typedef pointer_category category;
|
||||
static const char* type_name() { return #Type; }
|
||||
};
|
||||
}
|
||||
}
|
||||
%enddef
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Generate the typemaps for a class that has 'value' traits
|
||||
*/
|
||||
|
||||
%define %typemap_traits(Code,Type...)
|
||||
%typemaps_asvalfrom(%arg(Code),
|
||||
%arg(swig::asval<Type >),
|
||||
%arg(swig::from),
|
||||
%arg(SWIG_Traits_frag(Type)),
|
||||
%arg(SWIG_Traits_frag(Type)),
|
||||
Type);
|
||||
%enddef
|
||||
|
||||
/*
|
||||
Generate the typemaps for a class that behaves more like a 'pointer' or
|
||||
plain wrapped Swigtype.
|
||||
*/
|
||||
|
||||
%define %typemap_traits_ptr(Code,Type...)
|
||||
%typemaps_asptrfrom(%arg(Code),
|
||||
%arg(swig::asptr),
|
||||
%arg(swig::from),
|
||||
%arg(SWIG_Traits_frag(Type)),
|
||||
%arg(SWIG_Traits_frag(Type)),
|
||||
Type);
|
||||
%enddef
|
||||
|
||||
|
||||
/*
|
||||
Equality methods
|
||||
*/
|
||||
%define %std_equal_methods(Type...)
|
||||
%extend Type {
|
||||
bool operator == (const Type& v) {
|
||||
return *self == v;
|
||||
}
|
||||
|
||||
bool operator != (const Type& v) {
|
||||
return *self != v;
|
||||
}
|
||||
}
|
||||
|
||||
%enddef
|
||||
|
||||
/*
|
||||
Order methods
|
||||
*/
|
||||
|
||||
%define %std_order_methods(Type...)
|
||||
%extend Type {
|
||||
bool operator > (const Type& v) {
|
||||
return *self > v;
|
||||
}
|
||||
|
||||
bool operator < (const Type& v) {
|
||||
return *self < v;
|
||||
}
|
||||
|
||||
bool operator >= (const Type& v) {
|
||||
return *self >= v;
|
||||
}
|
||||
|
||||
bool operator <= (const Type& v) {
|
||||
return *self <= v;
|
||||
}
|
||||
}
|
||||
%enddef
|
||||
|
||||
/*
|
||||
Comparison methods
|
||||
*/
|
||||
|
||||
%define %std_comp_methods(Type...)
|
||||
%std_equal_methods(Type )
|
||||
%std_order_methods(Type )
|
||||
%enddef
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
%include <std_common.i>
|
||||
%include <exception.i>
|
||||
%include <std_alloc.i>
|
||||
|
||||
%{
|
||||
#include <algorithm>
|
||||
%}
|
||||
|
||||
// Common container methods
|
||||
|
||||
%define %std_container_methods(container...)
|
||||
container();
|
||||
container(const container&);
|
||||
|
||||
bool empty() const;
|
||||
size_type size() const;
|
||||
void clear();
|
||||
|
||||
void swap(container& v);
|
||||
|
||||
allocator_type get_allocator() const;
|
||||
|
||||
#ifdef SWIG_EXPORT_ITERATOR_METHODS
|
||||
class iterator;
|
||||
class reverse_iterator;
|
||||
class const_iterator;
|
||||
class const_reverse_iterator;
|
||||
|
||||
iterator begin();
|
||||
const_iterator begin() const;
|
||||
iterator end();
|
||||
const_iterator end() const;
|
||||
reverse_iterator rbegin();
|
||||
const_reverse_iterator rbegin() const;
|
||||
reverse_iterator rend();
|
||||
const_reverse_iterator rend() const;
|
||||
#endif
|
||||
|
||||
%enddef
|
||||
|
||||
// Common sequence
|
||||
|
||||
%define %std_sequence_methods_common(sequence)
|
||||
|
||||
%std_container_methods(%arg(sequence));
|
||||
|
||||
sequence(size_type size);
|
||||
void pop_back();
|
||||
|
||||
void resize(size_type new_size);
|
||||
|
||||
#ifdef SWIG_EXPORT_ITERATOR_METHODS
|
||||
iterator erase(iterator pos);
|
||||
iterator erase(iterator first, iterator last);
|
||||
#endif
|
||||
|
||||
%enddef
|
||||
|
||||
|
||||
%define %std_sequence_methods(sequence)
|
||||
|
||||
%std_sequence_methods_common(%arg(sequence));
|
||||
|
||||
sequence(size_type size, const value_type& value);
|
||||
void push_back(const value_type& x);
|
||||
|
||||
const value_type& front() const;
|
||||
const value_type& back() const;
|
||||
|
||||
void assign(size_type n, const value_type& x);
|
||||
|
||||
void resize(size_type new_size, const value_type& x);
|
||||
|
||||
#ifdef SWIG_EXPORT_ITERATOR_METHODS
|
||||
iterator insert(iterator pos, const value_type& x);
|
||||
void insert(iterator pos, size_type n, const value_type& x);
|
||||
#endif
|
||||
|
||||
%enddef
|
||||
|
||||
%define %std_sequence_methods_val(sequence...)
|
||||
|
||||
%std_sequence_methods_common(%arg(sequence));
|
||||
|
||||
sequence(size_type size, value_type value);
|
||||
void push_back(value_type x);
|
||||
|
||||
value_type front() const;
|
||||
value_type back() const;
|
||||
|
||||
void assign(size_type n, value_type x);
|
||||
|
||||
void resize(size_type new_size, value_type x);
|
||||
|
||||
#ifdef SWIG_EXPORT_ITERATOR_METHODS
|
||||
iterator insert(iterator pos, value_type x);
|
||||
void insert(iterator pos, size_type n, value_type x);
|
||||
#endif
|
||||
|
||||
%enddef
|
||||
|
||||
|
||||
//
|
||||
// Ignore member methods for Type with no default constructor
|
||||
//
|
||||
%define %std_nodefconst_type(Type...)
|
||||
%feature("ignore") std::vector<Type >::vector(size_type size);
|
||||
%feature("ignore") std::vector<Type >::resize(size_type size);
|
||||
%feature("ignore") std::deque<Type >::deque(size_type size);
|
||||
%feature("ignore") std::deque<Type >::resize(size_type size);
|
||||
%feature("ignore") std::list<Type >::list(size_type size);
|
||||
%feature("ignore") std::list<Type >::resize(size_type size);
|
||||
%enddef
|
||||
@@ -0,0 +1,127 @@
|
||||
//
|
||||
// std::deque
|
||||
|
||||
%include <std_container.i>
|
||||
|
||||
// Deque
|
||||
|
||||
%define %std_deque_methods(deque...)
|
||||
%std_sequence_methods(deque)
|
||||
|
||||
void pop_front();
|
||||
void push_front(const value_type& x);
|
||||
%enddef
|
||||
|
||||
%define %std_deque_methods_val(deque...)
|
||||
%std_sequence_methods_val(deque)
|
||||
|
||||
void pop_front();
|
||||
void push_front(value_type x);
|
||||
%enddef
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// std::deque
|
||||
//
|
||||
// const declarations are used to guess the intent of the function being
|
||||
// exported; therefore, the following rationale is applied:
|
||||
//
|
||||
// -- f(std::deque<T>), f(const std::deque<T>&):
|
||||
// the parameter being read-only, either a sequence or a
|
||||
// previously wrapped std::deque<T> can be passed.
|
||||
// -- f(std::deque<T>&), f(std::deque<T>*):
|
||||
// the parameter may be modified; therefore, only a wrapped std::deque
|
||||
// can be passed.
|
||||
// -- std::deque<T> f(), const std::deque<T>& f():
|
||||
// the deque is returned by copy; therefore, a sequence of T:s
|
||||
// is returned which is most easily used in other functions
|
||||
// -- std::deque<T>& f(), std::deque<T>* f():
|
||||
// the deque is returned by reference; therefore, a wrapped std::deque
|
||||
// is returned
|
||||
// -- const std::deque<T>* f(), f(const std::deque<T>*):
|
||||
// for consistency, they expect and return a plain deque pointer.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
%{
|
||||
#include <deque>
|
||||
%}
|
||||
|
||||
// exported classes
|
||||
|
||||
namespace std {
|
||||
|
||||
template<class _Tp, class _Alloc = allocator<_Tp> >
|
||||
class deque {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef _Tp value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef _Alloc allocator_type;
|
||||
|
||||
%traits_swigtype(_Tp);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::deque<_Tp, _Alloc >), "header",
|
||||
fragment=SWIG_Traits_frag(_Tp),
|
||||
fragment="StdDequeTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::deque<_Tp, _Alloc > > {
|
||||
typedef pointer_category category;
|
||||
static const char* type_name() {
|
||||
return "std::deque<" #_Tp " >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_DEQUE, std::deque<_Tp, _Alloc >);
|
||||
|
||||
#ifdef %swig_deque_methods
|
||||
// Add swig/language extra methods
|
||||
%swig_deque_methods(std::deque<_Tp, _Alloc >);
|
||||
#endif
|
||||
|
||||
%std_deque_methods(deque);
|
||||
};
|
||||
|
||||
template<class _Tp, class _Alloc >
|
||||
class deque<_Tp*, _Alloc > {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef _Tp* value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type reference;
|
||||
typedef value_type const_reference;
|
||||
typedef _Alloc allocator_type;
|
||||
|
||||
%traits_swigtype(_Tp);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::deque<_Tp*, _Alloc >), "header",
|
||||
fragment=SWIG_Traits_frag(_Tp),
|
||||
fragment="StdDequeTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::deque<_Tp*, _Alloc > > {
|
||||
typedef value_category category;
|
||||
static const char* type_name() {
|
||||
return "std::deque<" #_Tp " * >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_DEQUE, std::deque<_Tp*, _Alloc >);
|
||||
|
||||
#ifdef %swig_deque_methods_val
|
||||
// Add swig/language extra methods
|
||||
%swig_deque_methods_val(std::deque<_Tp*, _Alloc >);
|
||||
#endif
|
||||
|
||||
%std_deque_methods_val(std::deque<_Tp*, _Alloc >);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP)
|
||||
#error "do not use this version of std_except.i"
|
||||
#endif
|
||||
|
||||
%{
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
#if defined(SWIG_STD_EXCEPTIONS_AS_CLASSES)
|
||||
|
||||
namespace std {
|
||||
struct exception
|
||||
{
|
||||
virtual ~exception() throw();
|
||||
virtual const char* what() const throw();
|
||||
};
|
||||
|
||||
struct bad_exception : exception
|
||||
{
|
||||
};
|
||||
|
||||
struct logic_error : exception
|
||||
{
|
||||
logic_error(const string& msg);
|
||||
};
|
||||
|
||||
struct domain_error : logic_error
|
||||
{
|
||||
domain_error(const string& msg);
|
||||
};
|
||||
|
||||
struct invalid_argument : logic_error
|
||||
{
|
||||
invalid_argument(const string& msg);
|
||||
};
|
||||
|
||||
struct length_error : logic_error
|
||||
{
|
||||
length_error(const string& msg);
|
||||
};
|
||||
|
||||
struct out_of_range : logic_error
|
||||
{
|
||||
out_of_range(const string& msg);
|
||||
};
|
||||
|
||||
struct runtime_error : exception
|
||||
{
|
||||
runtime_error(const string& msg);
|
||||
};
|
||||
|
||||
struct range_error : runtime_error
|
||||
{
|
||||
range_error(const string& msg);
|
||||
};
|
||||
|
||||
struct overflow_error : runtime_error
|
||||
{
|
||||
overflow_error(const string& msg);
|
||||
};
|
||||
|
||||
struct underflow_error : runtime_error
|
||||
{
|
||||
underflow_error(const string& msg);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,260 @@
|
||||
%include <std_char_traits.i>
|
||||
%include <std_basic_string.i>
|
||||
%include <std_except.i>
|
||||
%{
|
||||
#ifndef SWIG_STD_NOMODERN_STL
|
||||
# include <ios>
|
||||
#else
|
||||
# include <streambuf.h>
|
||||
#endif
|
||||
%}
|
||||
|
||||
namespace std {
|
||||
|
||||
template<typename _CharT, typename _Traits = char_traits<_CharT> >
|
||||
class basic_streambuf;
|
||||
|
||||
template<typename _CharT, typename _Traits = char_traits<_CharT> >
|
||||
class basic_istream;
|
||||
|
||||
template<typename _CharT, typename _Traits = char_traits<_CharT> >
|
||||
class basic_ostream;
|
||||
|
||||
// 27.4.2 Class ios_base
|
||||
typedef size_t streamsize;
|
||||
|
||||
class locale;
|
||||
|
||||
|
||||
class ios_base
|
||||
{
|
||||
public:
|
||||
|
||||
#ifdef SWIG_NESTED_CLASSES
|
||||
// 27.4.2.1.1 Class ios_base::failure
|
||||
class failure : public exception
|
||||
{
|
||||
public:
|
||||
explicit failure(const string& __str) throw();
|
||||
};
|
||||
#endif
|
||||
|
||||
// 27.4.2.1.2 Type ios_base::fmtflags
|
||||
typedef int fmtflags;
|
||||
// 27.4.2.1.2 Type fmtflags
|
||||
static const fmtflags boolalpha ;
|
||||
static const fmtflags dec ;
|
||||
static const fmtflags fixed ;
|
||||
static const fmtflags hex ;
|
||||
static const fmtflags internal ;
|
||||
static const fmtflags left ;
|
||||
static const fmtflags oct ;
|
||||
static const fmtflags right ;
|
||||
static const fmtflags scientific ;
|
||||
static const fmtflags showbase ;
|
||||
static const fmtflags showpoint ;
|
||||
static const fmtflags showpos ;
|
||||
static const fmtflags skipws ;
|
||||
static const fmtflags unitbuf ;
|
||||
static const fmtflags uppercase ;
|
||||
static const fmtflags adjustfield ;
|
||||
static const fmtflags basefield ;
|
||||
static const fmtflags floatfield ;
|
||||
|
||||
// 27.4.2.1.3 Type ios_base::iostate
|
||||
typedef int iostate;
|
||||
static const iostate badbit ;
|
||||
static const iostate eofbit ;
|
||||
static const iostate failbit ;
|
||||
static const iostate goodbit ;
|
||||
|
||||
// 27.4.2.1.4 Type openmode
|
||||
typedef int openmode;
|
||||
static const openmode app ;
|
||||
static const openmode ate ;
|
||||
static const openmode binary ;
|
||||
static const openmode in ;
|
||||
static const openmode out ;
|
||||
static const openmode trunc ;
|
||||
|
||||
// 27.4.2.1.5 Type seekdir
|
||||
typedef int seekdir;
|
||||
static const seekdir beg ;
|
||||
static const seekdir cur ;
|
||||
static const seekdir end ;
|
||||
|
||||
|
||||
// Callbacks;
|
||||
enum event
|
||||
{
|
||||
erase_event,
|
||||
imbue_event,
|
||||
copyfmt_event
|
||||
};
|
||||
|
||||
typedef void (*event_callback) (event, ios_base&, int);
|
||||
|
||||
void
|
||||
register_callback(event_callback __fn, int __index);
|
||||
|
||||
// Fmtflags state:
|
||||
inline fmtflags
|
||||
flags() const ;
|
||||
|
||||
inline fmtflags
|
||||
flags(fmtflags __fmtfl);
|
||||
|
||||
inline fmtflags
|
||||
setf(fmtflags __fmtfl);
|
||||
|
||||
inline fmtflags
|
||||
setf(fmtflags __fmtfl, fmtflags __mask);
|
||||
|
||||
inline void
|
||||
unsetf(fmtflags __mask) ;
|
||||
|
||||
inline streamsize
|
||||
precision() const ;
|
||||
|
||||
inline streamsize
|
||||
precision(streamsize __prec);
|
||||
|
||||
inline streamsize
|
||||
width() const ;
|
||||
|
||||
inline streamsize
|
||||
width(streamsize __wide);
|
||||
|
||||
static bool
|
||||
sync_with_stdio(bool __sync = true);
|
||||
|
||||
// Locales:
|
||||
locale
|
||||
imbue(const locale& __loc);
|
||||
|
||||
inline locale
|
||||
getloc() const { return _M_ios_locale; }
|
||||
|
||||
// Storage:
|
||||
static int
|
||||
xalloc() throw();
|
||||
|
||||
inline long&
|
||||
iword(int __ix);
|
||||
|
||||
inline void*&
|
||||
pword(int __ix);
|
||||
|
||||
// Destructor
|
||||
~ios_base();
|
||||
|
||||
protected:
|
||||
ios_base();
|
||||
|
||||
//50. Copy constructor and assignment operator of ios_base
|
||||
private:
|
||||
ios_base(const ios_base&);
|
||||
|
||||
ios_base&
|
||||
operator=(const ios_base&);
|
||||
};
|
||||
|
||||
template<typename _CharT, typename _Traits = char_traits<_CharT> >
|
||||
class basic_ios : public ios_base
|
||||
{
|
||||
public:
|
||||
// Types:
|
||||
typedef _CharT char_type;
|
||||
typedef typename _Traits::int_type int_type;
|
||||
typedef typename _Traits::pos_type pos_type;
|
||||
typedef typename _Traits::off_type off_type;
|
||||
typedef _Traits traits_type;
|
||||
|
||||
public:
|
||||
|
||||
iostate
|
||||
rdstate() const;
|
||||
|
||||
void
|
||||
clear(iostate __state = goodbit);
|
||||
|
||||
void
|
||||
setstate(iostate __state);
|
||||
|
||||
bool
|
||||
good() const;
|
||||
|
||||
bool
|
||||
eof() const;
|
||||
|
||||
bool
|
||||
fail() const;
|
||||
|
||||
bool
|
||||
bad() const;
|
||||
|
||||
iostate
|
||||
exceptions() const;
|
||||
|
||||
void
|
||||
exceptions(iostate __except);
|
||||
|
||||
// Constructor/destructor:
|
||||
explicit
|
||||
basic_ios(basic_streambuf<_CharT, _Traits>* __sb) : ios_base();
|
||||
|
||||
virtual
|
||||
~basic_ios() ;
|
||||
|
||||
// Members:
|
||||
basic_ostream<_CharT, _Traits>*
|
||||
tie() const;
|
||||
|
||||
basic_ostream<_CharT, _Traits>*
|
||||
tie(basic_ostream<_CharT, _Traits>* __tiestr);
|
||||
|
||||
basic_streambuf<_CharT, _Traits>*
|
||||
rdbuf() const;
|
||||
|
||||
basic_streambuf<_CharT, _Traits>*
|
||||
rdbuf(basic_streambuf<_CharT, _Traits>* __sb);
|
||||
|
||||
basic_ios&
|
||||
copyfmt(const basic_ios& __rhs);
|
||||
|
||||
char_type
|
||||
fill() const;
|
||||
|
||||
char_type
|
||||
fill(char_type __ch);
|
||||
|
||||
// Locales:
|
||||
locale
|
||||
imbue(const locale& __loc);
|
||||
|
||||
char
|
||||
narrow(char_type __c, char __dfault) const;
|
||||
|
||||
char_type
|
||||
widen(char __c) const;
|
||||
|
||||
protected:
|
||||
// 27.4.5.1 basic_ios constructors
|
||||
basic_ios();
|
||||
private:
|
||||
ios_base(const ios_base&);
|
||||
|
||||
ios_base&
|
||||
operator=(const ios_base&);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace std {
|
||||
%template(ios) basic_ios<char>;
|
||||
#if defined(SWIG_WCHAR)
|
||||
%template(wios) basic_ios<wchar_t>;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,339 @@
|
||||
/*
|
||||
For wchar support, you need to include the wchar.i file
|
||||
before this file, ie:
|
||||
|
||||
%include <wchar.i>
|
||||
%include <std_iostream.i>
|
||||
|
||||
or equivalently, just include
|
||||
|
||||
%include <std_wiostream.i>
|
||||
*/
|
||||
|
||||
%include <std_ios.i>
|
||||
%include <std_basic_string.i>
|
||||
%include <std_string.i>
|
||||
#if defined(SWIG_WCHAR)
|
||||
%include <std_wstring.i>
|
||||
#endif
|
||||
|
||||
%{
|
||||
#include <iostream>
|
||||
%}
|
||||
|
||||
|
||||
namespace std
|
||||
{
|
||||
// 27.6.2.1 Template class basic_ostream
|
||||
template<typename _CharT, typename _Traits = char_traits<_CharT> >
|
||||
class basic_ostream : virtual public basic_ios<_CharT, _Traits>
|
||||
{
|
||||
public:
|
||||
// Types (inherited from basic_ios (27.4.4)):
|
||||
typedef _CharT char_type;
|
||||
typedef typename _Traits::int_type int_type;
|
||||
typedef typename _Traits::pos_type pos_type;
|
||||
typedef typename _Traits::off_type off_type;
|
||||
typedef _Traits traits_type;
|
||||
|
||||
// 27.6.2.2 Constructor/destructor:
|
||||
explicit
|
||||
basic_ostream(basic_streambuf<_CharT, _Traits>* __sb);
|
||||
|
||||
virtual
|
||||
~basic_ostream();
|
||||
|
||||
// 27.6.2.5 Formatted output:
|
||||
// 27.6.2.5.3 basic_ostream::operator<<
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(basic_ostream<_CharT, _Traits>& (*__pf)(basic_ostream<_CharT, _Traits>&));
|
||||
|
||||
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(basic_ios<_CharT, _Traits>& (*__pf)(basic_ios<_CharT, _Traits>&));
|
||||
|
||||
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(ios_base& (*__pf) (ios_base&));
|
||||
|
||||
// 27.6.2.5.2 Arithmetic Inserters
|
||||
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(long __n);
|
||||
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(unsigned long __n);
|
||||
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(bool __n);
|
||||
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(short __n);
|
||||
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(unsigned short __n);
|
||||
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(int __n);
|
||||
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(unsigned int __n);
|
||||
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(long long __n);
|
||||
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(unsigned long long __n);
|
||||
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(double __f);
|
||||
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(float __f);
|
||||
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(long double __f);
|
||||
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(const void* __p);
|
||||
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(basic_streambuf<_CharT, _Traits>* __sb);
|
||||
|
||||
%extend {
|
||||
std::basic_ostream<_CharT, _Traits >&
|
||||
operator<<(const std::basic_string<_CharT,_Traits, std::allocator<_CharT> >& s)
|
||||
{
|
||||
*self << s;
|
||||
return *self;
|
||||
}
|
||||
}
|
||||
|
||||
// Unformatted output:
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
put(char_type __c);
|
||||
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
write(const char_type* __s, streamsize __n);
|
||||
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
flush();
|
||||
|
||||
// Seeks:
|
||||
pos_type
|
||||
tellp();
|
||||
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
seekp(pos_type);
|
||||
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
seekp(off_type, ios_base::seekdir);
|
||||
|
||||
};
|
||||
|
||||
// 27.6.1.1 Template class basic_istream
|
||||
template<typename _CharT, typename _Traits = char_traits<_CharT> >
|
||||
class basic_istream : virtual public basic_ios<_CharT, _Traits>
|
||||
{
|
||||
public:
|
||||
// Types (inherited from basic_ios (27.4.4)):
|
||||
typedef _CharT char_type;
|
||||
typedef typename _Traits::int_type int_type;
|
||||
typedef typename _Traits::pos_type pos_type;
|
||||
typedef typename _Traits::off_type off_type;
|
||||
typedef _Traits traits_type;
|
||||
|
||||
|
||||
public:
|
||||
// 27.6.1.1.1 Constructor/destructor:
|
||||
explicit
|
||||
basic_istream(basic_streambuf<_CharT, _Traits>* __sb);
|
||||
|
||||
virtual
|
||||
~basic_istream();
|
||||
|
||||
// 27.6.1.2.3 basic_istream::operator>>
|
||||
basic_istream<_CharT, _Traits>&
|
||||
operator>>(basic_istream<_CharT, _Traits>& (*__pf)(basic_istream<_CharT, _Traits>&));
|
||||
|
||||
basic_istream<_CharT, _Traits>&
|
||||
operator>>(basic_ios<_CharT, _Traits>& (*__pf)(basic_ios<_CharT, _Traits>&));
|
||||
|
||||
basic_istream<_CharT, _Traits>&
|
||||
operator>>(ios_base& (*__pf)(ios_base&));
|
||||
|
||||
// 27.6.1.2.2 Arithmetic Extractors
|
||||
basic_istream<_CharT, _Traits>&
|
||||
operator>>(bool& __n);
|
||||
|
||||
basic_istream<_CharT, _Traits>&
|
||||
operator>>(short& __n);
|
||||
|
||||
basic_istream<_CharT, _Traits>&
|
||||
operator>>(unsigned short& __n);
|
||||
|
||||
basic_istream<_CharT, _Traits>&
|
||||
operator>>(int& __n);
|
||||
|
||||
basic_istream<_CharT, _Traits>&
|
||||
operator>>(unsigned int& __n);
|
||||
|
||||
basic_istream<_CharT, _Traits>&
|
||||
operator>>(long& __n);
|
||||
|
||||
basic_istream<_CharT, _Traits>&
|
||||
operator>>(unsigned long& __n);
|
||||
|
||||
basic_istream<_CharT, _Traits>&
|
||||
operator>>(long long& __n);
|
||||
|
||||
basic_istream<_CharT, _Traits>&
|
||||
operator>>(unsigned long long& __n);
|
||||
|
||||
basic_istream<_CharT, _Traits>&
|
||||
operator>>(float& __f);
|
||||
|
||||
basic_istream<_CharT, _Traits>&
|
||||
operator>>(double& __f);
|
||||
|
||||
basic_istream<_CharT, _Traits>&
|
||||
operator>>(long double& __f);
|
||||
|
||||
basic_istream<_CharT, _Traits>&
|
||||
operator>>(void*& __p);
|
||||
|
||||
basic_istream<_CharT, _Traits>&
|
||||
operator>>(basic_streambuf<_CharT, _Traits>* __sb);
|
||||
|
||||
// 27.6.1.3 Unformatted input:
|
||||
inline streamsize
|
||||
gcount(void) const;
|
||||
|
||||
int_type
|
||||
get(void);
|
||||
|
||||
basic_istream<_CharT, _Traits>&
|
||||
get(char_type& __c);
|
||||
|
||||
basic_istream<_CharT, _Traits>&
|
||||
get(char_type* __s, streamsize __n, char_type __delim);
|
||||
|
||||
inline basic_istream<_CharT, _Traits>&
|
||||
get(char_type* __s, streamsize __n);
|
||||
|
||||
basic_istream<_CharT, _Traits>&
|
||||
get(basic_streambuf<_CharT, _Traits>& __sb, char_type __delim);
|
||||
|
||||
inline basic_istream<_CharT, _Traits>&
|
||||
get(basic_streambuf<_CharT, _Traits>& __sb);
|
||||
|
||||
basic_istream<_CharT, _Traits>&
|
||||
getline(char_type* __s, streamsize __n, char_type __delim);
|
||||
|
||||
inline basic_istream<_CharT, _Traits>&
|
||||
getline(char_type* __s, streamsize __n);
|
||||
|
||||
basic_istream<_CharT, _Traits>&
|
||||
ignore(streamsize __n = 1, int_type __delim = _Traits::eof());
|
||||
|
||||
int_type
|
||||
peek(void);
|
||||
|
||||
basic_istream<_CharT, _Traits>&
|
||||
read(char_type* __s, streamsize __n);
|
||||
|
||||
streamsize
|
||||
readsome(char_type* __s, streamsize __n);
|
||||
|
||||
basic_istream<_CharT, _Traits>&
|
||||
putback(char_type __c);
|
||||
|
||||
basic_istream<_CharT, _Traits>&
|
||||
unget(void);
|
||||
|
||||
int
|
||||
sync(void);
|
||||
|
||||
pos_type
|
||||
tellg(void);
|
||||
|
||||
basic_istream<_CharT, _Traits>&
|
||||
seekg(pos_type);
|
||||
|
||||
basic_istream<_CharT, _Traits>&
|
||||
seekg(off_type, ios_base::seekdir);
|
||||
};
|
||||
|
||||
// 27.6.1.5 Template class basic_iostream
|
||||
template<typename _CharT, typename _Traits = char_traits<_CharT> >
|
||||
class basic_iostream
|
||||
: public basic_istream<_CharT, _Traits>,
|
||||
public basic_ostream<_CharT, _Traits>
|
||||
{
|
||||
public:
|
||||
typedef _CharT char_type;
|
||||
typedef typename _Traits::int_type int_type;
|
||||
typedef typename _Traits::pos_type pos_type;
|
||||
typedef typename _Traits::off_type off_type;
|
||||
typedef _Traits traits_type;
|
||||
|
||||
explicit
|
||||
basic_iostream(basic_streambuf<_CharT, _Traits>* __sb);
|
||||
|
||||
virtual
|
||||
~basic_iostream();
|
||||
};
|
||||
|
||||
typedef basic_ostream<char> ostream ;
|
||||
typedef basic_istream<char> istream;
|
||||
typedef basic_iostream<char> iostream;
|
||||
|
||||
extern istream cin;
|
||||
extern ostream cout;
|
||||
extern ostream cerr;
|
||||
extern ostream clog;
|
||||
|
||||
#if defined(SWIG_WCHAR)
|
||||
typedef basic_ostream<wchar_t> wostream;
|
||||
typedef basic_istream<wchar_t> wistream;
|
||||
typedef basic_iostream<wchar_t> wiostream;
|
||||
|
||||
extern wistream wcin;
|
||||
extern wostream wcout;
|
||||
extern wostream wcerr;
|
||||
extern wostream wclog;
|
||||
#endif
|
||||
|
||||
template<typename _CharT, typename _Traits = char_traits<_CharT> >
|
||||
std::basic_ostream<_CharT, _Traits>&
|
||||
endl(std::basic_ostream<_CharT, _Traits>&);
|
||||
|
||||
template<typename _CharT, typename _Traits = char_traits<_CharT> >
|
||||
std::basic_ostream<_CharT, _Traits>&
|
||||
ends(std::basic_ostream<_CharT, _Traits>&);
|
||||
|
||||
template<typename _CharT, typename _Traits = char_traits<_CharT> >
|
||||
std::basic_ostream<_CharT, _Traits>&
|
||||
flush(std::basic_ostream<_CharT, _Traits>&);
|
||||
}
|
||||
|
||||
namespace std {
|
||||
%template(ostream) basic_ostream<char>;
|
||||
%template(istream) basic_istream<char>;
|
||||
%template(iostream) basic_iostream<char>;
|
||||
|
||||
%template(endl) endl<char, std::char_traits<char> >;
|
||||
%template(ends) ends<char, std::char_traits<char> >;
|
||||
%template(flush) flush<char, std::char_traits<char> >;
|
||||
|
||||
#if defined(SWIG_WCHAR)
|
||||
%template(wostream) basic_ostream<wchar_t>;
|
||||
%template(wistream) basic_istream<wchar_t>;
|
||||
%template(wiostream) basic_iostream<wchar_t>;
|
||||
|
||||
%template(wendl) endl<wchar_t, std::char_traits<wchar_t> >;
|
||||
%template(wends) ends<wchar_t, std::char_traits<wchar_t> >;
|
||||
%template(wflush) flush<wchar_t, std::char_traits<wchar_t> >;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
//
|
||||
// std::list
|
||||
//
|
||||
|
||||
%include <std_container.i>
|
||||
|
||||
// List
|
||||
|
||||
%define %std_list_methods(list)
|
||||
%std_sequence_methods(list)
|
||||
|
||||
void pop_front();
|
||||
void push_front(const value_type& x);
|
||||
|
||||
void reverse();
|
||||
|
||||
%enddef
|
||||
|
||||
|
||||
%define %std_list_methods_val(list)
|
||||
%std_sequence_methods_val(list)
|
||||
|
||||
void pop_front();
|
||||
void push_front(value_type x);
|
||||
|
||||
void remove(value_type x);
|
||||
void unique();
|
||||
void reverse();
|
||||
void sort();
|
||||
|
||||
void merge(list& x);
|
||||
%enddef
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// std::list
|
||||
//
|
||||
// const declarations are used to guess the intent of the function being
|
||||
// exported; therefore, the following rationale is applied:
|
||||
//
|
||||
// -- f(std::list<T>), f(const std::list<T>&):
|
||||
// the parameter being read-only, either a sequence or a
|
||||
// previously wrapped std::list<T> can be passed.
|
||||
// -- f(std::list<T>&), f(std::list<T>*):
|
||||
// the parameter may be modified; therefore, only a wrapped std::list
|
||||
// can be passed.
|
||||
// -- std::list<T> f(), const std::list<T>& f():
|
||||
// the list is returned by copy; therefore, a sequence of T:s
|
||||
// is returned which is most easily used in other functions
|
||||
// -- std::list<T>& f(), std::list<T>* f():
|
||||
// the list is returned by reference; therefore, a wrapped std::list
|
||||
// is returned
|
||||
// -- const std::list<T>* f(), f(const std::list<T>*):
|
||||
// for consistency, they expect and return a plain list pointer.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
%{
|
||||
#include <list>
|
||||
%}
|
||||
|
||||
// exported classes
|
||||
|
||||
namespace std {
|
||||
|
||||
template<class _Tp, class _Alloc = allocator<_Tp> >
|
||||
class list {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef _Tp value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef _Alloc allocator_type;
|
||||
|
||||
%traits_swigtype(_Tp);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::list<_Tp, _Alloc >), "header",
|
||||
fragment=SWIG_Traits_frag(_Tp),
|
||||
fragment="StdListTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::list<_Tp, _Alloc > > {
|
||||
typedef pointer_category category;
|
||||
static const char* type_name() {
|
||||
return "std::list<" #_Tp ", " #_Alloc " >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_LIST, std::list<_Tp, _Alloc >);
|
||||
|
||||
#ifdef %swig_list_methods
|
||||
// Add swig/language extra methods
|
||||
%swig_list_methods(std::list<_Tp, _Alloc >);
|
||||
#endif
|
||||
|
||||
%std_list_methods(list);
|
||||
};
|
||||
|
||||
template<class _Tp, class _Alloc >
|
||||
class list<_Tp*, _Alloc> {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef _Tp* value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type reference;
|
||||
typedef value_type const_reference;
|
||||
typedef _Alloc allocator_type;
|
||||
|
||||
%traits_swigtype(_Tp);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::list<_Tp*, _Alloc >), "header",
|
||||
fragment=SWIG_Traits_frag(_Tp),
|
||||
fragment="StdListTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::list<_Tp*, _Alloc > > {
|
||||
typedef value_category category;
|
||||
static const char* type_name() {
|
||||
return "std::list<" #_Tp " *," #_Alloc " >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_LIST, std::list<_Tp*, _Alloc >);
|
||||
|
||||
#ifdef %swig_list_methods_val
|
||||
// Add swig/language extra methods
|
||||
%swig_list_methods_val(std::list<_Tp*, _Alloc >);
|
||||
#endif
|
||||
|
||||
%std_list_methods_val(list);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
%define %std_extequal_list(...)
|
||||
%extend std::list<__VA_ARGS__ > {
|
||||
void remove(const value_type& x) { self->remove(x); }
|
||||
void merge(std::list<__VA_ARGS__ >& x){ self->merge(x); }
|
||||
void unique() { self->unique(); }
|
||||
void sort() { self->sort(); }
|
||||
}
|
||||
%enddef
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
//
|
||||
// std::map
|
||||
//
|
||||
|
||||
%include <std_pair.i>
|
||||
%include <std_container.i>
|
||||
|
||||
%define %std_map_methods_common(map...)
|
||||
%std_container_methods(map);
|
||||
|
||||
size_type erase(const key_type& x);
|
||||
size_type count(const key_type& x) const;
|
||||
|
||||
#ifdef SWIG_EXPORT_ITERATOR_METHODS
|
||||
// iterator insert(iterator position, const value_type& x);
|
||||
void erase(iterator position);
|
||||
void erase(iterator first, iterator last);
|
||||
|
||||
iterator find(const key_type& x);
|
||||
iterator lower_bound(const key_type& x);
|
||||
iterator upper_bound(const key_type& x);
|
||||
#endif
|
||||
%enddef
|
||||
|
||||
%define %std_map_methods(map...)
|
||||
%std_map_methods_common(map);
|
||||
|
||||
#ifdef SWIG_EXPORT_ITERATOR_METHODS
|
||||
// iterator insert(const value_type& x);
|
||||
#endif
|
||||
%enddef
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// std::map
|
||||
//
|
||||
// const declarations are used to guess the intent of the function being
|
||||
// exported; therefore, the following rationale is applied:
|
||||
//
|
||||
// -- f(std::map<T>), f(const std::map<T>&):
|
||||
// the parameter being read-only, either a sequence or a
|
||||
// previously wrapped std::map<T> can be passed.
|
||||
// -- f(std::map<T>&), f(std::map<T>*):
|
||||
// the parameter may be modified; therefore, only a wrapped std::map
|
||||
// can be passed.
|
||||
// -- std::map<T> f(), const std::map<T>& f():
|
||||
// the map is returned by copy; therefore, a sequence of T:s
|
||||
// is returned which is most easily used in other functions
|
||||
// -- std::map<T>& f(), std::map<T>* f():
|
||||
// the map is returned by reference; therefore, a wrapped std::map
|
||||
// is returned
|
||||
// -- const std::map<T>* f(), f(const std::map<T>*):
|
||||
// for consistency, they expect and return a plain map pointer.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
%{
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
// exported class
|
||||
|
||||
namespace std {
|
||||
|
||||
template<class _Key, class _Tp, class _Compare = std::less<_Key >,
|
||||
class _Alloc = allocator<std::pair<const _Key, _Tp > > >
|
||||
class map {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef _Key key_type;
|
||||
typedef _Tp mapped_type;
|
||||
typedef std::pair<const _Key, _Tp> value_type;
|
||||
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef _Alloc allocator_type;
|
||||
|
||||
%traits_swigtype(_Key);
|
||||
%traits_swigtype(_Tp);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::pair< _Key, _Tp >), "header",
|
||||
fragment=SWIG_Traits_frag(_Key),
|
||||
fragment=SWIG_Traits_frag(_Tp),
|
||||
fragment="StdPairTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::pair< _Key, _Tp > > {
|
||||
typedef pointer_category category;
|
||||
static const char* type_name() {
|
||||
return "std::pair<" #_Key "," #_Tp " >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::map<_Key, _Tp, _Compare, _Alloc >), "header",
|
||||
fragment=SWIG_Traits_frag(std::pair<_Key, _Tp >),
|
||||
fragment="StdMapTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::map<_Key, _Tp, _Compare, _Alloc > > {
|
||||
typedef pointer_category category;
|
||||
static const char* type_name() {
|
||||
return "std::map<" #_Key "," #_Tp "," #_Compare "," #_Alloc " >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_MAP, std::map<_Key, _Tp, _Compare, _Alloc >);
|
||||
|
||||
map( const _Compare& );
|
||||
|
||||
#ifdef %swig_map_methods
|
||||
// Add swig/language extra methods
|
||||
%swig_map_methods(std::map<_Key, _Tp, _Compare, _Alloc >);
|
||||
#endif
|
||||
|
||||
%std_map_methods(map);
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
//
|
||||
// std::map
|
||||
//
|
||||
|
||||
%include <std_map.i>
|
||||
|
||||
|
||||
%define %std_multimap_methods(mmap...)
|
||||
%std_map_methods_common(mmap);
|
||||
|
||||
#ifdef SWIG_EXPORT_ITERATOR_METHODS
|
||||
std::pair<iterator,iterator> equal_range(const key_type& x);
|
||||
std::pair<const_iterator,const_iterator> equal_range(const key_type& x) const;
|
||||
#endif
|
||||
%enddef
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// std::multimap
|
||||
//
|
||||
// const declarations are used to guess the intent of the function being
|
||||
// exported; therefore, the following rationale is applied:
|
||||
//
|
||||
// -- f(std::multimap<T>), f(const std::multimap<T>&):
|
||||
// the parameter being read-only, either a sequence or a
|
||||
// previously wrapped std::multimap<T> can be passed.
|
||||
// -- f(std::multimap<T>&), f(std::multimap<T>*):
|
||||
// the parameter may be modified; therefore, only a wrapped std::multimap
|
||||
// can be passed.
|
||||
// -- std::multimap<T> f(), const std::multimap<T>& f():
|
||||
// the map is returned by copy; therefore, a sequence of T:s
|
||||
// is returned which is most easily used in other functions
|
||||
// -- std::multimap<T>& f(), std::multimap<T>* f():
|
||||
// the map is returned by reference; therefore, a wrapped std::multimap
|
||||
// is returned
|
||||
// -- const std::multimap<T>* f(), f(const std::multimap<T>*):
|
||||
// for consistency, they expect and return a plain map pointer.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
|
||||
// exported class
|
||||
|
||||
|
||||
namespace std {
|
||||
template<class _Key, class _Tp, class _Compare = std::less<_Key >,
|
||||
class _Alloc = allocator<std::pair<const _Key, _Tp > > >
|
||||
class multimap {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef _Key key_type;
|
||||
typedef _Tp mapped_type;
|
||||
typedef std::pair<const _Key, _Tp> value_type;
|
||||
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef _Alloc allocator_type;
|
||||
|
||||
%traits_swigtype(_Key);
|
||||
%traits_swigtype(_Tp);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::multimap<_Key, _Tp, _Compare, _Alloc >), "header",
|
||||
fragment=SWIG_Traits_frag(std::pair<_Key, _Tp >),
|
||||
fragment="StdMultimapTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::multimap<_Key, _Tp, _Compare, _Alloc > > {
|
||||
typedef pointer_category category;
|
||||
static const char* type_name() {
|
||||
return "std::multimap<" #_Key "," #_Tp "," #_Compare "," #_Alloc " >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_MULTIMAP, std::multimap<_Key, _Tp, _Compare, _Alloc >);
|
||||
|
||||
multimap( const _Compare& );
|
||||
|
||||
#ifdef %swig_multimap_methods
|
||||
// Add swig/language extra methods
|
||||
%swig_multimap_methods(std::multimap<_Key, _Tp, _Compare, _Alloc >);
|
||||
#endif
|
||||
|
||||
%std_multimap_methods(multimap);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
//
|
||||
// std::set
|
||||
//
|
||||
|
||||
%include <std_set.i>
|
||||
|
||||
// Multiset
|
||||
|
||||
%define %std_multiset_methods(multiset...)
|
||||
%std_set_methods_common(multiset);
|
||||
%enddef
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// std::multiset
|
||||
//
|
||||
// const declarations are used to guess the intent of the function being
|
||||
// exported; therefore, the following rationale is applied:
|
||||
//
|
||||
// -- f(std::multiset<T>), f(const std::multiset<T>&):
|
||||
// the parameter being read-only, either a sequence or a
|
||||
// previously wrapped std::multiset<T> can be passed.
|
||||
// -- f(std::multiset<T>&), f(std::multiset<T>*):
|
||||
// the parameter may be modified; therefore, only a wrapped std::multiset
|
||||
// can be passed.
|
||||
// -- std::multiset<T> f(), const std::multiset<T>& f():
|
||||
// the set is returned by copy; therefore, a sequence of T:s
|
||||
// is returned which is most easily used in other functions
|
||||
// -- std::multiset<T>& f(), std::multiset<T>* f():
|
||||
// the set is returned by reference; therefore, a wrapped std::multiset
|
||||
// is returned
|
||||
// -- const std::multiset<T>* f(), f(const std::multiset<T>*):
|
||||
// for consistency, they expect and return a plain set pointer.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
|
||||
// exported classes
|
||||
|
||||
namespace std {
|
||||
|
||||
//multiset
|
||||
|
||||
template <class _Key, class _Compare = std::less<_Key>,
|
||||
class _Alloc = allocator<_Key> >
|
||||
class multiset {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef _Key value_type;
|
||||
typedef _Key key_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef _Alloc allocator_type;
|
||||
|
||||
%traits_swigtype(_Key);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::multiset<_Key, _Compare, _Alloc >), "header",
|
||||
fragment=SWIG_Traits_frag(_Key),
|
||||
fragment="StdMultisetTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::multiset<_Key, _Compare, _Alloc > > {
|
||||
typedef pointer_category category;
|
||||
static const char* type_name() {
|
||||
return "std::multiset<" #_Key "," #_Compare "," #_Alloc " >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_MULTISET, std::multiset<_Key, _Compare, _Alloc >);
|
||||
|
||||
multiset( const _Compare& );
|
||||
|
||||
#ifdef %swig_multiset_methods
|
||||
// Add swig/language extra methods
|
||||
%swig_multiset_methods(std::multiset<_Key, _Compare, _Alloc >);
|
||||
#endif
|
||||
|
||||
%std_multiset_methods(multiset);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
%include <std_common.i>
|
||||
|
||||
%{
|
||||
#include <utility>
|
||||
%}
|
||||
|
||||
|
||||
namespace std {
|
||||
template <class T, class U > struct pair {
|
||||
typedef T first_type;
|
||||
typedef U second_type;
|
||||
|
||||
%traits_swigtype(T);
|
||||
%traits_swigtype(U);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::pair<T,U >), "header",
|
||||
fragment=SWIG_Traits_frag(T),
|
||||
fragment=SWIG_Traits_frag(U),
|
||||
fragment="StdPairTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::pair<T,U > > {
|
||||
typedef pointer_category category;
|
||||
static const char* type_name() {
|
||||
return "std::pair<" #T "," #U " >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef SWIG_STD_PAIR_ASVAL
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_PAIR, std::pair<T,U >);
|
||||
#else
|
||||
%typemap_traits(SWIG_TYPECHECK_PAIR, std::pair<T,U >);
|
||||
#endif
|
||||
|
||||
pair();
|
||||
pair(T first, U second);
|
||||
pair(const pair& p);
|
||||
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &p);
|
||||
|
||||
T first;
|
||||
U second;
|
||||
|
||||
#ifdef %swig_pair_methods
|
||||
// Add swig/language extra methods
|
||||
%swig_pair_methods(std::pair<T,U >)
|
||||
#endif
|
||||
};
|
||||
|
||||
// ***
|
||||
// The following specializations should dissapear or get
|
||||
// simplified when a 'const SWIGTYPE*&' can be defined
|
||||
// ***
|
||||
template <class T, class U > struct pair<T, U*> {
|
||||
typedef T first_type;
|
||||
typedef U* second_type;
|
||||
|
||||
%traits_swigtype(T);
|
||||
%traits_swigtype(U);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::pair<T,U* >), "header",
|
||||
fragment=SWIG_Traits_frag(T),
|
||||
fragment=SWIG_Traits_frag(U),
|
||||
fragment="StdPairTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::pair<T,U* > > {
|
||||
typedef pointer_category category;
|
||||
static const char* type_name() {
|
||||
return "std::pair<" #T "," #U " * >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_PAIR, std::pair<T,U* >);
|
||||
|
||||
pair();
|
||||
pair(T __a, U* __b);
|
||||
pair(const pair& __p);
|
||||
|
||||
T first;
|
||||
U* second;
|
||||
|
||||
#ifdef %swig_pair_methods
|
||||
// Add swig/language extra methods
|
||||
%swig_pair_methods(std::pair<T,U*>)
|
||||
#endif
|
||||
};
|
||||
|
||||
template <class T, class U > struct pair<T*, U> {
|
||||
typedef T* first_type;
|
||||
typedef U second_type;
|
||||
|
||||
%traits_swigtype(T);
|
||||
%traits_swigtype(U);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::pair<T*,U >), "header",
|
||||
fragment=SWIG_Traits_frag(T),
|
||||
fragment=SWIG_Traits_frag(U),
|
||||
fragment="StdPairTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::pair<T*,U > > {
|
||||
typedef pointer_category category;
|
||||
static const char* type_name() {
|
||||
return "std::pair<" #T " *," #U " >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_PAIR, std::pair<T*,U >);
|
||||
|
||||
pair();
|
||||
pair(T* __a, U __b);
|
||||
pair(const pair& __p);
|
||||
|
||||
T* first;
|
||||
U second;
|
||||
|
||||
#ifdef %swig_pair_methods
|
||||
// Add swig/language extra methods
|
||||
%swig_pair_methods(std::pair<T*,U >)
|
||||
#endif
|
||||
};
|
||||
|
||||
template <class T, class U > struct pair<T*, U*> {
|
||||
typedef T* first_type;
|
||||
typedef U* second_type;
|
||||
|
||||
%traits_swigtype(T);
|
||||
%traits_swigtype(U);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::pair<T*,U* >), "header",
|
||||
fragment=SWIG_Traits_frag(T),
|
||||
fragment=SWIG_Traits_frag(U),
|
||||
fragment="StdPairTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::pair<T*,U* > > {
|
||||
typedef pointer_category category;
|
||||
static const char* type_name() {
|
||||
return "std::pair<" #T " *," #U " * >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap_traits(SWIG_TYPECHECK_PAIR, std::pair<T*,U* >);
|
||||
|
||||
pair();
|
||||
pair(T* __a, U* __b);
|
||||
pair(const pair& __p);
|
||||
|
||||
T* first;
|
||||
U* second;
|
||||
|
||||
#ifdef %swig_pair_methods
|
||||
// Add swig/language extra methods
|
||||
%swig_pair_methods(std::pair<T*,U*>)
|
||||
#endif
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
/**
|
||||
* @file std_queue.i
|
||||
* @date Sun May 6 01:48:07 2007
|
||||
*
|
||||
* @brief A wrapping of std::queue for Ruby.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
%include <std_container.i>
|
||||
|
||||
// Queue
|
||||
|
||||
%define %std_queue_methods(queue...)
|
||||
queue();
|
||||
queue( const _Sequence& );
|
||||
|
||||
bool empty() const;
|
||||
size_type size() const;
|
||||
const value_type& front() const;
|
||||
const value_type& back() const;
|
||||
void pop();
|
||||
void push( const value_type& );
|
||||
%enddef
|
||||
|
||||
%define %std_queue_methods_val(queue...)
|
||||
%std_queue_methods(queue)
|
||||
%enddef
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// std::queue
|
||||
//
|
||||
// const declarations are used to guess the intent of the function being
|
||||
// exported; therefore, the following rationale is applied:
|
||||
//
|
||||
// -- f(std::queue<T>), f(const std::queue<T>&):
|
||||
// the parameter being read-only, either a sequence or a
|
||||
// previously wrapped std::queue<T> can be passed.
|
||||
// -- f(std::queue<T>&), f(std::queue<T>*):
|
||||
// the parameter may be modified; therefore, only a wrapped std::queue
|
||||
// can be passed.
|
||||
// -- std::queue<T> f(), const std::queue<T>& f():
|
||||
// the queue is returned by copy; therefore, a sequence of T:s
|
||||
// is returned which is most easily used in other functions
|
||||
// -- std::queue<T>& f(), std::queue<T>* f():
|
||||
// the queue is returned by reference; therefore, a wrapped std::queue
|
||||
// is returned
|
||||
// -- const std::queue<T>* f(), f(const std::queue<T>*):
|
||||
// for consistency, they expect and return a plain queue pointer.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
%{
|
||||
#include <queue>
|
||||
%}
|
||||
|
||||
// exported classes
|
||||
|
||||
namespace std {
|
||||
|
||||
template<class _Tp, class _Sequence = std::deque<_Tp> >
|
||||
class queue {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef _Tp value_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef _Sequence container_type;
|
||||
|
||||
%traits_swigtype(_Tp);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::queue<_Tp, _Sequence >), "header",
|
||||
fragment=SWIG_Traits_frag(_Tp),
|
||||
fragment="StdQueueTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::queue<_Tp, _Sequence > > {
|
||||
typedef pointer_category category;
|
||||
static const char* type_name() {
|
||||
return "std::queue<" #_Tp "," #_Sequence " >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_QUEUE, std::queue<_Tp, _Sequence >);
|
||||
|
||||
#ifdef %swig_queue_methods
|
||||
// Add swig/language extra methods
|
||||
%swig_queue_methods(std::queue<_Tp, _Sequence >);
|
||||
#endif
|
||||
|
||||
%std_queue_methods(queue);
|
||||
};
|
||||
|
||||
template<class _Tp, class _Sequence >
|
||||
class queue<_Tp*, _Sequence > {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef _Tp value_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef _Sequence container_type;
|
||||
|
||||
%traits_swigtype(_Tp);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::queue<_Tp*, _Sequence >), "header",
|
||||
fragment=SWIG_Traits_frag(_Tp),
|
||||
fragment="StdQueueTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::queue<_Tp*, _Sequence > > {
|
||||
typedef value_category category;
|
||||
static const char* type_name() {
|
||||
return "std::queue<" #_Tp "," #_Sequence " * >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_QUEUE, std::queue<_Tp*, _Sequence >);
|
||||
|
||||
#ifdef %swig_queue_methods_val
|
||||
// Add swig/language extra methods
|
||||
%swig_queue_methods_val(std::queue<_Tp*, _Sequence >);
|
||||
#endif
|
||||
|
||||
%std_queue_methods_val(std::queue<_Tp*, _Sequence >);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
//
|
||||
// std::set
|
||||
//
|
||||
|
||||
%include <std_container.i>
|
||||
%include <std_pair.i>
|
||||
|
||||
// Set
|
||||
%define %std_set_methods_common(set...)
|
||||
set();
|
||||
set( const set& );
|
||||
|
||||
bool empty() const;
|
||||
size_type size() const;
|
||||
void clear();
|
||||
|
||||
void swap(set& v);
|
||||
|
||||
|
||||
size_type erase(const key_type& x);
|
||||
size_type count(const key_type& x) const;
|
||||
|
||||
#ifdef SWIG_EXPORT_ITERATOR_METHODS
|
||||
class iterator;
|
||||
class reverse_iterator;
|
||||
|
||||
iterator begin();
|
||||
iterator end();
|
||||
reverse_iterator rbegin();
|
||||
reverse_iterator rend();
|
||||
|
||||
void erase(iterator pos);
|
||||
void erase(iterator first, iterator last);
|
||||
|
||||
iterator find(const key_type& x);
|
||||
iterator lower_bound(const key_type& x);
|
||||
iterator upper_bound(const key_type& x);
|
||||
std::pair<iterator,iterator> equal_range(const key_type& x);
|
||||
#endif
|
||||
%enddef
|
||||
|
||||
%define %std_set_methods(set...)
|
||||
%std_set_methods_common(set);
|
||||
#ifdef SWIG_EXPORT_ITERATOR_METHODS
|
||||
std::pair<iterator,bool> insert(const value_type& __x);
|
||||
#endif
|
||||
%enddef
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// std::set
|
||||
//
|
||||
// const declarations are used to guess the intent of the function being
|
||||
// exported; therefore, the following rationale is applied:
|
||||
//
|
||||
// -- f(std::set<T>), f(const std::set<T>&):
|
||||
// the parameter being read-only, either a sequence or a
|
||||
// previously wrapped std::set<T> can be passed.
|
||||
// -- f(std::set<T>&), f(std::set<T>*):
|
||||
// the parameter may be modified; therefore, only a wrapped std::set
|
||||
// can be passed.
|
||||
// -- std::set<T> f(), const std::set<T>& f():
|
||||
// the set is returned by copy; therefore, a sequence of T:s
|
||||
// is returned which is most easily used in other functions
|
||||
// -- std::set<T>& f(), std::set<T>* f():
|
||||
// the set is returned by reference; therefore, a wrapped std::set
|
||||
// is returned
|
||||
// -- const std::set<T>* f(), f(const std::set<T>*):
|
||||
// for consistency, they expect and return a plain set pointer.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
%{
|
||||
#include <set>
|
||||
%}
|
||||
|
||||
// exported classes
|
||||
|
||||
namespace std {
|
||||
|
||||
template <class _Key, class _Compare = std::less<_Key>,
|
||||
class _Alloc = allocator<_Key> >
|
||||
class set {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef _Key value_type;
|
||||
typedef _Key key_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef _Alloc allocator_type;
|
||||
|
||||
%traits_swigtype(_Key);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::set<_Key, _Compare, _Alloc >), "header",
|
||||
fragment=SWIG_Traits_frag(_Key),
|
||||
fragment="StdSetTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::set<_Key, _Compare, _Alloc > > {
|
||||
typedef pointer_category category;
|
||||
static const char* type_name() {
|
||||
return "std::set<" #_Key "," #_Compare "," #_Alloc " >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_SET, std::set<_Key, _Compare, _Alloc >);
|
||||
|
||||
set( const _Compare& );
|
||||
|
||||
#ifdef %swig_set_methods
|
||||
// Add swig/language extra methods
|
||||
%swig_set_methods(std::set<_Key, _Compare, _Alloc >);
|
||||
#endif
|
||||
|
||||
%std_set_methods(set);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
/*
|
||||
For wchar support, you need to include the wchar.i file
|
||||
before this file, ie:
|
||||
|
||||
%include <wchar.i>
|
||||
%include <std_sstream.i>
|
||||
|
||||
or equivalently, just include
|
||||
|
||||
%include <std_wsstream.i>
|
||||
*/
|
||||
|
||||
%include <std_alloc.i>
|
||||
%include <std_basic_string.i>
|
||||
%include <std_string.i>
|
||||
%include <std_ios.i>
|
||||
#if defined(SWIG_WCHAR)
|
||||
%include <std_wstring.i>
|
||||
#endif
|
||||
%include <std_streambuf.i>
|
||||
%include <std_iostream.i>
|
||||
|
||||
%{
|
||||
#include <sstream>
|
||||
%}
|
||||
|
||||
|
||||
namespace std
|
||||
{
|
||||
template<typename _CharT, typename _Traits = char_traits<_CharT>,
|
||||
typename _Alloc = allocator<_CharT> >
|
||||
class basic_stringbuf : public basic_streambuf<_CharT, _Traits>
|
||||
{
|
||||
public:
|
||||
// Types:
|
||||
typedef _CharT char_type;
|
||||
typedef _Traits traits_type;
|
||||
// 251. basic_stringbuf missing allocator_type
|
||||
typedef _Alloc allocator_type;
|
||||
typedef typename traits_type::int_type int_type;
|
||||
typedef typename traits_type::pos_type pos_type;
|
||||
typedef typename traits_type::off_type off_type;
|
||||
|
||||
public:
|
||||
// Constructors:
|
||||
explicit
|
||||
basic_stringbuf(ios_base::openmode __mode = ios_base::in | ios_base::out);
|
||||
|
||||
explicit
|
||||
basic_stringbuf(const basic_string<_CharT, _Traits, _Alloc>& __str,
|
||||
ios_base::openmode __mode = ios_base::in | ios_base::out);
|
||||
|
||||
// Get and set:
|
||||
basic_string<_CharT, _Traits, _Alloc>
|
||||
str() const;
|
||||
|
||||
void
|
||||
str(const basic_string<_CharT, _Traits, _Alloc>& __s);
|
||||
|
||||
};
|
||||
|
||||
|
||||
// 27.7.2 Template class basic_istringstream
|
||||
template<typename _CharT, typename _Traits = char_traits<_CharT>,
|
||||
typename _Alloc = allocator<_CharT> >
|
||||
class basic_istringstream : public basic_istream<_CharT, _Traits>
|
||||
{
|
||||
public:
|
||||
// Types:
|
||||
typedef _CharT char_type;
|
||||
typedef _Traits traits_type;
|
||||
// 251. basic_stringbuf missing allocator_type
|
||||
typedef _Alloc allocator_type;
|
||||
typedef typename traits_type::int_type int_type;
|
||||
typedef typename traits_type::pos_type pos_type;
|
||||
typedef typename traits_type::off_type off_type;
|
||||
|
||||
|
||||
public:
|
||||
// Constructors:
|
||||
explicit
|
||||
basic_istringstream(ios_base::openmode __mode = ios_base::in);
|
||||
|
||||
explicit
|
||||
basic_istringstream(const basic_string<_CharT, _Traits, _Alloc>& __str,
|
||||
ios_base::openmode __mode = ios_base::in);
|
||||
|
||||
~basic_istringstream();
|
||||
|
||||
// Members:
|
||||
basic_stringbuf<_CharT, _Traits, _Alloc>*
|
||||
rdbuf() const;
|
||||
|
||||
basic_string<_CharT, _Traits, _Alloc>
|
||||
str() const;
|
||||
|
||||
void
|
||||
str(const basic_string<_CharT, _Traits, _Alloc>& __s);
|
||||
};
|
||||
|
||||
|
||||
// 27.7.3 Template class basic_ostringstream
|
||||
template<typename _CharT, typename _Traits = char_traits<_CharT>,
|
||||
typename _Alloc = allocator<_CharT> >
|
||||
class basic_ostringstream : public basic_ostream<_CharT, _Traits>
|
||||
{
|
||||
public:
|
||||
// Types:
|
||||
typedef _CharT char_type;
|
||||
typedef _Traits traits_type;
|
||||
// 251. basic_stringbuf missing allocator_type
|
||||
typedef _Alloc allocator_type;
|
||||
typedef typename traits_type::int_type int_type;
|
||||
typedef typename traits_type::pos_type pos_type;
|
||||
typedef typename traits_type::off_type off_type;
|
||||
|
||||
|
||||
public:
|
||||
// Constructors/destructor:
|
||||
explicit
|
||||
basic_ostringstream(ios_base::openmode __mode = ios_base::out);
|
||||
|
||||
explicit
|
||||
basic_ostringstream(const basic_string<_CharT, _Traits, _Alloc>& __str,
|
||||
ios_base::openmode __mode = ios_base::out);
|
||||
|
||||
~basic_ostringstream();
|
||||
|
||||
// Members:
|
||||
basic_stringbuf<_CharT, _Traits, _Alloc>*
|
||||
rdbuf() const;
|
||||
|
||||
basic_string<_CharT, _Traits, _Alloc>
|
||||
str() const;
|
||||
|
||||
#if 0
|
||||
void
|
||||
str(const basic_string<_CharT, _Traits, _Alloc>& __s);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
// 27.7.4 Template class basic_stringstream
|
||||
template<typename _CharT, typename _Traits = char_traits<_CharT>,
|
||||
typename _Alloc = allocator<_CharT> >
|
||||
class basic_stringstream : public basic_iostream<_CharT, _Traits>
|
||||
{
|
||||
public:
|
||||
// Types:
|
||||
typedef _CharT char_type;
|
||||
typedef _Traits traits_type;
|
||||
// 251. basic_stringbuf missing allocator_type
|
||||
typedef _Alloc allocator_type;
|
||||
typedef typename traits_type::int_type int_type;
|
||||
typedef typename traits_type::pos_type pos_type;
|
||||
typedef typename traits_type::off_type off_type;
|
||||
|
||||
public:
|
||||
// Constructors/destructors
|
||||
explicit
|
||||
basic_stringstream(ios_base::openmode __m = ios_base::out | ios_base::in);
|
||||
|
||||
explicit
|
||||
basic_stringstream(const basic_string<_CharT, _Traits, _Alloc>& __str,
|
||||
ios_base::openmode __m = ios_base::out | ios_base::in);
|
||||
|
||||
~basic_stringstream();
|
||||
|
||||
// Members:
|
||||
basic_stringbuf<_CharT, _Traits, _Alloc>*
|
||||
rdbuf() const;
|
||||
|
||||
basic_string<_CharT, _Traits, _Alloc>
|
||||
str() const;
|
||||
|
||||
void
|
||||
str(const basic_string<_CharT, _Traits, _Alloc>& __s);
|
||||
};
|
||||
|
||||
|
||||
} // namespace std
|
||||
|
||||
|
||||
namespace std {
|
||||
%template(istringstream) basic_istringstream<char>;
|
||||
%template(ostringstream) basic_ostringstream<char>;
|
||||
%template(stringstream) basic_stringstream<char>;
|
||||
|
||||
|
||||
#if defined(SWIG_WCHAR)
|
||||
%template(wistringstream) basic_istringstream<wchar_t>;
|
||||
%template(wostringstream) basic_ostringstream<wchar_t>;
|
||||
%template(wstringstream) basic_stringstream<wchar_t>;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
/**
|
||||
* @file std_stack.i
|
||||
* @date Sun May 6 01:48:07 2007
|
||||
*
|
||||
* @brief A wrapping of std::stack for Ruby.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
%include <std_container.i>
|
||||
|
||||
// Stack
|
||||
|
||||
%define %std_stack_methods(stack...)
|
||||
stack();
|
||||
stack( const _Sequence& );
|
||||
|
||||
bool empty() const;
|
||||
size_type size() const;
|
||||
const value_type& top() const;
|
||||
void pop();
|
||||
void push( const value_type& );
|
||||
%enddef
|
||||
|
||||
%define %std_stack_methods_val(stack...)
|
||||
%std_stack_methods(stack)
|
||||
%enddef
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// std::stack
|
||||
//
|
||||
// const declarations are used to guess the intent of the function being
|
||||
// exported; therefore, the following rationale is applied:
|
||||
//
|
||||
// -- f(std::stack<T>), f(const std::stack<T>&):
|
||||
// the parameter being read-only, either a sequence or a
|
||||
// previously wrapped std::stack<T> can be passed.
|
||||
// -- f(std::stack<T>&), f(std::stack<T>*):
|
||||
// the parameter may be modified; therefore, only a wrapped std::stack
|
||||
// can be passed.
|
||||
// -- std::stack<T> f(), const std::stack<T>& f():
|
||||
// the stack is returned by copy; therefore, a sequence of T:s
|
||||
// is returned which is most easily used in other functions
|
||||
// -- std::stack<T>& f(), std::stack<T>* f():
|
||||
// the stack is returned by reference; therefore, a wrapped std::stack
|
||||
// is returned
|
||||
// -- const std::stack<T>* f(), f(const std::stack<T>*):
|
||||
// for consistency, they expect and return a plain stack pointer.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
%{
|
||||
#include <stack>
|
||||
%}
|
||||
|
||||
// exported classes
|
||||
|
||||
namespace std {
|
||||
|
||||
template<class _Tp, class _Sequence = std::deque<_Tp> >
|
||||
class stack {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef _Tp value_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef _Sequence container_type;
|
||||
|
||||
%traits_swigtype(_Tp);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::stack<_Tp, _Sequence >), "header",
|
||||
fragment=SWIG_Traits_frag(_Tp),
|
||||
fragment="StdStackTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::stack<_Tp, _Sequence > > {
|
||||
typedef pointer_category category;
|
||||
static const char* type_name() {
|
||||
return "std::stack<" #_Tp "," #_Sequence " >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_STACK, std::stack<_Tp, _Sequence >);
|
||||
|
||||
#ifdef %swig_stack_methods
|
||||
// Add swig/language extra methods
|
||||
%swig_stack_methods(std::stack<_Tp, _Sequence >);
|
||||
#endif
|
||||
|
||||
%std_stack_methods(stack);
|
||||
};
|
||||
|
||||
template<class _Tp, class _Sequence >
|
||||
class stack<_Tp*, _Sequence > {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef _Sequence::value_type value_type;
|
||||
typedef value_type reference;
|
||||
typedef value_type const_reference;
|
||||
typedef _Sequence container_type;
|
||||
|
||||
%traits_swigtype(_Tp);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::stack<_Tp*, _Sequence >), "header",
|
||||
fragment=SWIG_Traits_frag(_Tp),
|
||||
fragment="StdStackTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::stack<_Tp*, _Sequence > > {
|
||||
typedef value_category category;
|
||||
static const char* type_name() {
|
||||
return "std::stack<" #_Tp "," #_Sequence " * >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_STACK, std::stack<_Tp*, _Sequence >);
|
||||
|
||||
#ifdef %swig_stack_methods_val
|
||||
// Add swig/language extra methods
|
||||
%swig_stack_methods_val(std::stack<_Tp*, _Sequence >);
|
||||
#endif
|
||||
|
||||
%std_stack_methods_val(std::stack<_Tp*, _Sequence >);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
%include <std_ios.i>
|
||||
%{
|
||||
#ifndef SWIG_STD_NOMODERN_STL
|
||||
#include <streambuf>
|
||||
#else
|
||||
#include <streambuf.h>
|
||||
#endif
|
||||
%}
|
||||
|
||||
namespace std {
|
||||
|
||||
template<typename _CharT, typename _Traits = char_traits<_CharT> >
|
||||
class basic_streambuf
|
||||
{
|
||||
public:
|
||||
// Types:
|
||||
typedef _CharT char_type;
|
||||
typedef _Traits traits_type;
|
||||
typedef typename traits_type::int_type int_type;
|
||||
typedef typename traits_type::pos_type pos_type;
|
||||
typedef typename traits_type::off_type off_type;
|
||||
|
||||
public:
|
||||
virtual
|
||||
~basic_streambuf();
|
||||
|
||||
// Locales:
|
||||
locale
|
||||
pubimbue(const locale &__loc);
|
||||
|
||||
locale
|
||||
getloc() const;
|
||||
|
||||
// Buffer and positioning:
|
||||
basic_streambuf<_CharT, _Traits>*
|
||||
pubsetbuf(char_type* __s, streamsize __n);
|
||||
|
||||
pos_type
|
||||
pubseekoff(off_type __off, ios_base::seekdir __way,
|
||||
ios_base::openmode __mode = std::ios_base::in | std::ios_base::out);
|
||||
|
||||
pos_type
|
||||
pubseekpos(pos_type __sp,
|
||||
ios_base::openmode __mode = std::ios_base::in | std::ios_base::out);
|
||||
|
||||
int
|
||||
pubsync() ;
|
||||
|
||||
// Get and put areas:
|
||||
// Get area:
|
||||
streamsize
|
||||
in_avail();
|
||||
|
||||
int_type
|
||||
snextc();
|
||||
|
||||
int_type
|
||||
sbumpc();
|
||||
|
||||
int_type
|
||||
sgetc();
|
||||
|
||||
streamsize
|
||||
sgetn(char_type* __s, streamsize __n);
|
||||
|
||||
// Putback:
|
||||
int_type
|
||||
sputbackc(char_type __c);
|
||||
|
||||
int_type
|
||||
sungetc();
|
||||
|
||||
// Put area:
|
||||
int_type
|
||||
sputc(char_type __c);
|
||||
|
||||
streamsize
|
||||
sputn(const char_type* __s, streamsize __n);
|
||||
|
||||
protected:
|
||||
basic_streambuf();
|
||||
|
||||
private:
|
||||
basic_streambuf(const basic_streambuf&);
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
namespace std {
|
||||
%template(streambuf) basic_streambuf<char>;
|
||||
#if defined(SWIG_WCHAR)
|
||||
%template(wstreambuf) basic_streambuf<wchar_t>;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
%include <std/std_basic_string.i>
|
||||
|
||||
/* plain strings */
|
||||
|
||||
namespace std
|
||||
{
|
||||
%std_comp_methods(basic_string<char>);
|
||||
%naturalvar string;
|
||||
typedef basic_string<char> string;
|
||||
}
|
||||
|
||||
|
||||
%template(string) std::basic_string<char>;
|
||||
@@ -0,0 +1,184 @@
|
||||
//
|
||||
// std::vector
|
||||
//
|
||||
|
||||
%include <std_container.i>
|
||||
|
||||
// Vector
|
||||
|
||||
%define %std_vector_methods(vector...)
|
||||
%std_sequence_methods(vector)
|
||||
|
||||
void reserve(size_type n);
|
||||
size_type capacity() const;
|
||||
%enddef
|
||||
|
||||
|
||||
%define %std_vector_methods_val(vector...)
|
||||
%std_sequence_methods_val(vector)
|
||||
|
||||
void reserve(size_type n);
|
||||
size_type capacity() const;
|
||||
%enddef
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// std::vector
|
||||
//
|
||||
// The aim of all that follows would be to integrate std::vector with
|
||||
// as much as possible, namely, to allow the user to pass and
|
||||
// be returned tuples or lists.
|
||||
// const declarations are used to guess the intent of the function being
|
||||
// exported; therefore, the following rationale is applied:
|
||||
//
|
||||
// -- f(std::vector<T>), f(const std::vector<T>&):
|
||||
// the parameter being read-only, either a sequence or a
|
||||
// previously wrapped std::vector<T> can be passed.
|
||||
// -- f(std::vector<T>&), f(std::vector<T>*):
|
||||
// the parameter may be modified; therefore, only a wrapped std::vector
|
||||
// can be passed.
|
||||
// -- std::vector<T> f(), const std::vector<T>& f():
|
||||
// the vector is returned by copy; therefore, a sequence of T:s
|
||||
// is returned which is most easily used in other functions
|
||||
// -- std::vector<T>& f(), std::vector<T>* f():
|
||||
// the vector is returned by reference; therefore, a wrapped std::vector
|
||||
// is returned
|
||||
// -- const std::vector<T>* f(), f(const std::vector<T>*):
|
||||
// for consistency, they expect and return a plain vector pointer.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
%{
|
||||
#include <vector>
|
||||
%}
|
||||
|
||||
// exported classes
|
||||
|
||||
|
||||
namespace std {
|
||||
|
||||
template<class _Tp, class _Alloc = allocator< _Tp > >
|
||||
class vector {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef _Tp value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef _Tp& reference;
|
||||
typedef const _Tp& const_reference;
|
||||
typedef _Alloc allocator_type;
|
||||
|
||||
%traits_swigtype(_Tp);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::vector<_Tp, _Alloc >), "header",
|
||||
fragment=SWIG_Traits_frag(_Tp),
|
||||
fragment="StdVectorTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::vector<_Tp, _Alloc > > {
|
||||
typedef pointer_category category;
|
||||
static const char* type_name() {
|
||||
return "std::vector<" #_Tp "," #_Alloc " >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<_Tp, _Alloc >);
|
||||
|
||||
#ifdef %swig_vector_methods
|
||||
// Add swig/language extra methods
|
||||
%swig_vector_methods(std::vector<_Tp, _Alloc >);
|
||||
#endif
|
||||
|
||||
%std_vector_methods(vector);
|
||||
};
|
||||
|
||||
// ***
|
||||
// This specialization should dissapear or get simplified when
|
||||
// a 'const SWIGTYPE*&' can be defined
|
||||
// ***
|
||||
template<class _Tp, class _Alloc >
|
||||
class vector<_Tp*, _Alloc > {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef _Tp* value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type reference;
|
||||
typedef value_type const_reference;
|
||||
typedef _Alloc allocator_type;
|
||||
|
||||
%traits_swigtype(_Tp);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::vector<_Tp*, _Alloc >), "header",
|
||||
fragment=SWIG_Traits_frag(_Tp),
|
||||
fragment="StdVectorTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::vector<_Tp*, _Alloc > > {
|
||||
typedef value_category category;
|
||||
static const char* type_name() {
|
||||
return "std::vector<" #_Tp " *," #_Alloc " >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<_Tp*, _Alloc >);
|
||||
|
||||
#ifdef %swig_vector_methods_val
|
||||
// Add swig/language extra methods
|
||||
%swig_vector_methods_val(std::vector<_Tp*, _Alloc >);
|
||||
#endif
|
||||
|
||||
%std_vector_methods_val(vector);
|
||||
};
|
||||
|
||||
// ***
|
||||
// ***
|
||||
// bool specialization
|
||||
|
||||
template<class _Alloc >
|
||||
class vector<bool,_Alloc > {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef bool value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type reference;
|
||||
typedef value_type const_reference;
|
||||
typedef _Alloc allocator_type;
|
||||
|
||||
%traits_swigtype(bool);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::vector<bool, _Alloc >), "header",
|
||||
fragment=SWIG_Traits_frag(bool),
|
||||
fragment="StdVectorTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::vector<bool, _Alloc > > {
|
||||
typedef value_category category;
|
||||
static const char* type_name() {
|
||||
return "std::vector<bool, _Alloc >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<bool, _Alloc >);
|
||||
|
||||
|
||||
#ifdef %swig_vector_methods_val
|
||||
// Add swig/language extra methods
|
||||
%swig_vector_methods_val(std::vector<bool, _Alloc >);
|
||||
#endif
|
||||
|
||||
%std_vector_methods_val(vector);
|
||||
|
||||
#if defined(SWIG_STD_MODERN_STL) && !defined(SWIG_STD_NOMODERN_STL)
|
||||
void flip();
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
//
|
||||
// We keep this file only for backward compatibility, since std_vector.i
|
||||
// now uses the std::allocator parameter.
|
||||
//
|
||||
|
||||
%include <std_vector.i>
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
/*
|
||||
Provide 'std_ios.i' with wchar support.
|
||||
*/
|
||||
|
||||
%include <wchar.i>
|
||||
%include <std_ios.i>
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
/*
|
||||
Provide 'std_iostream.i' with wchar support.
|
||||
*/
|
||||
|
||||
%include <wchar.i>
|
||||
%include <std_iostream.i>
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
/*
|
||||
Provide 'std_sstream.i' with wchar support.
|
||||
*/
|
||||
|
||||
%include <wchar.i>
|
||||
%include <std_sstream.i>
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
/*
|
||||
Provide 'std_streambuf.i' with wchar support.
|
||||
*/
|
||||
|
||||
%include <wchar.i>
|
||||
%include <std_streambuf.i>
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
%include <wchar.i>
|
||||
%include <std/std_basic_string.i>
|
||||
|
||||
/* wide strings */
|
||||
|
||||
namespace std
|
||||
{
|
||||
%std_comp_methods(basic_string<wchar_t>);
|
||||
%naturalvar wstring;
|
||||
typedef basic_string<wchar_t> wstring;
|
||||
}
|
||||
|
||||
%template(wstring) std::basic_string<wchar_t>;
|
||||
|
||||
Reference in New Issue
Block a user