Fennel: /home/pub/open/dev/fennel/tuple/TuplePrinter.cpp Source File (original) (raw)

00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 #include "fennel/common/CommonPreamble.h" 00025 #include "fennel/tuple/TuplePrinter.h" 00026 #include "fennel/tuple/TupleDescriptor.h" 00027 00028 #include <boost/io/ios_state.hpp> 00029 00030 FENNEL_BEGIN_CPPFILE("$Id: //open/dev/fennel/tuple/TuplePrinter.cpp#10 $"); 00031 00032 TuplePrinter::TuplePrinter() 00033 { 00034 pStream = NULL; 00035 } 00036 00037 void TuplePrinter::print( 00038 std::ostream &stream, 00039 TupleDescriptor const &tupleDesc, 00040 TupleData const &tupleData) 00041 { 00042 boost::io::ios_all_saver streamStateSaver(stream); 00043 pStream = &stream; 00044 iValue = 0; 00045 (*pStream) << "[ "; 00046 tupleDesc.visit(tupleData,*this,false); 00047 (*pStream) << " ]"; 00048 pStream = NULL; 00049 } 00050 00051 void TuplePrinter::preVisitValue() 00052 { 00053 if (iValue) { 00054 (*pStream) << ", "; 00055 } 00056 } 00057 00058 void TuplePrinter::postVisitValue() 00059 { 00060 ++iValue; 00061 } 00062 00063 void TuplePrinter::visitString(std::string s) 00064 { 00065 preVisitValue(); 00066
00067 (*pStream) << "'" << s << "'"; 00068 postVisitValue(); 00069 } 00070 00071 void TuplePrinter::visitChars(char const c, TupleStorageByteLength n) 00072 { 00073 std::string s(c,n); 00074 visitString(s); 00075 } 00076 00077 void TuplePrinter::visitUnicodeChars(Ucs2ConstBuffer c, uint n) 00078 { 00079
00080 visitBytes(c, n
2); 00081 } 00082 00083 void TuplePrinter::visitUnsignedInt(uint64_t i) 00084 { 00085 preVisitValue(); 00086 (*pStream) << i; 00087 postVisitValue(); 00088 } 00089 00090 void TuplePrinter::visitSignedInt(int64_t i) 00091 { 00092 preVisitValue(); 00093
00094
00095 (*pStream) << i; 00096 postVisitValue(); 00097 } 00098 00099 void TuplePrinter::visitDouble(double d) 00100 { 00101 preVisitValue(); 00102 (*pStream) << d; 00103 postVisitValue(); 00104 } 00105 00106 void TuplePrinter::visitFloat(float f) 00107 { 00108 preVisitValue(); 00109 (*pStream) << f; 00110 postVisitValue(); 00111 } 00112 00113 void TuplePrinter::visitBoolean(bool b) 00114 { 00115 preVisitValue(); 00116 if (b) { 00117 (*pStream) << "true"; 00118 } else { 00119 (*pStream) << "false"; 00120 } 00121 postVisitValue(); 00122 } 00123 00124 void TuplePrinter::visitBytes(void const *v, TupleStorageByteLength iBytes) 00125 { 00126 preVisitValue(); 00127 if (!v) { 00128 (pStream) << "NULL"; 00129 } else { 00130 hexDump(pStream,v,iBytes); 00131 } 00132 postVisitValue(); 00133 } 00134 00135 void TuplePrinter::preVisitDocument(std::string) 00136 { 00137
00138 } 00139 00140 void TuplePrinter::postVisitDocument() 00141 { 00142
00143 } 00144 00145 void TuplePrinter::preVisitTable(std::string) 00146 { 00147
00148 } 00149 00150 void TuplePrinter::postVisitTable() 00151 { 00152
00153 } 00154 00155 void TuplePrinter::preVisitRow() 00156 { 00157
00158 } 00159 00160 void TuplePrinter::postVisitRow() 00161 { 00162
00163 } 00164 00165 void TuplePrinter::visitAttribute(std::string) 00166 { 00167
00168 } 00169 00170 void TuplePrinter::visitPageId(PageId) 00171 { 00172
00173 } 00174 00175 void TuplePrinter::visitPageOwnerId(PageOwnerId) 00176 { 00177
00178 } 00179 00180 void TuplePrinter::visitSegByteId(SegByteId) 00181 { 00182
00183 } 00184 00185 void TuplePrinter::visitFormatted(char const *) 00186 { 00187
00188 } 00189 00190 FENNEL_END_CPPFILE("$Id: //open/dev/fennel/tuple/TuplePrinter.cpp#10 $"); 00191 00192