/usr/include/tjutils/tjstream.h is in libodin-dev 1.8.5-2ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | /***************************************************************************
tjstream.h - description
-------------------
begin : Sun Jun 13 2004
copyright : (C) 2001 by Thies H. Jochimsen
email : jochimse@cns.mpg.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef TJSTREAM_H
#define TJSTREAM_H
#include <tjutils/tjstd.h>
// Macros, includes and typedefs are handled in tjstd.h to avoid circular dependencies
typedef STD_ostream& (*streammanipulator)(STD_ostream&);
/**
* @addtogroup tjutils
* @{
*/
#ifdef STREAM_REPLACEMENT
class tjstd_ostream {
public:
tjstd_ostream() {}
virtual ~tjstd_ostream() {}
inline tjstd_ostream& operator<<(char v) {append2buff(STD_string(1,v)); return *this;}
inline tjstd_ostream& operator<<(unsigned char v) {append2buff(STD_string(1,v)); return *this;}
inline tjstd_ostream& operator<<(signed char v) {append2buff(STD_string(1,v)); return *this;}
inline tjstd_ostream& operator<<(const char* v) {append2buff(v); return *this;}
inline tjstd_ostream& operator<<(int v) {buff_int(v); return *this;}
inline tjstd_ostream& operator<<(unsigned int v) {buff_int(v); return *this;}
inline tjstd_ostream& operator<<(long v) {buff_int(v); return *this;}
inline tjstd_ostream& operator<<(unsigned long v) {buff_int(v); return *this;}
#ifdef HAVE_LONG_LONG
inline tjstd_ostream& operator<<(long long v) {buff_int(v); return *this;}
#endif
inline tjstd_ostream& operator<<(short v) {buff_int(v); return *this;}
inline tjstd_ostream& operator<<(unsigned short v){buff_int(v); return *this;}
inline tjstd_ostream& operator<<(bool v) {if(v) append2buff("true"); else append2buff("false"); return *this;}
inline tjstd_ostream& operator<<(double v) {buff_float(v); return *this;}
inline tjstd_ostream& operator<<(float v) {buff_float(v); return *this;}
inline tjstd_ostream& operator<<(streammanipulator v) {v(*this); return *this;}
private:
// disable copying
tjstd_ostream(const tjstd_ostream&) {}
tjstd_ostream& operator = (const tjstd_ostream&) {return *this;}
virtual void append2buff(const STD_string& str) {} // do nothing by default, i.e. for cout/cerr
void buff_float(float f);
void buff_int(int i);
};
////////////////////////////////////////////////////////////////////////////
class tjstd_ostringstream : public tjstd_ostream {
public:
tjstd_ostringstream() {}
~tjstd_ostringstream() {}
const STD_string& str() const {return buff;}
private:
// disable copying
tjstd_ostringstream(const tjstd_ostringstream&) {}
tjstd_ostringstream& operator = (const tjstd_ostringstream&) {return *this;}
// overloaded from tjstd_ostream
void append2buff(const STD_string& str) {buff+=str;}
STD_string buff;
};
////////////////////////////////////////////////////////////////////////////
class tjstd_ofstream : public tjstd_ostream {
public:
tjstd_ofstream(const char* filename="");
~tjstd_ofstream() {close();}
void close();
bool bad() {return !file_ptr;}
private:
// disable default construction and copying
tjstd_ofstream(const tjstd_ofstream&) {}
tjstd_ofstream& operator = (const tjstd_ofstream&) {return *this;}
// overloaded from tjstd_ostream
void append2buff(const STD_string& str);
void* file_ptr;
};
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
class tjstd_istream {
public:
tjstd_istream() {}
inline tjstd_istream& operator>>(char) {return *this;}
inline tjstd_istream& operator>>(unsigned char) {return *this;}
inline tjstd_istream& operator>>(signed char) {return *this;}
inline tjstd_istream& operator>>(const char *) {return *this;}
inline tjstd_istream& operator>>(int) {return *this;}
inline tjstd_istream& operator>>(unsigned int) {return *this;}
inline tjstd_istream& operator>>(long) {return *this;}
inline tjstd_istream& operator>>(unsigned long) {return *this;}
#ifdef HAVE_LONG_LONG
inline tjstd_istream& operator>>(long long) {return *this;}
#endif
inline tjstd_istream& operator>>(short) {return *this;}
inline tjstd_istream& operator>>(unsigned short){return *this;}
inline tjstd_istream& operator>>(bool) {return *this;}
inline tjstd_istream& operator>>(double) {return *this;}
inline tjstd_istream& operator>>(float) {return *this;}
inline tjstd_istream& get(char&) {return *this;}
inline tjstd_istream& putback(char) {return *this;}
operator void* () const {return 0;} // stream is always empty
};
inline tjstd_istream& tjstd_getline(tjstd_istream& is, STD_string&) {return is;}
////////////////////////////////////////////////////////////////////////////
class tjstd_ifstream : public tjstd_istream {
public:
tjstd_ifstream(const char* ="") {}
void close() {}
bool bad() {return false;}
};
////////////////////////////////////////////////////////////////////////////
static tjstd_ostream tjstd_cout;
static tjstd_ostream tjstd_cerr;
static tjstd_istream tjstd_cin;
inline STD_ostream& tjstd_endl(STD_ostream& os) {return os << "\n";}
inline STD_ostream& tjstd_flush(STD_ostream& os) {return os;}
inline const char* tjstd_setprecision(unsigned int) {return "";}
#endif
/** @}
*/
#endif
|