00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #pragma once
00018
00019 #pragma warning(push)
00020 #pragma warning( disable : 4610)
00021 #pragma warning( disable : 4512)
00022
00023
00024 namespace TestToolBox
00025 {
00026
00027
00028
00029
00030
00031
00032
00033 const unsigned char M_NULL = 0x00;
00034 const unsigned char M_STDOUT = 0x01;
00035 const unsigned char M_OUTFILE = 0x02;
00036 const unsigned char M_RPTFILE = 0x04;
00037 const unsigned char M_ALL = M_STDOUT | M_OUTFILE | M_RPTFILE;
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 class TestStream {
00055
00056 public:
00057
00058
00059
00060
00061 TestStream(
00062 std::fstream* in_pOutFile = 0,
00063 std::fstream* in_pRptFile = 0);
00064
00065
00066
00067
00068
00069 void SetMode (unsigned char in_newMode);
00070
00071
00072
00073 void ResetMode (void);
00074
00075
00076 unsigned char GetMode (void);
00077
00078
00079
00080 void SetStreamActivation (
00081 unsigned char in_streamsToActivate);
00082
00083 unsigned char GetStreamActivation (void);
00084
00085
00086 int width(int in_newWidth);
00087 int width(void) const;
00088
00089
00090 long setf (long in_flags);
00091 long setf (long in_flags, long in_mask);
00092 long unsetf (long in_flags);
00093
00094
00095
00096 TestStream& TestStream::operator << (std::string in_item);
00097 TestStream& TestStream::operator << (unsigned char* in_item);
00098 TestStream& TestStream::operator << (const char* in_item);
00099 TestStream& TestStream::operator << (char in_item);
00100 TestStream& TestStream::operator << (unsigned char in_item);
00101 TestStream& TestStream::operator << (short in_item);
00102 TestStream& TestStream::operator << (unsigned short in_item);
00103 TestStream& TestStream::operator << (int in_item);
00104 TestStream& TestStream::operator << (unsigned int in_item);
00105 TestStream& TestStream::operator << (long in_item);
00106 TestStream& TestStream::operator << (unsigned long in_item);
00107 TestStream& TestStream::operator << (float in_item);
00108 TestStream& TestStream::operator << (double in_item);
00109 TestStream& TestStream::operator << (long double in_item);
00110
00111
00112
00113 TestStream& operator << ( std::ostream& (*f) (std::ostream&) );
00114 TestStream& operator << ( std::ios& (*f) (std::ios&) );
00115
00116
00117
00118
00119 TestStream& write (const signed char* in_pCh, int in_count);
00120 TestStream& write (const unsigned char* in_pCh, int in_count);
00121 TestStream& write (const char* in_pCh, int in_count)
00122 {return write ((const signed char*) in_pCh, in_count);}
00123
00124 private:
00125
00126
00127
00128 std::fstream* m_pOutFile;
00129
00130
00131 std::fstream* m_pRptFile;
00132
00133
00134 unsigned char m_mode;
00135
00136
00137
00138 unsigned char m_baseMode;
00139
00140
00141 unsigned char m_allowedStreams;
00142
00143 private:
00144
00145
00146 bool Selected (
00147 unsigned char in_mode) const;
00148
00149
00150 };
00151
00152
00153
00154
00155
00156
00157
00158
00159 inline void TestStream::SetMode (
00160 unsigned char in_newMode)
00161 {m_mode = in_newMode;};
00162
00163 inline void TestStream::ResetMode (void)
00164 {m_mode = m_baseMode;};
00165
00166 inline void TestStream::SetStreamActivation (
00167 unsigned char in_allowedStreams)
00168 {m_allowedStreams = in_allowedStreams;}
00169
00170 inline unsigned char TestStream::GetStreamActivation (void)
00171 {return m_allowedStreams;}
00172
00173 inline unsigned char TestStream::GetMode (void)
00174 {return m_mode;};
00175
00176 inline bool TestStream::Selected (
00177 unsigned char in_mode) const
00178 {return (m_allowedStreams & m_baseMode & m_mode & in_mode) != 0;};
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192 #ifdef _WINDLL
00193
00194
00195 class NullStream : public iostream
00196 {
00197 public:
00198 void setMode (byte ) {};
00199 int width(int ){return 0;};
00200 int width(void) const {return 0;};
00201 long setf (long ){return 0;};
00202 long setf (long , long ){return 0;};
00203 long unsetf (long ){return 0;};
00204 NullStream& NullStream::operator << (char* )
00205 { return *this;};
00206 NullStream& NullStream::operator << (unsigned char* )
00207 { return *this;};
00208 NullStream& NullStream::operator << (const char* )
00209 { return *this;};
00210 NullStream& NullStream::operator << (char )
00211 { return *this;};
00212 NullStream& NullStream::operator << (unsigned char )
00213 { return *this;};
00214 NullStream& NullStream::operator << (short )
00215 { return *this;};
00216 NullStream& NullStream::operator << (unsigned short )
00217 { return *this;};
00218 NullStream& NullStream::operator << (int )
00219 { return *this;};
00220 NullStream& NullStream::operator << (unsigned int )
00221 { return *this;};
00222 NullStream& NullStream::operator << (long )
00223 { return *this;};
00224 NullStream& NullStream::operator << (unsigned long )
00225 { return *this;};
00226 NullStream& NullStream::operator << (float )
00227 { return *this;};
00228 NullStream& NullStream::operator << (double )
00229 { return *this;};
00230 NullStream& NullStream::operator << (long double )
00231 { return *this;};
00232 NullStream& operator << ( ostream& (* ) (ostream&) )
00233 { return *this;};
00234 NullStream& operator << ( ios& (* ) (ios&) )
00235 { return *this;};
00236 NullStream& write (const char* , int )
00237 { return *this;};
00238 NullStream& write (const unsigned char* , int )
00239 { return *this;};
00240 NullStream& write (const signed char* , int )
00241 { return *this;};
00242
00243 };
00244
00245
00246 extern NullStream cin;
00247 extern NullStream cout;
00248 extern NullStream cerr;
00249
00250 #endif // ifdef _WINDLL
00251
00252
00253
00254
00255
00256
00257
00258 };
00259
00260
00261 #pragma warning(pop)
00262
00263