The world's most popular open source database
00001 /* Copyright (C) 2003 MySQL AB 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; either version 2 of the License, or 00006 (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 00016 00017 #ifndef NDBOUT_H 00018 #define NDBOUT_H 00019 00020 #ifdef __cplusplus 00021 00022 #include <ndb_types.h> 00023 #include <util/BaseString.hpp> 00024 00031 /* 00032 Example usage: 00033 00034 #include "NdbOut.hpp" 00035 00036 / * Use ndbout as you would use cout: 00037 00038 ndbout << "Hello World! "<< 1 << " Hello again" 00039 << 67 << anIntegerVar << "Hup << endl; 00040 00041 00042 / * Use ndbout_c as you would use printf: 00043 00044 ndbout_c("Hello World %d\n", 1); 00045 */ 00046 00047 class NdbOut; 00048 class OutputStream; 00049 class NullOutputStream; 00050 00051 /* Declare a static variable of NdbOut as ndbout */ 00052 extern NdbOut ndbout; 00053 00054 class NdbOut 00055 { 00056 public: 00057 NdbOut& operator<<(NdbOut& (* _f)(NdbOut&)); 00058 NdbOut& operator<<(Int8); 00059 NdbOut& operator<<(Uint8); 00060 NdbOut& operator<<(Int16); 00061 NdbOut& operator<<(Uint16); 00062 NdbOut& operator<<(Int32); 00063 NdbOut& operator<<(Uint32); 00064 NdbOut& operator<<(Int64); 00065 NdbOut& operator<<(Uint64); 00066 NdbOut& operator<<(long unsigned int); 00067 NdbOut& operator<<(const char*); 00068 NdbOut& operator<<(const unsigned char*); 00069 NdbOut& operator<<(BaseString &); 00070 NdbOut& operator<<(const void*); 00071 NdbOut& operator<<(float); 00072 NdbOut& operator<<(double); 00073 NdbOut& endline(void); 00074 NdbOut& flushline(void); 00075 NdbOut& setHexFormat(int _format); 00076 00077 NdbOut(OutputStream &); 00078 virtual ~NdbOut(); 00079 00080 void print(const char * fmt, ...); 00081 void println(const char * fmt, ...); 00082 00083 OutputStream * m_out; 00084 private: 00085 int isHex; 00086 }; 00087 00088 inline NdbOut& NdbOut::operator<<(NdbOut& (* _f)(NdbOut&)) { 00089 (* _f)(*this); 00090 return * this; 00091 } 00092 00093 inline NdbOut& endl(NdbOut& _NdbOut) { 00094 return _NdbOut.endline(); 00095 } 00096 00097 inline NdbOut& flush(NdbOut& _NdbOut) { 00098 return _NdbOut.flushline(); 00099 } 00100 00101 inline NdbOut& hex(NdbOut& _NdbOut) { 00102 return _NdbOut.setHexFormat(1); 00103 } 00104 00105 inline NdbOut& dec(NdbOut& _NdbOut) { 00106 return _NdbOut.setHexFormat(0); 00107 } 00108 extern "C" 00109 void ndbout_c(const char * fmt, ...); 00110 00111 class FilteredNdbOut : public NdbOut { 00112 public: 00113 FilteredNdbOut(OutputStream &, int threshold = 0, int level = 0); 00114 virtual ~FilteredNdbOut(); 00115 00116 void setLevel(int i); 00117 void setThreshold(int i); 00118 00119 int getLevel() const; 00120 int getThreshold() const; 00121 00122 private: 00123 int m_threshold, m_level; 00124 OutputStream * m_org; 00125 NullOutputStream * m_null; 00126 }; 00127 00128 #else 00129 void ndbout_c(const char * fmt, ...); 00130 #endif 00131 00132 #endif
1.4.7

