22 #include <tjutils/tjstd.h>
27 typedef STD_ostream& (*streammanipulator)(STD_ostream&);
35 #ifdef STREAM_REPLACEMENT
41 virtual ~tjstd_ostream() {}
43 inline tjstd_ostream& operator<<(
char v) {append2buff(STD_string(1,v));
return *
this;}
44 inline tjstd_ostream& operator<<(
unsigned char v) {append2buff(STD_string(1,v));
return *
this;}
45 inline tjstd_ostream& operator<<(
signed char v) {append2buff(STD_string(1,v));
return *
this;}
46 inline tjstd_ostream& operator<<(
const char* v) {append2buff(v);
return *
this;}
47 inline tjstd_ostream& operator<<(
int v) {buff_int(v);
return *
this;}
48 inline tjstd_ostream& operator<<(
unsigned int v) {buff_int(v);
return *
this;}
49 inline tjstd_ostream& operator<<(
long v) {buff_int(v);
return *
this;}
50 inline tjstd_ostream& operator<<(
unsigned long v) {buff_int(v);
return *
this;}
52 inline tjstd_ostream& operator<<(
long long v) {buff_int(v);
return *
this;}
54 inline tjstd_ostream& operator<<(
short v) {buff_int(v);
return *
this;}
55 inline tjstd_ostream& operator<<(
unsigned short v){buff_int(v);
return *
this;}
56 inline tjstd_ostream& operator<<(
bool v) {
if(v) append2buff(
"true");
else append2buff(
"false");
return *
this;}
57 inline tjstd_ostream& operator<<(
double v) {buff_float(v);
return *
this;}
58 inline tjstd_ostream& operator<<(
float v) {buff_float(v);
return *
this;}
59 inline tjstd_ostream& operator<<(streammanipulator v) {v(*
this);
return *
this;}
65 tjstd_ostream(
const tjstd_ostream&) {}
66 tjstd_ostream& operator = (
const tjstd_ostream&) {
return *
this;}
68 virtual void append2buff(
const STD_string& str) {}
70 void buff_float(
float f);
77 class tjstd_ostringstream :
public tjstd_ostream {
80 tjstd_ostringstream() {}
81 ~tjstd_ostringstream() {}
83 const STD_string& str()
const {
return buff;}
88 tjstd_ostringstream(
const tjstd_ostringstream&) {}
89 tjstd_ostringstream& operator = (
const tjstd_ostringstream&) {
return *
this;}
92 void append2buff(
const STD_string& str) {buff+=str;}
99 class tjstd_ofstream :
public tjstd_ostream {
103 tjstd_ofstream(
const char* filename=
"");
104 ~tjstd_ofstream() {close();}
108 bool bad() {
return !file_ptr;}
113 tjstd_ofstream(
const tjstd_ofstream&) {}
114 tjstd_ofstream& operator = (
const tjstd_ofstream&) {
return *
this;}
117 void append2buff(
const STD_string& str);
129 class tjstd_istream {
134 inline tjstd_istream& operator>>(
char) {
return *
this;}
135 inline tjstd_istream& operator>>(
unsigned char) {
return *
this;}
136 inline tjstd_istream& operator>>(
signed char) {
return *
this;}
137 inline tjstd_istream& operator>>(
const char *) {
return *
this;}
138 inline tjstd_istream& operator>>(
int) {
return *
this;}
139 inline tjstd_istream& operator>>(
unsigned int) {
return *
this;}
140 inline tjstd_istream& operator>>(
long) {
return *
this;}
141 inline tjstd_istream& operator>>(
unsigned long) {
return *
this;}
142 #ifdef HAVE_LONG_LONG
143 inline tjstd_istream& operator>>(
long long) {
return *
this;}
145 inline tjstd_istream& operator>>(
short) {
return *
this;}
146 inline tjstd_istream& operator>>(
unsigned short){
return *
this;}
147 inline tjstd_istream& operator>>(
bool) {
return *
this;}
148 inline tjstd_istream& operator>>(
double) {
return *
this;}
149 inline tjstd_istream& operator>>(
float) {
return *
this;}
151 inline tjstd_istream& get(
char&) {
return *
this;}
152 inline tjstd_istream& putback(
char) {
return *
this;}
154 operator void* ()
const {
return 0;}
158 inline tjstd_istream& tjstd_getline(tjstd_istream& is, STD_string&) {
return is;}
164 class tjstd_ifstream :
public tjstd_istream {
167 tjstd_ifstream(
const char* =
"") {}
169 bool bad() {
return false;}
175 static tjstd_ostream tjstd_cout;
176 static tjstd_ostream tjstd_cerr;
177 static tjstd_istream tjstd_cin;
179 inline STD_ostream& tjstd_endl(STD_ostream& os) {
return os <<
"\n";}
180 inline STD_ostream& tjstd_flush(STD_ostream& os) {
return os;}
181 inline const char* tjstd_setprecision(
unsigned int) {
return "";}