isolate language independent STD/STL/C++ code + more documentation + cleaning

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@6382 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2004-10-10 06:42:15 +00:00
commit a300b82163
50 changed files with 3502 additions and 3408 deletions

22
SWIG/Lib/std/README Normal file
View file

@ -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

View file

@ -0,0 +1,252 @@
%include <exception.i>
%include <std_container.i>
%include <std_char_traits.i>
%{
#include <string>
%}
namespace std {
template <class _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;
static const size_type npos;
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();
%swig_basic_string(std::basic_string<_CharT>);
#ifdef SWIG_EXPORT_ITERATOR_METHODS
iterator
insert(iterator __p, _CharT __c = _CharT());
iterator
erase(iterator __position);
iterator
erase(iterator __first, iterator __last);
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, const _CharT* __s);
basic_string&
replace(iterator __i1, iterator __i2, size_type __n, _CharT __c);
basic_string&
replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2);
basic_string&
replace(iterator __i1, iterator __i2, const _CharT* __k1, const _CharT* __k2);
basic_string&
replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2);
basic_string&
replace(iterator __i1, iterator __i2, const_iterator __k1, const_iterator __k2);
#endif
std::basic_string<_CharT>& operator +=(const basic_string& v);
%newobject __add__;
%newobject __radd__;
%extend {
std::basic_string<_CharT>* __add__(const basic_string& v) {
std::basic_string<_CharT>* res = new std::basic_string<_CharT>(*self);
*res += v;
return res;
}
std::basic_string<_CharT>* __radd__(const basic_string& v) {
std::basic_string<_CharT>* res = new std::basic_string<_CharT>(v);
*res += *self;
return res;
}
const std::basic_string<_CharT>& __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;
}
}
};
}

View file

@ -0,0 +1,132 @@
%include <std_common.i>
%include <wchar.i>
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);
};
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);
};
}
namespace std {
#ifndef SWIG_STL_WRAP_TRAITS
%template() char_traits<char>;
%template() char_traits<wchar_t>;
#else
%template(char_traits_c) char_traits<char>;
%template(char_traits_w) char_traits<wchar_t>;
#endif
}

236
SWIG/Lib/std/std_common.i Normal file
View file

@ -0,0 +1,236 @@
//
// 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)
#define SWIG_STD_NOASSIGN_STL
#define SWIG_STD_NOINSERT_TEMPLATE_STL
#endif
%}
//
// Common code for supporting the STD C++ namespace
//
%{
#include <string>
#include <stdexcept>
%}
%apply size_t { std::size_t };
%apply const size_t& { const std::size_t& };
%apply ptrdiff_t { std::ptrdiff_t }
%apply const ptrdiff_t& { const std::ptrdiff_t& }
%fragment("StdTraitsCommon","header")
%{
namespace swig {
/*
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<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>
struct noconst_traits {
typedef Type noconst_type;
};
template <class Type>
struct noconst_traits<const Type> {
typedef Type noconst_type;
};
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 traits for a 'primitive' type, such as 'double',
for which the SWIG_AsVal and SWIG_From methods are already defined.
*/
%define %traits_ptypen(Type...)
%fragment(SWIG_Traits_frag(Type),"header",
fragment=SWIG_AsVal_frag(Type),
fragment=SWIG_From_frag(Type),
fragment="StdTraits") {
namespace swig {
template <> struct traits<Type > {
typedef value_category category;
static const char* type_name() { return #Type; }
};
template <> struct traits_asval<Type > {
typedef Type value_type;
static int asval(PyObject *obj, value_type *val) {
return SWIG_AsVal(Type)(obj, val);
}
};
template <> struct traits_from<Type > {
typedef Type value_type;
static PyObject *from(const value_type& val) {
return SWIG_From(Type)(val);
}
};
}
}
%enddef
%apply_cpptypes(%traits_ptypen);
/*
Generate the typemaps for a class that has 'value' traits
*/
%define %typemap_traits(Code,Type...)
%typemap_ascheckfrom(SWIG_arg(Code),
SWIG_arg(swig::as<Type >),
SWIG_arg(swig::check<Type >),
SWIG_arg(swig::from),
SWIG_arg(SWIG_Traits_frag(Type)),
SWIG_arg(SWIG_Traits_frag(Type)),
SWIG_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...)
%typemap_asptrfrom(SWIG_arg(Code),
SWIG_arg(swig::asptr),
SWIG_arg(swig::from),
SWIG_arg(SWIG_Traits_frag(Type)),
SWIG_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

View file

@ -0,0 +1,106 @@
%include <std_common.i>
%include <exception.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);
#ifdef SWIG_EXPORT_ITERATOR_METHODS
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(SWIG_arg(sequence));
sequence(size_type size);
void pop_back();
void resize(size_type new_size);
#ifdef SWIG_EXPORT_ITERATOR_METHODS
iterator insert(iterator pos);
iterator erase(iterator pos);
iterator erase(iterator first, iterator last);
#endif
%enddef
%define %std_sequence_methods(sequence)
%std_sequence_methods_common(SWIG_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(SWIG_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

115
SWIG/Lib/std/std_deque.i Normal file
View file

@ -0,0 +1,115 @@
//
// 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 T > class deque {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
%traits_swigtype(T);
%fragment(SWIG_Traits_frag(std::deque<T >), "header",
fragment=SWIG_Traits_frag(T),
fragment="StdDequeTraits") {
namespace swig {
template <> struct traits<std::deque<T > > {
typedef pointer_category category;
static const char* type_name() {
return "std::deque<" #T " >";
}
};
}
}
%typemap_traits_ptr(SWIG_TYPECHECK_DEQUE, std::deque<T >);
%std_deque_methods(deque);
%swig_deque_methods(std::deque<T >);
};
template<class T > class deque<T*> {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T* value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type reference;
typedef value_type const_reference;
%traits_swigtype(T);
%fragment(SWIG_Traits_frag(std::deque<T* >), "header",
fragment=SWIG_Traits_frag(T),
fragment="StdDequeTraits") {
namespace swig {
template <> struct traits<std::deque<T* > > {
typedef value_category category;
static const char* type_name() {
return "std::deque<" #T " * >";
}
};
}
}
%typemap_traits_ptr(SWIG_TYPECHECK_DEQUE, std::deque<T* >);
%std_deque_methods_val(std::deque<T* >);
%swig_deque_methods_val(std::deque<T* >);
};
}

79
SWIG/Lib/std/std_except.i Normal file
View file

@ -0,0 +1,79 @@
%include <std_string.i>
%include <exception.i>
%{
#include <stdexcept>
%}
namespace std {
/* Mark all of them as exception classes */
%feature("exceptionclass") exception;
%feature("exceptionclass") bad_exception;
%feature("exceptionclass") logic_error;
%feature("exceptionclass") domain_error;
%feature("exceptionclass") invalid_argument;
%feature("exceptionclass") length_error;
%feature("exceptionclass") out_of_range;
%feature("exceptionclass") runtime_error;
%feature("exceptionclass") range_error;
%feature("exceptionclass") overflow_error;
%feature("exceptionclass") underflow_error;
}
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);
};
}

247
SWIG/Lib/std/std_ios.i Normal file
View file

@ -0,0 +1,247 @@
%include <std_except.i>
%include <std_char_traits.i>
%{
#include <ios>
%}
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();
};
template<typename _CharT, typename _Traits >
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, std::char_traits<char> >;
%template(wios) basic_ios<wchar_t, std::char_traits<wchar_t> >;
}

328
SWIG/Lib/std/std_iostream.i Normal file
View file

@ -0,0 +1,328 @@
%include <std_ios.i>
%include <std_string.i>
%include <std_wstring.i>
%{
#include <iostream>
%}
namespace std
{
%feature("immutable") cin;
%feature("immutable") cout;
%feature("immutable") cerr;
%feature("immutable") clog;
%feature("immutable") wcin;
%feature("immutable") wcout;
%feature("immutable") wcerr;
%feature("immutable") wclog;
}
namespace std
{
// 27.6.2.1 Template class basic_ostream
template<typename _CharT, typename _Traits>
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);
// 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);
%extend {
std::basic_ostream<_CharT, _Traits>&
operator<<(const std::basic_string<_CharT>& s)
{
*self << s;
return *self;
}
}
};
// 27.6.1.1 Template class basic_istream
template<typename _CharT, typename _Traits>
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>
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, std::char_traits<char> > ostream ;
typedef basic_istream<char, std::char_traits<char> > istream;
typedef basic_iostream<char, std::char_traits<char> > iostream;
typedef basic_ostream<wchar_t, std::char_traits<wchar_t> > wostream;
typedef basic_istream<wchar_t, std::char_traits<wchar_t> > wistream;
typedef basic_iostream<wchar_t, std::char_traits<wchar_t> > wiostream;
extern std::istream cin;
extern std::ostream cout;
extern std::ostream cerr;
extern std::ostream clog;
extern std::wistream wcin;
extern std::wostream wcout;
extern std::wostream wcerr;
extern std::wostream wclog;
template<typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
endl(std::basic_ostream<_CharT, _Traits>&);
template<typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
ends(std::basic_ostream<_CharT, _Traits>&);
template<typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
flush(std::basic_ostream<_CharT, _Traits>&);
}
namespace std {
%template(ostream) basic_ostream<char, std::char_traits<char> >;
%template(istream) basic_istream<char, std::char_traits<char> >;
%template(iostream) basic_iostream<char, std::char_traits<char> >;
%template(wostream) basic_ostream<wchar_t, std::char_traits<wchar_t> >;
%template(wistream) basic_istream<wchar_t, std::char_traits<wchar_t> >;
%template(wiostream) basic_iostream<wchar_t, std::char_traits<wchar_t> >;
%template(endl) endl<char, std::char_traits<char> >;
%template(ends) ends<char, std::char_traits<char> >;
%template(flush) flush<char, std::char_traits<char> >;
%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> >;
}

136
SWIG/Lib/std/std_list.i Normal file
View file

@ -0,0 +1,136 @@
//
// 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 T > class list {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
%traits_swigtype(T);
%fragment(SWIG_Traits_frag(std::list<T >), "header",
fragment=SWIG_Traits_frag(T),
fragment="StdListTraits") {
namespace swig {
template <> struct traits<std::list<T > > {
typedef pointer_category category;
static const char* type_name() {
return "std::list<" #T " >";
}
};
}
}
%typemap_traits_ptr(SWIG_TYPECHECK_LIST, std::list<T >);
%std_list_methods(list);
%swig_list_methods(std::list<T >);
};
template<class T > class list<T*> {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T* value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type reference;
typedef value_type const_reference;
%traits_swigtype(T);
%fragment(SWIG_Traits_frag(std::list<T* >), "header",
fragment=SWIG_Traits_frag(T),
fragment="StdListTraits") {
namespace swig {
template <> struct traits<std::list<T* > > {
typedef value_category category;
static const char* type_name() {
return "std::list<" #T " * >";
}
};
}
}
%typemap_traits_ptr(SWIG_TYPECHECK_LIST, std::list<T* >);
%std_list_methods_val(list);
%swig_list_methods_val(std::list<T* >);
};
}
%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

118
SWIG/Lib/std/std_map.i Normal file
View file

@ -0,0 +1,118 @@
//
// 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);
const_iterator find(const key_type& x) const;
iterator lower_bound(const key_type& x);
const_iterator lower_bound(const key_type& x) const;
iterator upper_bound(const key_type& x);
const_iterator upper_bound(const key_type& x) const;
#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
// **** Note ****
//
// If you are going to use a map, you need to instantiate both the
// map and the pair class:
//
// %template(pair_ii) std::pair<int, int>;
// %template(map_ii) std::map<int, int>;
//
// or
//
// %template() std::pair<int, int>;
// %template(map_ii) std::map<int, int>;
//
// **** Note ****
// ------------------------------------------------------------------------
// 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 K, class T> class map {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef K key_type;
typedef T mapped_type;
typedef std::pair<const K, T> value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
%traits_swigtype(K);
%traits_swigtype(T);
%fragment(SWIG_Traits_frag(std::map<K, T >), "header",
fragment=SWIG_Traits_frag(std::pair<K, T >),
fragment="StdMapTraits") {
namespace swig {
template <> struct traits<std::map<K, T > > {
typedef pointer_category category;
static const char* type_name() {
return "std::map<" #K "," #T " >";
}
};
}
}
%typemap_traits_ptr(SWIG_TYPECHECK_MAP, std::map<K, T >);
%std_map_methods(map);
%swig_map_methods(std::map<K, T >);
};
}

View file

@ -0,0 +1,80 @@
//
// std::map
//
%include <std_map.i>
%define %std_multimap_methods(mmap...)
%std_map_methods_common(mmap);
#ifdef SWIG_EXPORT_ITERATOR_METHODS
pair<iterator,bool> insert(const value_type& x);
pair<iterator,iterator> equal_range(const key_type& x);
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 K, class T> class multimap {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef K key_type;
typedef T mapped_type;
typedef std::pair<const K, T> value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
%traits_swigtype(K);
%traits_swigtype(T);
%fragment(SWIG_Traits_frag(std::multimap<K, T >), "header",
fragment=SWIG_Traits_frag(std::pair<K, T >),
fragment="StdMultimapTraits") {
namespace swig {
template <> struct traits<std::multimap<K, T > > {
typedef value_category category;
static const char* type_name() {
return "std::multimap<" #K "," #T " >";
}
};
}
}
%typemap_traits_ptr(SWIG_TYPECHECK_MULTIMAP, std::multimap<K, T >);
%std_multimap_methods(multimap);
%swig_multimap_methods(std::multimap<K, T >);
};
}

View file

@ -0,0 +1,78 @@
//
// std::set
//
%include <std_set.i>
// Multiset
%define %std_multiset_methods(multiset)
%std_set_methods_common(multiset);
#ifdef SWIG_EXPORT_ITERATOR_METHODS
pair<iterator,bool> insert(iterator pos);
#endif
%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 T > class multiset {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef T key_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
%traits_swigtype(T);
%fragment(SWIG_Traits_frag(std::multiset<T >), "header",
fragment=SWIG_Traits_frag(T),
fragment="StdMultisetTraits") {
namespace swig {
template <> struct traits<std::multiset<T > > {
typedef pointer_category category;
static const char* type_name() {
return "std::multiset<" #T " >";
}
};
}
}
%typemap_traits_ptr(SWIG_TYPECHECK_MULTISET, std::multiset<T >);
%std_multiset_methods(multiset);
%swig_container_methods(std::multiset<T >);
};
}

145
SWIG/Lib/std/std_pair.i Normal file
View file

@ -0,0 +1,145 @@
%include <std_common.i>
%{
#include <utility>
%}
namespace std {
template <class T, class U > struct pair {
typedef T fisrt_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;
%swig_pair_methods(std::pair<T,U >)
};
// ***
// 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 fisrt_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;
%swig_pair_methods(std::pair<T,U*>)
};
template <class T, class U > struct pair<T*, U> {
typedef T* fisrt_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;
%swig_pair_methods(std::pair<T*,U >)
};
template <class T, class U > struct pair<T*, U*> {
typedef T* fisrt_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;
%swig_pair_methods(std::pair<T*,U*>)
};
}

98
SWIG/Lib/std/std_set.i Normal file
View file

@ -0,0 +1,98 @@
//
// std::set
//
%include <std_container.i>
// Set
%define %std_set_methods_common(set)
%std_container_methods(set);
size_type erase(const key_type& x);
size_type count(const key_type& x) const;
#ifdef SWIG_EXPORT_ITERATOR_METHODS
iterator insert(iterator pos, const value_type& x);
void insert(iterator pos, size_type n, const value_type& x);
iterator erase(iterator pos);
iterator erase(iterator first, iterator last);
iterator find(const key_type& x) const;
iterator lower_bound(const key_type& x) const;
iterator upper_bound(const key_type& x) const;
std::pair<iterator,iterator> equal_range(const key_type& x);
iterator begin() const;
iterator end() const;
#endif
%enddef
%define %std_set_methods(set)
%std_set_methods_common(set);
#ifdef SWIG_EXPORT_ITERATOR_METHODS
pair<iterator,bool> insert(const value_type& __x);
iterator insert(iterator pos);
#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 T > class set {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef T key_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
%traits_swigtype(T);
%fragment(SWIG_Traits_frag(std::set<T >), "header",
fragment=SWIG_Traits_frag(T),
fragment="StdSetTraits") {
namespace swig {
template <> struct traits<std::set<T > > {
typedef pointer_category category;
static const char* type_name() {
return "std::set<" #T " >";
}
};
}
}
%typemap_traits_ptr(SWIG_TYPECHECK_SET, std::set<T >);
%std_set_methods(set);
%swig_set_methods(std::set<T >);
};
}

View file

@ -0,0 +1,87 @@
%include <std_ios.i>
%{
#include <streambuf>
%}
namespace std {
template<typename _CharT, typename _Traits>
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;
typedef basic_streambuf<char_type, traits_type> __streambuf_type;
public:
virtual
~basic_streambuf();
// Locales:
locale
pubimbue(const locale &__loc);
locale
getloc() const;
// Buffer and positioning:
__streambuf_type*
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();
};
}
namespace std {
%template(streambuf) basic_streambuf<char, char_traits<char> >;
%template(wstreambuf) basic_streambuf<wchar_t, char_traits<wchar_t> >;
}

170
SWIG/Lib/std/std_vector.i Normal file
View file

@ -0,0 +1,170 @@
//
// 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
#if !defined(SWIG_STD_MODERN_STL) || defined(SWIG_STD_NOMODERN_STL)
%ignore std::vector<bool>::flip();
#endif
namespace std {
template<class T > class vector {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef T& reference;
typedef const T& const_reference;
%traits_swigtype(T);
%fragment(SWIG_Traits_frag(std::vector<T >), "header",
fragment=SWIG_Traits_frag(T),
fragment="StdVectorTraits") {
namespace swig {
template <> struct traits<std::vector<T > > {
typedef pointer_category category;
static const char* type_name() {
return "std::vector<" #T " >";
}
};
}
}
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<T >);
%std_vector_methods(vector);
%swig_vector_methods(std::vector<T >);
};
// bool specialization
%extend vector<bool> {
void flip()
{
self->flip();
}
}
// ***
// This specialization should dissapear or get simplified when
// a 'const SWIGTYPE*&' can be defined
// ***
template<class T > class vector<T*> {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T* value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type reference;
typedef value_type const_reference;
%traits_swigtype(T);
%fragment(SWIG_Traits_frag(std::vector<T* >), "header",
fragment=SWIG_Traits_frag(T),
fragment="StdVectorTraits") {
namespace swig {
template <> struct traits<std::vector<T* > > {
typedef value_category category;
static const char* type_name() {
return "std::vector<" #T " * >";
}
};
}
}
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<T* >);
%std_vector_methods_val(vector);
%swig_vector_methods_val(std::vector<T* >);
};
// ***
// ***
template<class T > class vector<bool> {
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;
%traits_swigtype(bool);
%fragment(SWIG_Traits_frag(std::vector<bool>), "header",
fragment=SWIG_Traits_frag(bool),
fragment="StdVectorTraits") {
namespace swig {
template <> struct traits<std::vector<bool> > {
typedef value_category category;
static const char* type_name() {
return "std::vector<bool>";
}
};
}
}
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<bool>);
%std_vector_methods_val(vector<bool>);
%swig_vector_methods_val(std::vector<bool>);
};
}

137
SWIG/Lib/std/std_vectora.i Normal file
View file

@ -0,0 +1,137 @@
//
// std::vector<T,A>
//
//
// First attemp to add allocators. Still, the plain version
// works much better. So, if tyou don't need allocators, use
// std_vector.i instead.
//
%include <std_container.i>
// Vector
%define %std_vector_methods(vector...)
%std_sequence_methods(SWIG_arg(vector))
void reserve(size_type n);
size_type capacity() const;
%enddef
%define %std_vector_methods_val(vector...)
%std_sequence_methods_val(SWIG_arg(vector))
void reserve(size_type n);
size_type capacity() const;
%enddef
// ------------------------------------------------------------------------
// std::vector
//
// const declarations are used to guess the intent of the function being
// exported; therefore, the following rationale is applied:
//
// -- f(std::vector<T,A>), f(const std::vector<T,A>&):
// the parameter being read-only, either a sequence or a
// previously wrapped std::vector<T,A> can be passed.
// -- f(std::vector<T,A>&), f(std::vector<T,A>*):
// the parameter may be modified; therefore, only a wrapped std::vector
// can be passed.
// -- std::vector<T,A> f(), const std::vector<T,A>& 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,A>& f(), std::vector<T,A>* f():
// the vector is returned by reference; therefore, a wrapped std::vector
// is returned
// -- const std::vector<T,A>* f(), f(const std::vector<T,A>*):
// for consistency, they expect and return a plain vector pointer.
// ------------------------------------------------------------------------
%{
#include <vector>
%}
// exported classes
namespace std {
template<class T, class A = std::allocator<T > >
class vector {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef T& reference;
typedef const T& const_reference;
%traits_swigtype(T);
%fragment(SWIG_Traits_frag(std::vector<T,A >), "header",
fragment=SWIG_Traits_frag(T),
fragment="StdVectorATraits") {
namespace swig {
template <> struct traits<std::vector<T,A > > {
typedef pointer_category category;
static const char* type_name() {
return "std::vector<" #T "," #A " >";
}
};
}
}
%typemap_traits(SWIG_TYPECHECK_VECTOR, std::vector<T,A >);
%std_vector_methods(vector<T,A >);
%swig_vector_methods(std::vector<T,A >);
};
// ***
// This pointer especialization should dissapears or get
// simplified when a 'const SWIGTYPE*&' can be be defined.
// ***
template<class T, class A = std::allocator<T*> >
class vector<T*,A> {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T* value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type reference;
typedef value_type const_reference;
%traits_swigtype(T);
%fragment(SWIG_Traits_frag(std::vector<T*,A >), "header",
fragment="StdVectorATraits") {
namespace swig {
template <> struct traits<std::vector<T*,A > > {
typedef value_category category;
static const char* type_name() {
return "std::vector<" #T " *,"#A" >";
}
};
}
}
%typemap_traits(SWIG_TYPECHECK_VECTOR, std::vector<T*,A >);
%std_vector_methods_val(vector);
%swig_vector_methods_val(std::vector<T*,A >);
};
// bool specialization
%extend vector<bool,std::allocator<bool> > {
void flip()
{
self->flip();
}
}
}