added more elements from std

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@6282 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2004-10-02 01:39:15 +00:00
commit d3534ecc5a
4 changed files with 804 additions and 0 deletions

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
}

251
SWIG/Lib/python/std_ios.i Normal file
View file

@ -0,0 +1,251 @@
%include <std_except.i>
%include <std_char_traits.i>
%{
#include <ios>
%}
#ifdef SWIGPYTHON
%rename(ios_base_in) std::ios_base::in;
#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();
};
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> >;
}

View file

@ -0,0 +1,334 @@
%include <std_ios.i>
%include <std_string.i>
%include <std_wstring.i>
%{
#include <iostream>
%}
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.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();
};
}
namespace std {
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;
}
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> >;
}
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
{
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>&);
%pythoncallback(1);
%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> >;
%pythoncallback(0);
}

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> >;
}