1 // Special g++ Options: -fcheck-memory-usage
66 #define _IO_NEW_STREAMS
101 #define _G_LIB_VERSION "0.67"
102 #define _G_NAMES_HAVE_UNDERSCORE 1
103 #define _G_VTABLE_LABEL_HAS_LENGTH 1
104 #define _G_VTABLE_LABEL_PREFIX "__vt$"
105 #define _G_HAVE_ST_BLKSIZE 1
106 typedef long _G_clock_t;
107 typedef short _G_dev_t;
108 typedef long _G_fpos_t;
109 typedef unsigned short _G_gid_t;
110 typedef unsigned long _G_ino_t;
111 typedef unsigned short _G_mode_t;
112 typedef short _G_nlink_t;
113 typedef long _G_off_t;
114 typedef int _G_pid_t;
118 typedef int _G_ptrdiff_t;
119 typedef int _G_sigset_t;
123 typedef unsigned int _G_size_t;
124 typedef long _G_time_t;
125 typedef unsigned short _G_uid_t;
129 typedef __wchar_t _G_wchar_t;
130 typedef int _G_ssize_t;
131 typedef int _G_wint_t;
132 typedef char * _G_va_list;
133 #define _G_signal_return_type void
134 #define _G_sprintf_return_type char*
136 typedef signed char _G_int8_t;
138 typedef unsigned char _G_uint8_t;
139 typedef short _G_int16_t;
140 typedef unsigned short _G_uint16_t;
141 typedef long _G_int32_t;
142 typedef unsigned long _G_uint32_t;
145 typedef long long _G_int64_t;
146 typedef unsigned long long _G_uint64_t;
148 #define _G_BUFSIZ 1024
149 #define _G_FOPEN_MAX 32
150 #define _G_FILENAME_MAX 1024
153 #define _G_ARGS(ARGLIST) ARGLIST
163 #define _G_HAVE_ATEXIT 0
164 #define _G_HAVE_SYS_RESOURCE 1
165 #define _G_HAVE_SYS_SOCKET 1
166 #define _G_HAVE_SYS_WAIT 1
167 #define _G_HAVE_UNISTD 1
168 #define _G_HAVE_DIRENT 1
169 #define _G_HAVE_CURSES 1
170 #define _G_MATH_H_INLINES 0
171 #define _G_HAVE_BOOL 1
174 #define _IO_pos_t _G_fpos_t
175 #define _IO_fpos_t _G_fpos_t
176 #define _IO_size_t _G_size_t
177 #define _IO_ssize_t _G_ssize_t
178 #define _IO_off_t _G_off_t
179 #define _IO_pid_t _G_pid_t
180 #define _IO_uid_t _G_uid_t
181 #define _IO_HAVE_SYS_WAIT _G_HAVE_SYS_WAIT
182 #define _IO_HAVE_ST_BLKSIZE _G_HAVE_ST_BLKSIZE
183 #define _IO_BUFSIZ _G_BUFSIZ
184 #define _IO_va_list _G_va_list
193 #define __P(protos) protos
202 #define _PARAMS(protos) __P(protos)
208 #define _IO_UNIFIED_JUMPTABLES 1
210 #define _IO_USE_DTOA 1
219 #define NULL (__null)
230 #define _IOS_OUTPUT 2
232 #define _IOS_APPEND 8
233 #define _IOS_TRUNC 16
234 #define _IOS_NOCREATE 32
235 #define _IOS_NOREPLACE 64
244 #define _IO_MAGIC 0xFBAD0000
245 #define _OLD_STDIO_MAGIC 0xFABC0000
246 #define _IO_MAGIC_MASK 0xFFFF0000
247 #define _IO_USER_BUF 1
248 #define _IO_UNBUFFERED 2
249 #define _IO_NO_READS 4
250 #define _IO_NO_WRITES 8
251 #define _IO_EOF_SEEN 0x10
252 #define _IO_ERR_SEEN 0x20
253 #define _IO_DELETE_DONT_CLOSE 0x40
254 #define _IO_LINKED 0x80
255 #define _IO_IN_BACKUP 0x100
256 #define _IO_LINE_BUF 0x200
257 #define _IO_TIED_PUT_GET 0x400
258 #define _IO_CURRENTLY_PUTTING 0x800
259 #define _IO_IS_APPENDING 0x1000
260 #define _IO_IS_FILEBUF 0x2000
261 #define _IO_BAD_SEEN 0x4000
264 #define _IO_SKIPWS 01
267 #define _IO_INTERNAL 010
271 #define _IO_SHOWBASE 0200
272 #define _IO_SHOWPOINT 0400
273 #define _IO_UPPERCASE 01000
274 #define _IO_SHOWPOS 02000
275 #define _IO_SCIENTIFIC 04000
276 #define _IO_FIXED 010000
277 #define _IO_UNITBUF 020000
278 #define _IO_STDIO 040000
279 #define _IO_DONT_CLOSE 0100000
280 #define _IO_BOOLALPHA 0200000
283 struct _IO_jump_t; struct _IO_FILE;
295 typedef void _IO_lock_t;
304 struct _IO_marker *_next;
305 struct _IO_FILE *_sbuf;
315 #define _IO_file_flags _flags
322 char* _IO_write_base;
329 char *_IO_backup_base;
332 struct _IO_marker *_markers;
334 struct _IO_FILE *_chain;
340 #define __HAVE_COLUMN
342 unsigned short _cur_column;
357 struct _IO_FILE_plus;
358 extern struct _IO_FILE_plus _IO_stdin_, _IO_stdout_, _IO_stderr_;
359 #define _IO_stdin ((_IO_FILE*)(&_IO_stdin_))
360 #define _IO_stdout ((_IO_FILE*)(&_IO_stdout_))
361 #define _IO_stderr ((_IO_FILE*)(&_IO_stderr_))
367 _G_ssize_t (*read) (struct _IO_FILE *, void *, _G_ssize_t ) ;
368 _G_ssize_t (*write) (struct _IO_FILE *, const void *, _G_ssize_t ) ;
369 _G_fpos_t (*seek) (struct _IO_FILE *, _G_off_t , int) ;
370 int (*close) (struct _IO_FILE *) ;
371 } _IO_cookie_io_functions_t;
374 struct _IO_cookie_file
376 struct _IO_FILE file;
379 _IO_cookie_io_functions_t io_functions;
387 extern int __underflow (_IO_FILE *) ;
388 extern int __uflow (_IO_FILE *) ;
389 extern int __overflow (_IO_FILE *, int) ;
391 #define _IO_getc_unlocked(_fp) ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end ? __uflow (_fp) : *(unsigned char *) (_fp)->_IO_read_ptr++)
394 #define _IO_peekc_unlocked(_fp) ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end && __underflow (_fp) == EOF ? EOF : *(unsigned char *) (_fp)->_IO_read_ptr)
399 #define _IO_putc_unlocked(_ch, _fp) (((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end) ? __overflow (_fp, (unsigned char) (_ch)) : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch)))
404 #define _IO_feof_unlocked(__fp) (((__fp)->_flags & _IO_EOF_SEEN) != 0)
405 #define _IO_ferror_unlocked(__fp) (((__fp)->_flags & _IO_ERR_SEEN) != 0)
407 extern int _IO_getc (_IO_FILE *__fp) ;
408 extern int _IO_putc (int __c, _IO_FILE *__fp) ;
409 extern int _IO_feof (_IO_FILE *__fp) ;
410 extern int _IO_ferror (_IO_FILE *__fp) ;
412 extern int _IO_peekc_locked (_IO_FILE *__fp) ;
415 #define _IO_PENDING_OUTPUT_COUNT(_fp) ((_fp)->_IO_write_ptr - (_fp)->_IO_write_base)
418 extern void _IO_flockfile (_IO_FILE *) ;
419 extern void _IO_funlockfile (_IO_FILE *) ;
420 extern int _IO_ftrylockfile (_IO_FILE *) ;
425 #define _IO_peekc(_fp) _IO_peekc_unlocked (_fp)
426 #define _IO_flockfile(_fp)
427 #define _IO_funlockfile(_fp)
428 #define _IO_ftrylockfile(_fp)
429 #define _IO_cleanup_region_start(_fct, _fp)
430 #define _IO_cleanup_region_end(_Doit)
434 extern int _IO_vfscanf (_IO_FILE *, const char *, _G_va_list , int *) ;
435 extern int _IO_vfprintf (_IO_FILE *, const char *, _G_va_list ) ;
436 extern _G_ssize_t _IO_padn (_IO_FILE *, int, _G_ssize_t ) ;
437 extern _G_size_t _IO_sgetn (_IO_FILE *, void *, _G_size_t ) ;
439 extern _G_fpos_t _IO_seekoff (_IO_FILE *, _G_off_t , int, int) ;
440 extern _G_fpos_t _IO_seekpos (_IO_FILE *, _G_fpos_t , int) ;
442 extern void _IO_free_backup_area (_IO_FILE *) ;
471 #define _IO_wchar_t short
476 class ostream; class streambuf;
482 typedef _G_off_t streamoff;
483 typedef _G_fpos_t streampos;
484 typedef _G_ssize_t streamsize;
486 typedef unsigned long __fmtflags;
487 typedef unsigned char __iostate;
497 __iostate _exceptions;
513 #define _IO_NOCREATE 32
514 #define _IO_NOREPLACE 64
519 class ios : public _ios_fields {
520 ios& operator=(ios&);
523 typedef __fmtflags fmtflags;
525 typedef int openmode;
526 typedef int streamsize;
542 enum seek_dir { beg, cur, end};
543 typedef enum seek_dir seekdir;
546 left= 02 , right= 04 , internal= 010 ,
547 dec= 020 , oct= 040 , hex= 0100 ,
548 showbase= 0200 , showpoint= 0400 ,
549 uppercase= 01000 , showpos= 02000 ,
550 scientific= 04000 , fixed= 010000 ,
551 unitbuf= 020000 , stdio= 040000
557 basefield=dec+oct+hex,
558 floatfield = scientific+fixed,
559 adjustfield = left+right+internal
564 ostream* tie() const { return _tie; }
565 ostream* tie(ostream* val) { ostream* save=_tie; _tie=val; return save; }
568 short fill() const { return (short )_fill; }
569 short fill(short newf)
570 {short oldf = (short )_fill; _fill = (char)newf; return oldf;}
571 fmtflags flags() const { return _flags; }
572 fmtflags flags(fmtflags new_val) {
573 fmtflags old_val = _flags; _flags = new_val; return old_val; }
574 int precision() const { return _precision; }
575 int precision(int newp) {
576 unsigned short oldp = _precision; _precision = (unsigned short)newp;
578 fmtflags setf(fmtflags val) {
579 fmtflags oldbits = _flags;
580 _flags |= val; return oldbits; }
581 fmtflags setf(fmtflags val, fmtflags mask) {
582 fmtflags oldbits = _flags;
583 _flags = (_flags & ~mask) | (val & mask); return oldbits; }
584 fmtflags unsetf(fmtflags mask) {
585 fmtflags oldbits = _flags;
586 _flags &= ~mask; return oldbits; }
587 int width() const { return _width; }
588 int width(int val) { int save = _width; _width = val; return save; }
593 void _throw_failure() const { }
595 void clear(iostate state = 0) {
596 _state = _strbuf ? state : state|badbit;
597 if (_state & _exceptions) _throw_failure(); }
598 void set(iostate flag) { _state |= flag;
599 if (_state & _exceptions) _throw_failure(); }
600 void setstate(iostate flag) { _state |= flag;
601 if (_state & _exceptions) _throw_failure(); }
602 int good() const { return _state == 0; }
603 int eof() const { return _state & ios::eofbit; }
604 int fail() const { return _state & (ios::badbit|ios::failbit); }
605 int bad() const { return _state & ios::badbit; }
606 iostate rdstate() const { return _state; }
607 operator void*() const { return fail() ? (void*)0 : (void*)(-1); }
608 int operator!() const { return fail(); }
609 iostate exceptions() const { return _exceptions; }
610 void exceptions(iostate enable) {
611 _exceptions = enable;
612 if (_state & _exceptions) _throw_failure(); }
614 streambuf* rdbuf() const { return _strbuf; }
615 streambuf* rdbuf(streambuf *_s) {
616 streambuf *_old = _strbuf; _strbuf = _s; clear (); return _old; }
618 static int sync_with_stdio(int on);
619 static void sync_with_stdio() { sync_with_stdio(1); }
620 static fmtflags bitalloc();
623 void* pword(int) const;
625 long iword(int) const;
642 inline ios(streambuf* sb = 0, ostream* tie_to = 0);
643 inline virtual ~ios();
644 inline void init(streambuf* sb, ostream* tie = 0);
650 typedef ios::seek_dir _seek_dir;
661 class streammarker : private _IO_marker {
662 friend class streambuf;
663 void set_offset(int offset) { _pos = offset; }
665 streammarker(streambuf *sb);
667 int saving() { return 1; }
668 int delta(streammarker&);
672 struct streambuf : public _IO_FILE {
674 friend class istream;
675 friend class ostream;
676 friend class streammarker;
677 const void *&_vtable() { return *(const void**)((_IO_FILE*)this + 1); }
679 static streambuf* _list_all;
680 _IO_FILE*& xchain() { return _chain; }
684 { return _flags & 0x100 ? _IO_save_base : _IO_read_ptr; }
685 char* pptr() const { return _IO_write_ptr; }
687 { return _flags & 0x100 ? _IO_save_end : _IO_read_end; }
688 char* epptr() const { return _IO_write_end; }
689 char* pbase() const { return _IO_write_base; }
691 { return _flags & 0x100 ? _IO_save_base : _IO_read_base;}
692 char* base() const { return _IO_buf_base; }
693 char* ebuf() const { return _IO_buf_end; }
694 int blen() const { return _IO_buf_end - _IO_buf_base; }
695 void xput_char(char c) { *_IO_write_ptr++ = c; }
696 int xflags() { return _flags ; }
697 int xflags(int f) {int fl = _flags ; _flags = f; return fl;}
698 void xsetflags(int f) { _flags |= f; }
699 void xsetflags(int f, int mask)
700 { _flags = (_flags & ~mask) | (f & mask); }
702 { _flags & 0x100 ? (_IO_save_base+=n):(_IO_read_ptr+=n);}
703 void pbump(int n) { _IO_write_ptr += n; }
704 void setb(char* b, char* eb, int a=0);
705 void setp(char* p, char* ep)
706 { _IO_write_base=_IO_write_ptr=p; _IO_write_end=ep; }
707 void setg(char* eb, char* g, char *eg) {
708 if (_flags & 0x100 ) _IO_free_backup_area(this);
709 _IO_read_base = eb; _IO_read_ptr = g; _IO_read_end = eg; }
710 char *shortbuf() { return _shortbuf; }
712 int in_backup() { return _flags & 0x100 ; }
714 char *Gbase() { return in_backup() ? _IO_save_base : _IO_read_base; }
716 char *eGptr() { return in_backup() ? _IO_save_end : _IO_read_end; }
718 char *Bbase() { return in_backup() ? _IO_read_base : _IO_save_base; }
719 char *Bptr() { return _IO_backup_base; }
721 char *eBptr() { return in_backup() ? _IO_read_end : _IO_save_end; }
722 char *Nbase() { return _IO_save_base; }
723 char *eNptr() { return _IO_save_end; }
724 int have_backup() { return _IO_save_base != (__null) ; }
725 int have_markers() { return _markers != (__null) ; }
726 void free_backup_area();
727 void unsave_markers();
728 int put_mode() { return _flags & 0x800 ; }
729 int switch_to_get_mode();
731 streambuf(int flags=0);
733 static int flush_all();
734 static void flush_all_linebuffered();
735 virtual ~streambuf();
736 virtual int overflow(int c = (-1) );
737 virtual int underflow();
739 virtual int pbackfail(int c);
741 virtual streamsize xsputn(const char* s, streamsize n);
742 virtual streamsize xsgetn(char* s, streamsize n);
743 virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
744 virtual streampos seekpos(streampos pos, int mode = ios::in|ios::out);
746 streampos pubseekoff(streamoff o, _seek_dir d, int mode=ios::in|ios::out)
747 { return _IO_seekoff (this, o, d, mode); }
748 streampos pubseekpos(streampos pos, int mode = ios::in|ios::out)
749 { return _IO_seekpos (this, pos, mode); }
750 streampos sseekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
751 streampos sseekpos(streampos pos, int mode = ios::in|ios::out);
752 virtual streambuf* setbuf(char* p, int len);
754 virtual int doallocate();
756 int seekmark(streammarker& mark, int delta = 0);
757 int sputbackc(char c);
759 int unbuffered() { return _flags & 2 ? 1 : 0; }
760 int linebuffered() { return _flags & 0x200 ? 1 : 0; }
761 void unbuffered(int i)
762 { if (i) _flags |= 2 ; else _flags &= ~2 ; }
763 void linebuffered(int i)
764 { if (i) _flags |= 0x200 ; else _flags &= ~0x200 ; }
766 if (base() || unbuffered()) return 0;
767 else return doallocate(); }
769 void allocbuf() { if (base() == (__null) ) doallocbuf(); }
771 int in_avail() { return _IO_read_end - _IO_read_ptr; }
772 int out_waiting() { return _IO_write_ptr - _IO_write_base; }
773 streamsize sputn(const char* s, streamsize n) { return xsputn(s, n); }
774 streamsize padn(char pad, streamsize n) { return _IO_padn(this, pad, n); }
775 streamsize sgetn(char* s, streamsize n) { return _IO_sgetn(this, s, n); }
779 long sgetline(char* buf, _G_size_t n, char delim, int putback_delim);
780 int sputc(int c) { return _IO_putc(c, this); }
781 int sbumpc() { return _IO_getc(this); }
782 int sgetc() { return (( this )->_IO_read_ptr >= ( this )->_IO_read_end && __underflow ( this ) == (-1) ? (-1) : *(unsigned char *) ( this )->_IO_read_ptr) ; }
784 if (_IO_read_ptr >= _IO_read_end && __underflow(this) == (-1) )
786 else return _IO_read_ptr++, sgetc(); }
787 void stossc() { if (_IO_read_ptr < _IO_read_end) _IO_read_ptr++; }
788 int vscan(char const *fmt0, _G_va_list ap, ios* stream = (__null) );
789 int scan(char const *fmt0 ...);
790 int vform(char const *fmt0, _G_va_list ap);
791 int form(char const *fmt0 ...);
796 virtual streamsize sys_read(char* buf, streamsize size);
797 virtual streamsize sys_write(const char*, streamsize);
798 virtual streampos sys_seek(streamoff, _seek_dir);
799 virtual int sys_close();
800 virtual int sys_stat(void*);
806 class filebuf : public streambuf {
810 static const int openprot;
813 filebuf(int fd, char* p, int len);
818 filebuf* attach(int fd);
819 filebuf* open(const char *filename, const char *mode);
820 filebuf* open(const char *filename, ios::openmode mode, int prot = 0664);
821 virtual int underflow();
822 virtual int overflow(int c = (-1) );
823 int is_open() const { return _fileno >= 0; }
824 int fd() const { return is_open() ? _fileno : (-1) ; }
826 virtual int doallocate();
827 virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
828 virtual streambuf* setbuf(char* p, int len);
829 streamsize xsputn(const char* s, streamsize n);
830 streamsize xsgetn(char* s, streamsize n);
834 int is_reading() { return eback() != egptr(); }
835 char* cur_ptr() { return is_reading() ? gptr() : pptr(); }
837 char* file_ptr() { return eGptr(); }
839 virtual streamsize sys_read(char* buf, streamsize size);
840 virtual streampos sys_seek(streamoff, _seek_dir);
841 virtual streamsize sys_write(const char*, streamsize);
842 virtual int sys_stat(void*);
843 virtual int sys_close();
850 inline void ios::init(streambuf* sb, ostream* tie_to) {
851 _state = sb ? ios::goodbit : ios::badbit; _exceptions=0;
852 _strbuf=sb; _tie = tie_to; _width=0; _fill=' ';
854 _flags=ios::skipws|ios::dec;
858 _precision=6; _arrays = 0; }
860 inline ios::ios(streambuf* sb, ostream* tie_to) { init(sb, tie_to); }
866 operator delete(_arrays);
873 class istream; class ostream;
874 typedef ios& (*__manip)(ios&);
875 typedef istream& (*__imanip)(istream&);
876 typedef ostream& (*__omanip)(ostream&);
878 extern istream& ws(istream& ins);
879 extern ostream& flush(ostream& outs);
880 extern ostream& endl(ostream& outs);
881 extern ostream& ends(ostream& outs);
883 class ostream : virtual public ios
889 ostream(streambuf* sb, ostream* tied= (__null) );
891 if (!good()) return 0;
892 else { if (_tie) _tie->flush(); ; return 1;} }
894 if (flags() & (ios::unitbuf|ios::stdio))
897 ostream& put(char c) { _strbuf->sputc(c); return *this; }
903 ostream& write(const char *s, streamsize n);
904 ostream& write(const unsigned char *s, streamsize n)
905 { return write((const char*)s, n);}
906 ostream& write(const signed char *s, streamsize n)
907 { return write((const char*)s, n);}
908 ostream& write(const void *s, streamsize n)
909 { return write((const char*)s, n);}
910 ostream& seekp(streampos);
911 ostream& seekp(streamoff, _seek_dir);
913 ostream& form(const char *format ...);
914 ostream& vform(const char *format, _G_va_list args);
916 ostream& operator<<(char c);
917 ostream& operator<<(unsigned char c) { return (*this) << (char)c; }
918 ostream& operator<<(signed char c) { return (*this) << (char)c; }
919 ostream& operator<<(const char *s);
920 ostream& operator<<(const unsigned char *s)
921 { return (*this) << (const char*)s; }
922 ostream& operator<<(const signed char *s)
923 { return (*this) << (const char*)s; }
924 ostream& operator<<(const void *p);
925 ostream& operator<<(int n);
926 ostream& operator<<(unsigned int n);
927 ostream& operator<<(long n);
928 ostream& operator<<(unsigned long n);
930 __extension__ ostream& operator<<(long long n);
931 __extension__ ostream& operator<<(unsigned long long n);
933 ostream& operator<<(short n) {return operator<<((int)n);}
934 ostream& operator<<(unsigned short n) {return operator<<((unsigned int)n);}
936 ostream& operator<<(bool b) { return operator<<((int)b); }
938 ostream& operator<<(double n);
939 ostream& operator<<(float n) { return operator<<((double)n); }
943 ostream& operator<<(long double n) { return operator<<((double)n); }
945 ostream& operator<<(__omanip func) { return (*func)(*this); }
946 ostream& operator<<(__manip func) {(*func)(*this); return *this;}
947 ostream& operator<<(streambuf*);
953 class istream : virtual public ios
961 istream(): _gcount (0) { }
962 istream(streambuf* sb, ostream*tied= (__null) );
963 istream& get(char* ptr, int len, char delim = '\n');
964 istream& get(unsigned char* ptr, int len, char delim = '\n')
965 { return get((char*)ptr, len, delim); }
966 istream& get(char& c);
967 istream& get(unsigned char& c) { return get((char&)c); }
968 istream& getline(char* ptr, int len, char delim = '\n');
969 istream& getline(unsigned char* ptr, int len, char delim = '\n')
970 { return getline((char*)ptr, len, delim); }
971 istream& get(signed char& c) { return get((char&)c); }
972 istream& get(signed char* ptr, int len, char delim = '\n')
973 { return get((char*)ptr, len, delim); }
974 istream& getline(signed char* ptr, int len, char delim = '\n')
975 { return getline((char*)ptr, len, delim); }
976 istream& read(char *ptr, streamsize n);
977 istream& read(unsigned char *ptr, streamsize n)
978 { return read((char*)ptr, n); }
979 istream& read(signed char *ptr, streamsize n)
980 { return read((char*)ptr, n); }
981 istream& read(void *ptr, streamsize n)
982 { return read((char*)ptr, n); }
983 istream& get(streambuf& sb, char delim = '\n');
984 istream& gets(char **s, char delim = '\n');
985 int ipfx(int need = 0) {
986 if (!good()) { set(ios::failbit); return 0; }
989 if (_tie && (need == 0 || rdbuf()->in_avail() < need)) _tie->flush();
990 if (!need && (flags() & ios::skipws)) return _skip_ws();
995 if (!good()) { set(ios::failbit); return 0; }
998 if (_tie) _tie->flush();
999 if (flags() & ios::skipws) return _skip_ws();
1004 if (!good()) { set(ios::failbit); return 0; }
1007 if (_tie && rdbuf()->in_avail() == 0) _tie->flush();
1012 int get() { if (!ipfx1()) return (-1) ;
1013 else { int ch = _strbuf->sbumpc();
1014 if (ch == (-1) ) set(ios::eofbit);
1018 _G_size_t gcount() { return _gcount; }
1019 istream& ignore(int n=1, int delim = (-1) );
1021 istream& seekg(streampos);
1022 istream& seekg(streamoff, _seek_dir);
1024 istream& putback(char ch) {
1025 if (good() && _strbuf->sputbackc(ch) == (-1) ) clear(ios::badbit);
1028 if (good() && _strbuf->sungetc() == (-1) ) clear(ios::badbit);
1030 istream& scan(const char *format ...);
1031 istream& vscan(const char *format, _G_va_list args);
1038 istream& operator>>(char*);
1039 istream& operator>>(unsigned char* p) { return operator>>((char*)p); }
1040 istream& operator>>(signed char*p) { return operator>>((char*)p); }
1041 istream& operator>>(char& c);
1042 istream& operator>>(unsigned char& c) {return operator>>((char&)c);}
1043 istream& operator>>(signed char& c) {return operator>>((char&)c);}
1044 istream& operator>>(int&);
1045 istream& operator>>(long&);
1047 __extension__ istream& operator>>(long long&);
1048 __extension__ istream& operator>>(unsigned long long&);
1050 istream& operator>>(short&);
1051 istream& operator>>(unsigned int&);
1052 istream& operator>>(unsigned long&);
1053 istream& operator>>(unsigned short&);
1055 istream& operator>>(bool&);
1057 istream& operator>>(float&);
1058 istream& operator>>(double&);
1059 istream& operator>>(long double&);
1060 istream& operator>>( __manip func) {(*func)(*this); return *this;}
1061 istream& operator>>(__imanip func) { return (*func)(*this); }
1062 istream& operator>>(streambuf*);
1065 class iostream : public istream, public ostream
1069 iostream(streambuf* sb, ostream*tied= (__null) );
1072 class _IO_istream_withassign : public istream {
1074 _IO_istream_withassign& operator=(istream&);
1075 _IO_istream_withassign& operator=(_IO_istream_withassign& rhs)
1076 { return operator= (static_cast<istream&> (rhs)); }
1079 class _IO_ostream_withassign : public ostream {
1081 _IO_ostream_withassign& operator=(ostream&);
1082 _IO_ostream_withassign& operator=(_IO_ostream_withassign& rhs)
1083 { return operator= (static_cast<ostream&> (rhs)); }
1086 extern _IO_istream_withassign cin;
1088 extern _IO_ostream_withassign cout, cerr;
1090 extern _IO_ostream_withassign clog
1096 extern istream& lock(istream& ins);
1097 extern istream& unlock(istream& ins);
1098 extern ostream& lock(ostream& outs);
1099 extern ostream& unlock(ostream& outs);
1101 struct Iostream_init { } ;
1103 inline ios& dec(ios& i)
1104 { i.setf(ios::dec, ios::dec|ios::hex|ios::oct); return i; }
1105 inline ios& hex(ios& i)
1106 { i.setf(ios::hex, ios::dec|ios::hex|ios::oct); return i; }
1107 inline ios& oct(ios& i)
1108 { i.setf(ios::oct, ios::dec|ios::hex|ios::oct); return i; }
1154 template<class TP> class smanip;
1156 template<class TP> class sapp {
1157 ios& (*_f)(ios&, TP);
1159 sapp(ios& (*f)(ios&, TP)) : _f(f) {}
1161 smanip<TP> operator()(TP a)
1162 { return smanip<TP>(_f, a); }
1166 inline istream& operator>>(istream& i, const smanip<TP>& m);
1168 inline ostream& operator<<(ostream& o, const smanip<TP>& m);
1170 template <class TP> class smanip {
1171 ios& (*_f)(ios&, TP);
1174 smanip(ios& (*f)(ios&, TP), TP a) : _f(f), _a(a) {}
1177 istream& operator>> <>(istream& i, const smanip<TP>& m);
1179 ostream& operator<< <>(ostream& o, const smanip<TP>& m);
1183 extern template class smanip<int>;
1184 extern template class smanip<ios::fmtflags>;
1188 inline istream& operator>>(istream& i, const smanip<TP>& m)
1189 { (*m._f)(i, m._a); return i; }
1192 inline ostream& operator<<(ostream& o, const smanip<TP>& m)
1193 { (*m._f)(o, m._a); return o;}
1196 extern template istream& operator>>(istream&, const smanip<int>&);
1197 extern template istream& operator>>(istream&, const smanip<ios::fmtflags>&);
1198 extern template ostream& operator<<(ostream&, const smanip<int>&);
1199 extern template ostream& operator<<(ostream&, const smanip<ios::fmtflags>&);
1206 template<class TP> class imanip;
1208 template<class TP> class iapp {
1209 istream& (*_f)(istream&, TP);
1211 iapp(istream& (*f)(istream&,TP)) : _f(f) {}
1213 imanip<TP> operator()(TP a)
1214 { return imanip<TP>(_f, a); }
1218 inline istream& operator>>(istream&, const imanip<TP>&);
1220 template <class TP> class imanip {
1221 istream& (*_f)(istream&, TP);
1224 imanip(istream& (*f)(istream&, TP), TP a) : _f(f), _a(a) {}
1227 istream& operator>> <>(istream& i, const imanip<TP>& m);
1231 inline istream& operator>>(istream& i, const imanip<TP>& m)
1232 { return (*m._f)( i, m._a); }
1238 template<class TP> class omanip;
1240 template<class TP> class oapp {
1241 ostream& (*_f)(ostream&, TP);
1243 oapp(ostream& (*f)(ostream&,TP)) : _f(f) {}
1245 omanip<TP> operator()(TP a)
1246 { return omanip<TP>(_f, a); }
1250 inline ostream& operator<<(ostream&, const omanip<TP>&);
1252 template <class TP> class omanip {
1253 ostream& (*_f)(ostream&, TP);
1256 omanip(ostream& (*f)(ostream&, TP), TP a) : _f(f), _a(a) {}
1259 ostream& operator<< <>(ostream& o, const omanip<TP>& m);
1263 inline ostream& operator<<(ostream& o, const omanip<TP>& m)
1264 { return (*m._f)(o, m._a); }
1274 #define __DEFINE_IOMANIP_FN1(type,param,function) extern ios& __iomanip_##function (ios&, param); inline type<param> function (param n) { return type<param> (__iomanip_##function, n); }
1279 extern ios& __iomanip_setbase (ios&, int ); inline smanip < int > setbase ( int n) { return smanip < int > (__iomanip_setbase , n); }
1280 extern ios& __iomanip_setfill (ios&, int ); inline smanip < int > setfill ( int n) { return smanip < int > (__iomanip_setfill , n); }
1281 extern ios& __iomanip_setprecision (ios&, int ); inline smanip < int > setprecision ( int n) { return smanip < int > (__iomanip_setprecision , n); }
1282 extern ios& __iomanip_setw (ios&, int ); inline smanip < int > setw ( int n) { return smanip < int > (__iomanip_setw , n); }
1284 extern ios& __iomanip_resetiosflags (ios&, ios::fmtflags ); inline smanip < ios::fmtflags > resetiosflags ( ios::fmtflags n) { return smanip < ios::fmtflags > (__iomanip_resetiosflags , n); }
1285 extern ios& __iomanip_setiosflags (ios&, ios::fmtflags ); inline smanip < ios::fmtflags > setiosflags ( ios::fmtflags n) { return smanip < ios::fmtflags > (__iomanip_setiosflags , n); }
1294 #define Mouvement_hh
1311 #pragma ident "@(#)math.h 2.5 95/02/07"
1330 typedef union _h_val {
1331 unsigned long _i[2];
1336 extern const _h_val __huge_val;
1342 #define HUGE_VAL __huge_val._d
1350 #define M_E 2.7182818284590452354
1351 #define M_LOG2E 1.4426950408889634074
1352 #define M_LOG10E 0.43429448190325182765
1353 #define M_LN2 0.69314718055994530942
1354 #define M_LN10 2.30258509299404568402
1355 #define M_PI 3.14159265358979323846
1356 #define M_PI_2 1.57079632679489661923
1357 #define M_PI_4 0.78539816339744830962
1358 #define M_1_PI 0.31830988618379067154
1359 #define M_2_PI 0.63661977236758134308
1360 #define M_2_SQRTPI 1.12837916709551257390
1361 #define M_SQRT2 1.41421356237309504880
1362 #define M_SQRT1_2 0.70710678118654752440
1366 #define MAXFLOAT ((float)3.40282346638528860e+38)
1372 enum version {libm_ieee = -1, c_issue_4, ansi_1, strict_ansi};
1375 extern const enum version _lib_version;
1381 #define exception __math_exception
1383 struct __math_exception {
1394 #define HUGE MAXFLOAT
1396 #define _ABS(x) ((x) < 0 ? -(x) : (x))
1398 #define _REDUCE(TYPE, X, XN, C1, C2) { double x1 = (double)(TYPE)X, x2 = X - x1; X = x1 - (XN) * (C1); X += x2; X -= (XN) * (C2); }
1409 #define _POLY1(x, c) ((c)[0] * (x) + (c)[1])
1410 #define _POLY2(x, c) (_POLY1((x), (c)) * (x) + (c)[2])
1411 #define _POLY3(x, c) (_POLY2((x), (c)) * (x) + (c)[3])
1412 #define _POLY4(x, c) (_POLY3((x), (c)) * (x) + (c)[4])
1413 #define _POLY5(x, c) (_POLY4((x), (c)) * (x) + (c)[5])
1414 #define _POLY6(x, c) (_POLY5((x), (c)) * (x) + (c)[6])
1415 #define _POLY7(x, c) (_POLY6((x), (c)) * (x) + (c)[7])
1416 #define _POLY8(x, c) (_POLY7((x), (c)) * (x) + (c)[8])
1417 #define _POLY9(x, c) (_POLY8((x), (c)) * (x) + (c)[9])
1424 extern double acos (double) ;
1425 extern double asin (double) ;
1426 extern double atan (double) ;
1427 extern double atan2 (double, double) ;
1428 extern double cos (double) ;
1429 extern double sin (double) ;
1430 extern double tan (double) ;
1432 extern double cosh (double) ;
1433 extern double sinh (double) ;
1434 extern double tanh (double) ;
1436 extern double exp (double) ;
1437 extern double frexp (double, int *) ;
1438 extern double ldexp (double, int) ;
1439 extern double log (double) ;
1440 extern double log10 (double) ;
1441 extern double modf (double, double *) ;
1443 extern double pow (double, double) ;
1444 extern double sqrt (double) ;
1446 extern double ceil (double) ;
1447 extern double fabs (double) ;
1448 extern double floor (double) ;
1449 extern double fmod (double, double) ;
1456 extern double erf (double) ;
1457 extern double erfc (double) ;
1458 extern double gamma (double) ;
1459 extern double hypot (double, double) ;
1460 extern int isnan (double) ;
1461 extern double j0 (double) ;
1462 extern double j1 (double) ;
1463 extern double jn (int, double) ;
1464 extern double lgamma (double) ;
1465 extern double y0 (double) ;
1466 extern double y1 (double) ;
1467 extern double yn (int, double) ;
1474 extern double acosh (double) ;
1475 extern double asinh (double) ;
1476 extern double atanh (double) ;
1477 extern double cbrt (double) ;
1478 extern double logb (double) ;
1479 extern double nextafter (double, double) ;
1480 extern double remainder (double, double) ;
1481 extern double scalb (double, double) ;
1486 extern double expm1 (double) ;
1487 extern int ilogb (double) ;
1488 extern double log1p (double) ;
1489 extern double rint (double) ;
1497 #define exception __math_exception
1499 extern int matherr (struct __math_exception *) ;
1507 extern double significand (double) ;
1512 extern double copysign (double, double) ;
1513 extern double scalbn (double, int) ;
1527 extern float modff (float, float *) ;
1537 #define _FLOATINGPOINT_H
1543 #pragma ident "@(#)floatingpoint.h 2.4 94/06/09"
1575 #pragma ident "@(#)stdio.h 1.39 95/12/04 SMI"
1585 #define _SYS_FEATURE_TESTS_H
1587 #pragma ident "@(#)feature_tests.h 1.7 94/12/06 SMI"
1617 #define _SYS_VA_LIST_H
1619 #pragma ident "@(#)va_list.h 1.6 96/01/26 SMI"
1638 typedef void *__va_list;
1658 typedef unsigned int size_t;
1661 typedef long fpos_t;
1715 #define _IOREAD 0001
1718 #define _IOMYBUF 0010
1724 #define FOPEN_MAX _NFILE
1725 #define FILENAME_MAX 1024
1730 #define TMP_MAX 17576
1742 #define P_tmpdir "/var/tmp/"
1748 #define stdin (&__iob[0])
1749 #define stdout (&__iob[1])
1750 #define stderr (&__iob[2])
1764 unsigned char *_ptr;
1766 unsigned char *_base;
1767 unsigned char _flag;
1768 unsigned char _file;
1772 extern FILE __iob[20 ];
1776 extern FILE *_lastbuf;
1777 extern unsigned char *_bufendtab[];
1779 extern unsigned char _sibuf[], _sobuf[];
1784 extern int remove(const char *);
1785 extern int rename(const char *, const char *);
1786 extern FILE *tmpfile(void);
1787 extern char *tmpnam(char *);
1791 extern int fclose(FILE *);
1792 extern int fflush(FILE *);
1793 extern FILE *fopen(const char *, const char *);
1794 extern FILE *freopen(const char *, const char *, FILE *);
1795 extern void setbuf(FILE *, char *);
1796 extern int setvbuf(FILE *, char *, int, size_t);
1798 extern int fprintf(FILE *, const char *, ...);
1800 extern int fscanf(FILE *, const char *, ...);
1802 extern int printf(const char *, ...);
1804 extern int scanf(const char *, ...);
1806 extern int sprintf(char *, const char *, ...);
1808 extern int sscanf(const char *, const char *, ...);
1809 extern int vfprintf(FILE *, const char *, __va_list);
1810 extern int vprintf(const char *, __va_list);
1811 extern int vsprintf(char *, const char *, __va_list);
1812 extern int fgetc(FILE *);
1813 extern char *fgets(char *, int, FILE *);
1814 extern int fputc(int, FILE *);
1815 extern int fputs(const char *, FILE *);
1816 extern int getc(FILE *);
1817 extern int getchar(void);
1818 extern char *gets(char *);
1819 extern int putc(int, FILE *);
1820 extern int putchar(int);
1821 extern int puts(const char *);
1822 extern int ungetc(int, FILE *);
1823 extern size_t fread(void *, size_t, size_t, FILE *);
1824 extern size_t fwrite(const void *, size_t, size_t, FILE *);
1825 extern int fgetpos(FILE *, fpos_t *);
1826 extern int fseek(FILE *, long, int);
1827 extern int fsetpos(FILE *, const fpos_t *);
1828 extern long ftell(FILE *);
1829 extern void rewind(FILE *);
1830 extern void clearerr(FILE *);
1831 extern int feof(FILE *);
1832 extern int ferror(FILE *);
1833 extern void perror(const char *);
1835 extern int __filbuf(FILE *);
1836 extern int __flsbuf(int, FILE *);
1844 extern FILE *fdopen(int, const char *);
1845 extern char *ctermid(char *);
1846 extern int fileno(FILE *);
1860 extern FILE *popen(const char *, const char *);
1861 extern char *cuserid(char *);
1862 extern char *tempnam(const char *, const char *);
1863 extern int getopt(int, char *const *, const char *);
1865 extern int getsubopt(char **, char *const *, char **);
1867 extern char *optarg;
1868 extern int optind, opterr, optopt;
1869 extern int getw(FILE *);
1870 extern int putw(int, FILE *);
1871 extern int pclose(FILE *);
1889 #define getc(p) (--(p)->_cnt < 0 ? __filbuf(p) : (int)*(p)->_ptr++)
1890 #define putc(x, p) (--(p)->_cnt < 0 ? __flsbuf((unsigned char) (x), (p)) : (int)(*(p)->_ptr++ = (x)))
1898 #define getchar() getc(stdin)
1899 #define putchar(x) putc((x), stdout)
1900 #define clearerr(p) ((void)((p)->_flag &= ~(_IOERR | _IOEOF)))
1901 #define feof(p) ((p)->_flag & _IOEOF)
1902 #define ferror(p) ((p)->_flag & _IOERR)
1907 #define fileno(p) ((p)->_file)
1926 #define _SYS_IEEEFP_H
1928 #pragma ident "@(#)ieeefp.h 2.7 94/11/09"
1938 enum fp_direction_type {
1945 enum fp_precision_type {
1952 enum fp_exception_type {
1960 enum fp_trap_enable_type {
1961 fp_trap_inexact = 0,
1962 fp_trap_division = 1,
1963 fp_trap_underflow = 2,
1964 fp_trap_overflow = 3,
1973 enum fp_class_type {
1999 #define N_IEEE_EXCEPTION 5
2001 typedef int sigfpe_code_type;
2003 typedef void (*sigfpe_handler_type)();
2005 #define SIGFPE_DEFAULT (void (*)())0
2006 #define SIGFPE_IGNORE (void (*)())1
2007 #define SIGFPE_ABORT (void (*)())2
2009 extern sigfpe_handler_type sigfpe (sigfpe_code_type, sigfpe_handler_type) ;
2014 typedef float single;
2018 typedef unsigned extended[3];
2021 typedef long double quadruple;
2023 typedef unsigned fp_exception_field_type;
2031 #define DECIMAL_STRING_LENGTH 512
2033 typedef char decimal_string[512 ];
2037 enum fp_class_type fpclass;
2060 enum fp_direction_type rd;
2062 enum decimal_form df;
2067 enum decimal_string_form {
2073 fixed_intdotfrac_form,
2075 floating_intdot_form,
2076 floating_dotfrac_form,
2077 floating_intdotfrac_form,
2084 extern void single_to_decimal (single *, decimal_mode *, decimal_record *,
2085 fp_exception_field_type *) ;
2086 extern void double_to_decimal (double *, decimal_mode *, decimal_record *,
2087 fp_exception_field_type *) ;
2088 extern void extended_to_decimal (extended *, decimal_mode *,
2089 decimal_record *, fp_exception_field_type *) ;
2090 extern void quadruple_to_decimal (quadruple *, decimal_mode *,
2091 decimal_record *, fp_exception_field_type *) ;
2093 extern void decimal_to_single (single *, decimal_mode *, decimal_record *,
2094 fp_exception_field_type *) ;
2095 extern void decimal_to_double (double *, decimal_mode *, decimal_record *,
2096 fp_exception_field_type *) ;
2097 extern void decimal_to_extended (extended *, decimal_mode *,
2098 decimal_record *, fp_exception_field_type *) ;
2099 extern void decimal_to_quadruple (quadruple *, decimal_mode *,
2100 decimal_record *, fp_exception_field_type *) ;
2102 extern void string_to_decimal (char **, int, int, decimal_record *,
2103 enum decimal_string_form *, char **) ;
2104 extern void func_to_decimal (char **, int, int, decimal_record *,
2105 enum decimal_string_form *, char **,
2106 int (*)(void), int *, int (*)(int)) ;
2107 extern void file_to_decimal (char **, int, int, decimal_record *,
2108 enum decimal_string_form *, char **,
2111 extern char *seconvert (single *, int, int *, int *, char *) ;
2112 extern char *sfconvert (single *, int, int *, int *, char *) ;
2113 extern char *sgconvert (single *, int, int, char *) ;
2114 extern char *econvert (double, int, int *, int *, char *) ;
2115 extern char *fconvert (double, int, int *, int *, char *) ;
2116 extern char *gconvert (double, int, int, char *) ;
2117 extern char *qeconvert (quadruple *, int, int *, int *, char *) ;
2118 extern char *qfconvert (quadruple *, int, int *, int *, char *) ;
2119 extern char *qgconvert (quadruple *, int, int, char *) ;
2121 extern char *ecvt (double, int, int *, int *) ;
2122 extern char *fcvt (double, int, int *, int *) ;
2123 extern char *gcvt (double, int, char *) ;
2129 extern double atof (const char *) ;
2130 extern double strtod (const char *, char **) ;
2204 struct re_pattern_buffer;
2205 struct re_registers;
2211 Regex(const Regex&) {}
2212 void operator = (const Regex&) {}
2215 re_pattern_buffer* buf;
2219 Regex(const char* t,
2222 const char* transtable = 0);
2226 int match(const char* s, int len, int pos = 0) const;
2227 int search(const char* s, int len,
2228 int& matchlen, int startpos = 0) const;
2229 int match_info(int& start, int& length, int nth = 0) const;
2262 StrRep* Salloc(StrRep*, const char*, int, int);
2263 StrRep* Scopy(StrRep*, const StrRep*);
2264 StrRep* Scat(StrRep*, const char*, int, const char*, int);
2265 StrRep* Scat(StrRep*, const char*, int,const char*,int, const char*,int);
2266 StrRep* Sprepend(StrRep*, const char*, int);
2267 StrRep* Sreverse(const StrRep*, StrRep*);
2268 StrRep* Supcase(const StrRep*, StrRep*);
2269 StrRep* Sdowncase(const StrRep*, StrRep*);
2270 StrRep* Scapitalize(const StrRep*, StrRep*);
2279 friend class String;
2286 void assign(const StrRep*, const char*, int = -1);
2287 SubString(String& x, int p, int l);
2290 SubString(const SubString& x);
2297 SubString& operator = (const String& y);
2298 SubString& operator = (const SubString& y);
2299 SubString& operator = (const char* t);
2300 SubString& operator = (char c);
2304 int contains(char c) const;
2305 int contains(const String& y) const;
2306 int contains(const SubString& y) const;
2307 int contains(const char* t) const;
2308 int contains(const Regex& r) const;
2312 int matches(const Regex& r) const;
2316 friend ostream& operator<<(ostream& s, const SubString& x);
2320 unsigned int length() const;
2322 const char* chars() const;
2331 friend class SubString;
2338 int search(int, int, const char*, int = -1) const;
2339 int search(int, int, char) const;
2340 int match(int, int, int, const char*, int = -1) const;
2341 int _gsub(const char*, int, const char* ,int);
2342 int _gsub(const Regex&, const char*, int);
2343 SubString _substr(int, int);
2350 String(const String& x);
2351 String(const SubString& x);
2352 String(const char* t);
2353 String(const char* t, int len);
2358 String& operator = (const String& y);
2359 String& operator = (const char* y);
2360 String& operator = (char c);
2361 String& operator = (const SubString& y);
2365 String& operator += (const String& y);
2366 String& operator += (const SubString& y);
2367 String& operator += (const char* t);
2368 String& operator += (char c);
2370 void prepend(const String& y);
2371 void prepend(const SubString& y);
2372 void prepend(const char* t);
2373 void prepend(char c);
2379 friend inline void cat(const String&, const String&, String&);
2380 friend inline void cat(const String&, const SubString&, String&);
2381 friend inline void cat(const String&, const char*, String&);
2382 friend inline void cat(const String&, char, String&);
2384 friend inline void cat(const SubString&, const String&, String&);
2385 friend inline void cat(const SubString&, const SubString&, String&);
2386 friend inline void cat(const SubString&, const char*, String&);
2387 friend inline void cat(const SubString&, char, String&);
2389 friend inline void cat(const char*, const String&, String&);
2390 friend inline void cat(const char*, const SubString&, String&);
2391 friend inline void cat(const char*, const char*, String&);
2392 friend inline void cat(const char*, char, String&);
2398 friend inline void cat(const String&,const String&, const String&,String&);
2399 friend inline void cat(const String&,const String&,const SubString&,String&);
2400 friend inline void cat(const String&,const String&, const char*, String&);
2401 friend inline void cat(const String&,const String&, char, String&);
2402 friend inline void cat(const String&,const SubString&,const String&,String&);
2403 inline friend void cat(const String&,const SubString&,const SubString&,String&);
2404 friend inline void cat(const String&,const SubString&, const char*, String&);
2405 friend inline void cat(const String&,const SubString&, char, String&);
2406 friend inline void cat(const String&,const char*, const String&, String&);
2407 friend inline void cat(const String&,const char*, const SubString&, String&);
2408 friend inline void cat(const String&,const char*, const char*, String&);
2409 friend inline void cat(const String&,const char*, char, String&);
2411 friend inline void cat(const char*, const String&, const String&,String&);
2412 friend inline void cat(const char*,const String&,const SubString&,String&);
2413 friend inline void cat(const char*,const String&, const char*, String&);
2414 friend inline void cat(const char*,const String&, char, String&);
2415 friend inline void cat(const char*,const SubString&,const String&,String&);
2416 friend inline void cat(const char*,const SubString&,const SubString&,String&);
2417 friend inline void cat(const char*,const SubString&, const char*, String&);
2418 friend inline void cat(const char*,const SubString&, char, String&);
2419 friend inline void cat(const char*,const char*, const String&, String&);
2420 friend inline void cat(const char*,const char*, const SubString&, String&);
2421 friend inline void cat(const char*,const char*, const char*, String&);
2422 friend inline void cat(const char*,const char*, char, String&);
2429 int index(char c, int startpos = 0) const;
2430 int index(const String& y, int startpos = 0) const;
2431 int index(const SubString& y, int startpos = 0) const;
2432 int index(const char* t, int startpos = 0) const;
2433 int index(const Regex& r, int startpos = 0) const;
2437 int contains(char c) const;
2438 int contains(const String& y) const;
2439 int contains(const SubString& y) const;
2440 int contains(const char* t) const;
2441 int contains(const Regex& r) const;
2446 int contains(char c, int pos) const;
2447 int contains(const String& y, int pos) const;
2448 int contains(const SubString& y, int pos) const;
2449 int contains(const char* t, int pos) const;
2450 int contains(const Regex& r, int pos) const;
2454 int matches(char c, int pos = 0) const;
2455 int matches(const String& y, int pos = 0) const;
2456 int matches(const SubString& y, int pos = 0) const;
2457 int matches(const char* t, int pos = 0) const;
2458 int matches(const Regex& r, int pos = 0) const;
2462 int freq(char c) const;
2463 int freq(const String& y) const;
2464 int freq(const SubString& y) const;
2465 int freq(const char* t) const;
2473 SubString at(int pos, int len);
2474 SubString operator () (int pos, int len);
2476 SubString at(const String& x, int startpos = 0);
2477 SubString at(const SubString& x, int startpos = 0);
2478 SubString at(const char* t, int startpos = 0);
2479 SubString at(char c, int startpos = 0);
2480 SubString at(const Regex& r, int startpos = 0);
2482 SubString before(int pos);
2483 SubString before(const String& x, int startpos = 0);
2484 SubString before(const SubString& x, int startpos = 0);
2485 SubString before(const char* t, int startpos = 0);
2486 SubString before(char c, int startpos = 0);
2487 SubString before(const Regex& r, int startpos = 0);
2489 SubString through(int pos);
2490 SubString through(const String& x, int startpos = 0);
2491 SubString through(const SubString& x, int startpos = 0);
2492 SubString through(const char* t, int startpos = 0);
2493 SubString through(char c, int startpos = 0);
2494 SubString through(const Regex& r, int startpos = 0);
2496 SubString from(int pos);
2497 SubString from(const String& x, int startpos = 0);
2498 SubString from(const SubString& x, int startpos = 0);
2499 SubString from(const char* t, int startpos = 0);
2500 SubString from(char c, int startpos = 0);
2501 SubString from(const Regex& r, int startpos = 0);
2503 SubString after(int pos);
2504 SubString after(const String& x, int startpos = 0);
2505 SubString after(const SubString& x, int startpos = 0);
2506 SubString after(const char* t, int startpos = 0);
2507 SubString after(char c, int startpos = 0);
2508 SubString after(const Regex& r, int startpos = 0);
2514 void del(int pos, int len);
2518 void del(const String& y, int startpos = 0);
2519 void del(const SubString& y, int startpos = 0);
2520 void del(const char* t, int startpos = 0);
2521 void del(char c, int startpos = 0);
2522 void del(const Regex& r, int startpos = 0);
2526 int gsub(const String& pat, const String& repl);
2527 int gsub(const SubString& pat, const String& repl);
2528 int gsub(const char* pat, const String& repl);
2529 int gsub(const char* pat, const char* repl);
2530 int gsub(const Regex& pat, const String& repl);
2536 friend int split(const String& x, String res[], int maxn,
2538 friend int split(const String& x, String res[], int maxn,
2541 friend String common_prefix(const String& x, const String& y,
2543 friend String common_suffix(const String& x, const String& y,
2545 friend String replicate(char c, int n);
2546 friend String replicate(const String& y, int n);
2547 friend String join(String src[], int n, const String& sep);
2551 friend inline String reverse(const String& x);
2552 friend inline String upcase(const String& x);
2553 friend inline String downcase(const String& x);
2554 friend inline String capitalize(const String& x);
2565 char& operator [] (int i);
2566 const char& operator [] (int i) const;
2567 char elem(int i) const;
2568 char firstchar() const;
2569 char lastchar() const;
2573 operator const char*() const;
2574 const char* chars() const;
2579 friend inline ostream& operator<<(ostream& s, const String& x);
2580 friend ostream& operator<<(ostream& s, const SubString& x);
2581 friend istream& operator>>(istream& s, String& x);
2583 friend int readline(istream& s, String& x,
2584 char terminator = '\n',
2585 int discard_terminator = 1);
2589 unsigned int length() const;
2593 void alloc(int newsize);
2597 int allocation() const;
2600 void error(const char* msg) const;
2605 typedef String StrTmp;
2609 int compare(const String& x, const String& y);
2610 int compare(const String& x, const SubString& y);
2611 int compare(const String& x, const char* y);
2612 int compare(const SubString& x, const String& y);
2613 int compare(const SubString& x, const SubString& y);
2614 int compare(const SubString& x, const char* y);
2615 int fcompare(const String& x, const String& y);
2617 extern StrRep _nilStrRep;
2618 extern String _nilString;
2622 inline unsigned int String::length() const { return rep->len; }
2623 inline int String::empty() const { return rep->len == 0; }
2624 inline const char* String::chars() const { return &(rep->s[0]); }
2625 inline int String::allocation() const { return rep->sz; }
2627 inline unsigned int SubString::length() const { return len; }
2628 inline int SubString::empty() const { return len == 0; }
2629 inline const char* SubString::chars() const { return &(S.rep->s[pos]); }
2634 inline String::String()
2635 : rep(&_nilStrRep) {}
2636 inline String::String(const String& x)
2637 : rep(Scopy(0, x.rep)) {}
2638 inline String::String(const char* t)
2639 : rep(Salloc(0, t, -1, -1)) {}
2640 inline String::String(const char* t, int tlen)
2641 : rep(Salloc(0, t, tlen, tlen)) {}
2642 inline String::String(const SubString& y)
2643 : rep(Salloc(0, y.chars(), y.length(), y.length())) {}
2644 inline String::String(char c)
2645 : rep(Salloc(0, &c, 1, 1)) {}
2647 inline String::~String() { if (rep != &_nilStrRep) delete rep; }
2649 inline SubString::SubString(const SubString& x)
2650 :S(x.S), pos(x.pos), len(x.len) {}
2651 inline SubString::SubString(String& x, int first, int l)
2652 :S(x), pos(first), len(l) {}
2654 inline SubString::~SubString() {}
2658 inline String& String::operator = (const String& y)
2660 rep = Scopy(rep, y.rep);
2664 inline String& String::operator=(const char* t)
2666 rep = Salloc(rep, t, -1, -1);
2670 inline String& String::operator=(const SubString& y)
2672 rep = Salloc(rep, y.chars(), y.length(), y.length());
2676 inline String& String::operator=(char c)
2678 rep = Salloc(rep, &c, 1, 1);
2683 inline SubString& SubString::operator = (const char* ys)
2689 inline SubString& SubString::operator = (char ch)
2695 inline SubString& SubString::operator = (const String& y)
2697 assign(y.rep, y.chars(), y.length());
2701 inline SubString& SubString::operator = (const SubString& y)
2703 assign(y.S.rep, y.chars(), y.length());
2709 inline void cat(const String& x, const String& y, String& r)
2711 r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length());
2714 inline void cat(const String& x, const SubString& y, String& r)
2716 r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length());
2719 inline void cat(const String& x, const char* y, String& r)
2721 r.rep = Scat(r.rep, x.chars(), x.length(), y, -1);
2724 inline void cat(const String& x, char y, String& r)
2726 r.rep = Scat(r.rep, x.chars(), x.length(), &y, 1);
2729 inline void cat(const SubString& x, const String& y, String& r)
2731 r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length());
2734 inline void cat(const SubString& x, const SubString& y, String& r)
2736 r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length());
2739 inline void cat(const SubString& x, const char* y, String& r)
2741 r.rep = Scat(r.rep, x.chars(), x.length(), y, -1);
2744 inline void cat(const SubString& x, char y, String& r)
2746 r.rep = Scat(r.rep, x.chars(), x.length(), &y, 1);
2749 inline void cat(const char* x, const String& y, String& r)
2751 r.rep = Scat(r.rep, x, -1, y.chars(), y.length());
2754 inline void cat(const char* x, const SubString& y, String& r)
2756 r.rep = Scat(r.rep, x, -1, y.chars(), y.length());
2759 inline void cat(const char* x, const char* y, String& r)
2761 r.rep = Scat(r.rep, x, -1, y, -1);
2764 inline void cat(const char* x, char y, String& r)
2766 r.rep = Scat(r.rep, x, -1, &y, 1);
2769 inline void cat(const String& a, const String& x, const String& y, String& r)
2771 r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length());
2774 inline void cat(const String& a, const String& x, const SubString& y, String& r)
2776 r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length());
2779 inline void cat(const String& a, const String& x, const char* y, String& r)
2781 r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y, -1);
2784 inline void cat(const String& a, const String& x, char y, String& r)
2786 r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), &y, 1);
2789 inline void cat(const String& a, const SubString& x, const String& y, String& r)
2791 r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length());
2794 inline void cat(const String& a, const SubString& x, const SubString& y, String& r)
2796 r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length());
2799 inline void cat(const String& a, const SubString& x, const char* y, String& r)
2801 r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y, -1);
2804 inline void cat(const String& a, const SubString& x, char y, String& r)
2806 r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), &y, 1);
2809 inline void cat(const String& a, const char* x, const String& y, String& r)
2811 r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y.chars(), y.length());
2814 inline void cat(const String& a, const char* x, const SubString& y, String& r)
2816 r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y.chars(), y.length());
2819 inline void cat(const String& a, const char* x, const char* y, String& r)
2821 r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y, -1);
2824 inline void cat(const String& a, const char* x, char y, String& r)
2826 r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, &y, 1);
2830 inline void cat(const char* a, const String& x, const String& y, String& r)
2832 r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length());
2835 inline void cat(const char* a, const String& x, const SubString& y, String& r)
2837 r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length());
2840 inline void cat(const char* a, const String& x, const char* y, String& r)
2842 r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y, -1);
2845 inline void cat(const char* a, const String& x, char y, String& r)
2847 r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), &y, 1);
2850 inline void cat(const char* a, const SubString& x, const String& y, String& r)
2852 r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length());
2855 inline void cat(const char* a, const SubString& x, const SubString& y, String& r)
2857 r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length());
2860 inline void cat(const char* a, const SubString& x, const char* y, String& r)
2862 r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y, -1);
2865 inline void cat(const char* a, const SubString& x, char y, String& r)
2867 r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), &y, 1);
2870 inline void cat(const char* a, const char* x, const String& y, String& r)
2872 r.rep = Scat(r.rep, a, -1, x, -1, y.chars(), y.length());
2875 inline void cat(const char* a, const char* x, const SubString& y, String& r)
2877 r.rep = Scat(r.rep, a, -1, x, -1, y.chars(), y.length());
2880 inline void cat(const char* a, const char* x, const char* y, String& r)
2882 r.rep = Scat(r.rep, a, -1, x, -1, y, -1);
2885 inline void cat(const char* a, const char* x, char y, String& r)
2887 r.rep = Scat(r.rep, a, -1, x, -1, &y, 1);
2893 inline String& String::operator +=(const String& y)
2895 cat(*this, y, *this);
2899 inline String& String::operator +=(const SubString& y)
2901 cat(*this, y, *this);
2905 inline String& String::operator += (const char* y)
2907 cat(*this, y, *this);
2911 inline String& String:: operator +=(char y)
2913 cat(*this, y, *this);
2921 inline String operator + (const String& x, const String& y) return r;
2926 inline String operator + (const String& x, const SubString& y) return r;
2931 inline String operator + (const String& x, const char* y) return r;
2936 inline String operator + (const String& x, char y) return r;
2941 inline String operator + (const SubString& x, const String& y) return r;
2946 inline String operator + (const SubString& x, const SubString& y) return r;
2951 inline String operator + (const SubString& x, const char* y) return r;
2956 inline String operator + (const SubString& x, char y) return r;
2961 inline String operator + (const char* x, const String& y) return r;
2966 inline String operator + (const char* x, const SubString& y) return r;
2971 inline String reverse(const String& x) return r;
2973 r.rep = Sreverse(x.rep, r.rep);
2976 inline String upcase(const String& x) return r;
2978 r.rep = Supcase(x.rep, r.rep);
2981 inline String downcase(const String& x) return r;
2983 r.rep = Sdowncase(x.rep, r.rep);
2986 inline String capitalize(const String& x) return r;
2988 r.rep = Scapitalize(x.rep, r.rep);
2995 inline void String::prepend(const String& y)
2997 rep = Sprepend(rep, y.chars(), y.length());
3000 inline void String::prepend(const char* y)
3002 rep = Sprepend(rep, y, -1);
3005 inline void String::prepend(char y)
3007 rep = Sprepend(rep, &y, 1);
3010 inline void String::prepend(const SubString& y)
3012 rep = Sprepend(rep, y.chars(), y.length());
3018 inline void String::reverse()
3020 rep = Sreverse(rep, rep);
3024 inline void String::upcase()
3026 rep = Supcase(rep, rep);
3030 inline void String::downcase()
3032 rep = Sdowncase(rep, rep);
3036 inline void String::capitalize()
3038 rep = Scapitalize(rep, rep);
3043 inline char& String::operator [] (int i)
3045 if (((unsigned)i) >= length()) error("invalid index");
3049 inline const char& String::operator [] (int i) const
3051 if (((unsigned)i) >= length()) error("invalid index");
3055 inline char String::elem (int i) const
3057 if (((unsigned)i) >= length()) error("invalid index");
3061 inline char String::firstchar() const
3066 inline char String::lastchar() const
3068 return elem(length() - 1);
3073 inline int String::index(char c, int startpos) const
3075 return search(startpos, length(), c);
3078 inline int String::index(const char* t, int startpos) const
3080 return search(startpos, length(), t);
3083 inline int String::index(const String& y, int startpos) const
3085 return search(startpos, length(), y.chars(), y.length());
3088 inline int String::index(const SubString& y, int startpos) const
3090 return search(startpos, length(), y.chars(), y.length());
3093 inline int String::index(const Regex& r, int startpos) const
3095 int unused; return r.search(chars(), length(), unused, startpos);
3098 inline int String::contains(char c) const
3100 return search(0, length(), c) >= 0;
3103 inline int String::contains(const char* t) const
3105 return search(0, length(), t) >= 0;
3108 inline int String::contains(const String& y) const
3110 return search(0, length(), y.chars(), y.length()) >= 0;
3113 inline int String::contains(const SubString& y) const
3115 return search(0, length(), y.chars(), y.length()) >= 0;
3118 inline int String::contains(char c, int p) const
3120 return match(p, length(), 0, &c, 1) >= 0;
3123 inline int String::contains(const char* t, int p) const
3125 return match(p, length(), 0, t) >= 0;
3128 inline int String::contains(const String& y, int p) const
3130 return match(p, length(), 0, y.chars(), y.length()) >= 0;
3133 inline int String::contains(const SubString& y, int p) const
3135 return match(p, length(), 0, y.chars(), y.length()) >= 0;
3138 inline int String::contains(const Regex& r) const
3140 int unused; return r.search(chars(), length(), unused, 0) >= 0;
3143 inline int String::contains(const Regex& r, int p) const
3145 return r.match(chars(), length(), p) >= 0;
3149 inline int String::matches(const SubString& y, int p) const
3151 return match(p, length(), 1, y.chars(), y.length()) >= 0;
3154 inline int String::matches(const String& y, int p) const
3156 return match(p, length(), 1, y.chars(), y.length()) >= 0;
3159 inline int String::matches(const char* t, int p) const
3161 return match(p, length(), 1, t) >= 0;
3164 inline int String::matches(char c, int p) const
3166 return match(p, length(), 1, &c, 1) >= 0;
3169 inline int String::matches(const Regex& r, int p) const
3171 int l = (p < 0)? -p : length() - p;
3172 return r.match(chars(), length(), p) == l;
3176 inline int SubString::contains(const char* t) const
3178 return S.search(pos, pos+len, t) >= 0;
3181 inline int SubString::contains(const String& y) const
3183 return S.search(pos, pos+len, y.chars(), y.length()) >= 0;
3186 inline int SubString::contains(const SubString& y) const
3188 return S.search(pos, pos+len, y.chars(), y.length()) >= 0;
3191 inline int SubString::contains(char c) const
3193 return S.search(pos, pos+len, c) >= 0;
3196 inline int SubString::contains(const Regex& r) const
3198 int unused; return r.search(chars(), len, unused, 0) >= 0;
3201 inline int SubString::matches(const Regex& r) const
3203 return r.match(chars(), len, 0) == len;
3207 inline int String::gsub(const String& pat, const String& r)
3209 return _gsub(pat.chars(), pat.length(), r.chars(), r.length());
3212 inline int String::gsub(const SubString& pat, const String& r)
3214 return _gsub(pat.chars(), pat.length(), r.chars(), r.length());
3217 inline int String::gsub(const Regex& pat, const String& r)
3219 return _gsub(pat, r.chars(), r.length());
3222 inline int String::gsub(const char* pat, const String& r)
3224 return _gsub(pat, -1, r.chars(), r.length());
3227 inline int String::gsub(const char* pat, const char* r)
3229 return _gsub(pat, -1, r, -1);
3234 inline ostream& operator<<(ostream& s, const String& x)
3236 s << x.chars(); return s;
3241 inline int operator==(const String& x, const String& y)
3243 return compare(x, y) == 0;
3246 inline int operator!=(const String& x, const String& y)
3248 return compare(x, y) != 0;
3251 inline int operator>(const String& x, const String& y)
3253 return compare(x, y) > 0;
3256 inline int operator>=(const String& x, const String& y)
3258 return compare(x, y) >= 0;
3261 inline int operator<(const String& x, const String& y)
3263 return compare(x, y) < 0;
3266 inline int operator<=(const String& x, const String& y)
3268 return compare(x, y) <= 0;
3271 inline int operator==(const String& x, const SubString& y)
3273 return compare(x, y) == 0;
3276 inline int operator!=(const String& x, const SubString& y)
3278 return compare(x, y) != 0;
3281 inline int operator>(const String& x, const SubString& y)
3283 return compare(x, y) > 0;
3286 inline int operator>=(const String& x, const SubString& y)
3288 return compare(x, y) >= 0;
3291 inline int operator<(const String& x, const SubString& y)
3293 return compare(x, y) < 0;
3296 inline int operator<=(const String& x, const SubString& y)
3298 return compare(x, y) <= 0;
3301 inline int operator==(const String& x, const char* t)
3303 return compare(x, t) == 0;
3306 inline int operator!=(const String& x, const char* t)
3308 return compare(x, t) != 0;
3311 inline int operator>(const String& x, const char* t)
3313 return compare(x, t) > 0;
3316 inline int operator>=(const String& x, const char* t)
3318 return compare(x, t) >= 0;
3321 inline int operator<(const String& x, const char* t)
3323 return compare(x, t) < 0;
3326 inline int operator<=(const String& x, const char* t)
3328 return compare(x, t) <= 0;
3331 inline int operator==(const SubString& x, const String& y)
3333 return compare(y, x) == 0;
3336 inline int operator!=(const SubString& x, const String& y)
3338 return compare(y, x) != 0;
3341 inline int operator>(const SubString& x, const String& y)
3343 return compare(y, x) < 0;
3346 inline int operator>=(const SubString& x, const String& y)
3348 return compare(y, x) <= 0;
3351 inline int operator<(const SubString& x, const String& y)
3353 return compare(y, x) > 0;
3356 inline int operator<=(const SubString& x, const String& y)
3358 return compare(y, x) >= 0;
3361 inline int operator==(const SubString& x, const SubString& y)
3363 return compare(x, y) == 0;
3366 inline int operator!=(const SubString& x, const SubString& y)
3368 return compare(x, y) != 0;
3371 inline int operator>(const SubString& x, const SubString& y)
3373 return compare(x, y) > 0;
3376 inline int operator>=(const SubString& x, const SubString& y)
3378 return compare(x, y) >= 0;
3381 inline int operator<(const SubString& x, const SubString& y)
3383 return compare(x, y) < 0;
3386 inline int operator<=(const SubString& x, const SubString& y)
3388 return compare(x, y) <= 0;
3391 inline int operator==(const SubString& x, const char* t)
3393 return compare(x, t) == 0;
3396 inline int operator!=(const SubString& x, const char* t)
3398 return compare(x, t) != 0;
3401 inline int operator>(const SubString& x, const char* t)
3403 return compare(x, t) > 0;
3406 inline int operator>=(const SubString& x, const char* t)
3408 return compare(x, t) >= 0;
3411 inline int operator<(const SubString& x, const char* t)
3413 return compare(x, t) < 0;
3416 inline int operator<=(const SubString& x, const char* t)
3418 return compare(x, t) <= 0;
3424 inline SubString String::_substr(int first, int l)
3426 if (first < 0 || (unsigned)(first + l) > length() )
3427 return SubString(_nilString, 0, 0) ;
3429 return SubString(*this, first, l);
3439 typedef int booleen;
3441 const booleen VRAI=1;
3442 const booleen FAUX=0;
3447 #define valeur_bidon 12345678
3449 #define fors(type, i, imin, imax) for(type i=imin; i< imax; i++)
3450 #define fore(type, i, imin, imax) for(type i=imin; i<=imax; i++)
3452 void verif_nb_param(int argc, char* argv[], int nb_params);
3454 booleen f_exists(String nom);
3457 template<class Type>
3458 inline Type carre(const Type x)
3463 template<class Type>
3464 inline Type cube(const Type x)
3469 template<class Type>
3470 inline Type rac3(const Type x)
3476 return exp(log(x)/3);
3478 return -exp(log(-x)/3);
3481 template<class Type>
3482 inline Type min(const Type a,const Type b)
3487 template<class Type>
3488 inline Type max(const Type a,const Type b)
3493 template<class Type>
3494 inline Type min(const Type a,const Type b,const Type c)
3496 return min(a,min(b,c));
3499 template<class Type>
3500 inline Type max(const Type a,const Type b,const Type c)
3502 return max(a,max(b,c));
3505 template <class Type>
3506 inline void echange(Type& a,Type& b)
3514 String i2S(int n,int l=0);
3516 template <class Type>
3517 inline booleen dans(Type x, Type a, Type b)
3519 return (a<=x) && (x<=b);
3522 template <class Type>
3523 inline Type mabs(Type x)
3525 return (x<0) ? -x : x ;
3528 template <class Type>
3529 inline booleen dans2(Type x, Type a, Type b)
3532 return mabs(x-(a+b)/2) <= mabs((a-b)/2) ;
3535 template <class Type>
3536 inline booleen proche(Type x, Type y, Type eps)
3538 return mabs(x-y)<eps;
3541 template <class Type>
3542 inline int arrondi(Type x)
3547 template<class Type>
3548 unsigned char arrondi_ng(Type x)
3550 if((-0.5<x) && (x<255.5))
3551 return (unsigned char)(x+0.5);
3554 if(x<-3.0 || x>268.0)
3555 cerr<<"arrondi_ng : attention x= "<<x<<endl;
3564 template<class Type>
3565 unsigned char arrondi_ng_err(Type x)
3567 if((-0.5<x) && (x<255.5))
3568 return (unsigned char)(x+0.5);
3578 inline int nb_diff2(int a,int b)
3586 inline int nb_diff3(int a,int b,int c)
3589 return nb_diff2(b,c);
3591 return 1+nb_diff2(b,c);
3594 inline int nb_diff4(int a,int b,int c,int d)
3596 if(a==b || a==c || a==d)
3597 return nb_diff3(b,c,d);
3599 return 1+nb_diff3(b,c,d);
3602 float echMSB(float a);
3609 template<class Type>
3610 void lis_param(istream& f, Type& param)
3613 f.ignore(20000,'\n');
3616 void lis_chaine(istream& s, String chaine);
3618 template<class Type_dest, class Type_source>
3619 void convert(Type_dest& dest, const Type_source& source)
3642 depl2D() : x(0.0), y(0.0)
3646 depl2D(double xx, double yy) : x(xx), y(yy)
3650 return max(mabs(x),mabs(y));
3654 ostream& operator<<(ostream& s, depl2D m);
3659 Mouvement* read_mv(istream& s);
3667 Mouvement(double i_t_x, double i_t_y, double i_centre_x, double i_centre_y);
3668 virtual void Id()=0;
3669 virtual void centre(double x,double y)=0;
3670 virtual void applique(double& xx, double& yy, double x, double y) const=0;
3671 virtual void applique(float& xx, float& yy, float x, float y) const=0;
3672 virtual depl2D calc_depl(double x, double y)=0;
3673 double Centre_x() const
3677 double Centre_y() const
3682 virtual int nb_param() const=0;
3685 virtual void init_from_vect_d(const double param[])=0;
3686 virtual void init_vect_d(double param[]) const=0;
3687 virtual void init_from_vect_f(const float param[])=0;
3688 virtual void init_vect_f(float param[]) const=0;
3690 virtual Mouvement* clone() const=0;
3691 virtual String nom() const=0;
3692 virtual void dump(ostream& s) const=0;
3694 virtual booleen trop_grand(float seuil) const=0;
3695 booleen trop_grand2(float seuil, float seuil_t) const;
3698 ostream& operator<<(ostream& s, const Mouvement& m);
3699 Mouvement* read_mv(istream& s);
3706 class LS : public Mouvement
3713 LS(double i_t_x, double i_t_y, double i_k, double i_theta, double i_centre_x, double i_centre_y);
3716 int nb_param() const;
3717 void update(double d_t_x, double d_t_y, double d_k, double d_theta);
3718 void init_from_vect_d(const double param[]);
3719 void init_vect_d(double param[]) const;
3720 void init_from_vect_f(const float param[]);
3721 void init_vect_f(float param[]) const;
3723 void dump(ostream& s) const;
3726 ostream& operator<<(ostream& s, const LS& m);
3737 class AFF: public Mouvement
3746 AFF(double i_t_x, double i_t_y,
3747 double i_a, double i_b, double i_c, double i_d,
3748 double i_centre_x, double i_centre_y);
3751 int nb_param() const;
3752 void init_from_vect_d(const double param[]);
3753 void init_vect_d(double param[]) const;
3754 void init_from_vect_f(const float param[]);
3755 void init_vect_f(float param[]) const;
3758 void dump(ostream& s) const;
3761 ostream& operator<<(ostream& s, const AFF& m);
3775 LS::LS(double i_t_x, double i_t_y,
3776 double i_k, double i_theta,
3777 double i_centre_x, double i_centre_y) :
3778 Mouvement(i_t_x, i_t_y, i_centre_x, i_centre_y),
3785 s>>k>>theta>>t_x>>theta>>k>>t_y>>centre_x>>centre_y;
3788 LS::LS(const AFF& aff): Mouvement(aff.t_x, aff.t_y, aff.centre_x, aff.centre_y)
3790 const double eps_k=1E-6;
3791 if(mabs(aff.a-aff.d)>eps_k)
3793 cout<<"AFF_2_LS : delta k < "<<eps_k<<endl;
3794 cout<<aff.a<<endl<<aff.d<<endl;
3800 const double eps_theta=1E-6;
3801 if(mabs(aff.c+aff.b)>eps_theta)
3803 cout<<"AFF_2_LS : delta theta < "<<eps_theta<<endl;
3807 theta=(aff.c-aff.b)/2;
3810 int LS::nb_param() const
3815 void LS::update(double d_t_x,
3826 void LS::init_from_vect_d(const double param[])
3834 void LS::init_vect_d(double param[]) const
3842 void LS::init_from_vect_f(const float param[])
3850 void LS::init_vect_f(float param[]) const
3872 void LS::dump(ostream& s) const
3874 const int largeur=14;
3875 s.setf(ios::left,ios::adjustfield);
3877 <<setw(largeur)<<k<<setw(largeur)<<-theta<<setw(largeur)<<t_x<<endl
3878 <<setw(largeur)<<theta<<setw(largeur)<<k<<setw(largeur)<<t_y<<endl
3879 <<centre_x<<' '<<centre_y<<endl;
3882 ostream& operator<<(ostream& s, const LS& m)