home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 31
/
CDASC_31_1996_juillet_aout.iso
/
vrac
/
cuj0796.zip
/
COLNER.ZIP
/
STRING.CPP
< prev
Wrap
C/C++ Source or Header
|
1996-05-08
|
2KB
|
66 lines
#include <iomanip.h>
#ifdef _MSC_VER // for Microsoft's parameterized io manipulators
#define CAST_IOMANIP(CLASS) \
inline CLASS& operator \
<<(CLASS& _s, const SMANIP(int)& _f) { \
(ostream&)_s << _f ; return _s; \
} \
inline CLASS& operator \
<<(CLASS& _s, const SMANIP(long)& _f) { \
(ostream&)_s << _f ; return _s; \
}
#else // for Borland's template class io manipulators
#define CAST_IOMANIP(CLASS) \
inline CLASS& operator \
<<(CLASS& _s, smanip<int>& _f) { \
(ostream&)_s << _f ; \
return _s; \
} \
inline CLASS& operator \
<<(CLASS& _s, smanip<long>& _f) { \
(ostream&)_s << _f ; \
return _s; \
}
#endif
class
String : public ostrstream{
String& replace(const char * const str);
public:
CAST_INJECTORS(String)
String() : ostrstream(){}
String(const char * const s){
(ostrstream&)*this << s;
}
String(String& str){
if(str.notNull())
(ostrstream&)*this << (const char * const)str;
}
String&
testType(){ return *this;}
String&
setNull();
int
notNull(){ return rdbuf()->out_waiting();}
int
isNull(){ return !notNull();}
String& operator
= (const char * const val) {
return replace(val);
}
int operator
!= ( String& val) {
return (strcmp((char*)*this,(char*)val) != 0);
}
int operator
== ( String& val) {
return !strcmp((char*)*this,(char*)val);
}
operator char* (void);
};
inline ostream& operator
<<(ostream& out, String& s){
return (out << (char *)s);
}
CAST_IOMANIP(String)
#endif