Go to the documentation of this file.00001
00015 #include "OutputBuilderText.hpp"
00016
00017 namespace OA {
00018
00019 int gNestedObjects = 0;
00020 int gIndentLevel = 0;
00021 ostream &indt(ostream &os)
00022 {
00023 os << '\n';
00024 os.flush();
00025 for(int i = 0; i < gIndentLevel; i++) { os << " "; }
00026 return os;
00027 }
00028
00029 ostream &pushIndt(ostream &os)
00030 {
00031 gIndentLevel++;
00032 return os;
00033 }
00034
00035 ostream &popIndt(ostream &os)
00036 {
00037 gIndentLevel--;
00038 return os;
00039 }
00040
00041 ostream &black(ostream &os) { os << "\033[30m"; return os; }
00042 ostream &red(ostream &os) { os << "\033[31m"; return os; }
00043 ostream &green(ostream &os) { os << "\033[32m"; return os; }
00044 ostream &yellow(ostream &os) { os << "\033[33m"; return os; }
00045 ostream &blue(ostream &os) { os << "\033[34m"; return os; }
00046 ostream &magenta(ostream &os) { os << "\033[35m"; return os; }
00047 ostream &purple(ostream &os) { os << "\033[35m"; return os; }
00048 ostream &cyan(ostream &os) { os << "\033[36m"; return os; }
00049 ostream &white(ostream &os) { os << "\033[37m"; return os; }
00050 ostream &brBlack(ostream &os) { os << "\033[90m"; return os; }
00051 ostream &darkGray(ostream &os) { os << "\033[90m"; return os; }
00052 ostream &darkGrey(ostream &os) { os << "\033[90m"; return os; }
00053 ostream &brRed(ostream &os) { os << "\033[91m"; return os; }
00054 ostream &brGreen(ostream &os) { os << "\033[92m"; return os; }
00055 ostream &brYellow(ostream &os) { os << "\033[93m"; return os; }
00056 ostream &brBlue(ostream &os) { os << "\033[94m"; return os; }
00057 ostream &brMagenta(ostream &os) { os << "\033[95m"; return os; }
00058 ostream &brPurple(ostream &os) { os << "\033[95m"; return os; }
00059 ostream &brCyan(ostream &os) { os << "\033[96m"; return os; }
00060 ostream &brWhite(ostream &os) { os << "\033[97m"; return os; }
00061
00062 ostream &blackBG(ostream &os) { os << "\033[40m"; return os; }
00063 ostream &redBG(ostream &os) { os << "\033[41m"; return os; }
00064 ostream &greenBG(ostream &os) { os << "\033[42m"; return os; }
00065 ostream &yellowBG(ostream &os) { os << "\033[43m"; return os; }
00066 ostream &blueBG(ostream &os) { os << "\033[44m"; return os; }
00067 ostream &magentaBG(ostream &os) { os << "\033[45m"; return os; }
00068 ostream &purpleBG(ostream &os) { os << "\033[45m"; return os; }
00069 ostream &cyanBG(ostream &os) { os << "\033[46m"; return os; }
00070 ostream &whiteBG(ostream &os) { os << "\033[47m"; return os; }
00071 ostream &brBlackBG(ostream &os) { os << "\033[100m"; return os; }
00072 ostream &darkGrayBG(ostream &os) { os << "\033[100m"; return os; }
00073 ostream &darkGreyBG(ostream &os) { os << "\033[100m"; return os; }
00074 ostream &brRedBG(ostream &os) { os << "\033[101m"; return os; }
00075 ostream &brGreenBG(ostream &os) { os << "\033[102m"; return os; }
00076 ostream &brYellowBG(ostream &os) { os << "\033[103m"; return os; }
00077 ostream &brBlueBG(ostream &os) { os << "\033[104m"; return os; }
00078 ostream &brMagentaBG(ostream &os) { os << "\033[105m"; return os; }
00079 ostream &brPurpleBG(ostream &os) { os << "\033[105m"; return os; }
00080 ostream &brCyanBG(ostream &os) { os << "\033[106m"; return os; }
00081 ostream &brWhiteBG(ostream &os) { os << "\033[107m"; return os; }
00082
00083 ostream &boldOn(ostream &os) { os << "\033[1m"; return os; }
00084 ostream &underlineOn(ostream &os) { os << "\033[4m"; return os; }
00085 ostream &blinkOn(ostream &os) { os << "\033[5m"; return os; }
00086
00087 ostream &boldOff(ostream &os) { os << "\033[22m"; return os; }
00088 ostream &underlineOff(ostream &os) { os << "\033[24m"; return os; }
00089 ostream &blinkOff(ostream &os) { os << "\033[25m"; return os; }
00090
00091 ostream &resetColor(ostream &os) { os << "\033[0m"; return os; }
00092
00093
00094 void OutputBuilderText::outputString(const std::string &str)
00095 {
00096 mStream << str;
00097 }
00098
00099
00100
00101
00102 void OutputBuilderText::outputIRHandle(ProcHandle h,
00103 IRHandlesIRInterface& pIR)
00104 {
00105 mStream << "ProcHandle(" << pIR.toString(h) << ")";
00106 }
00107
00108 void OutputBuilderText::outputIRHandle(StmtHandle h,
00109 IRHandlesIRInterface& pIR)
00110 {
00111 mStream << "StmtHandle(" << pIR.toString(h) << ")";
00112 }
00113
00114 void OutputBuilderText::outputIRHandle(ExprHandle h,
00115 IRHandlesIRInterface& pIR)
00116 {
00117 mStream << "ExprHandle(" << pIR.toString(h) << ")";
00118 }
00119
00120 void OutputBuilderText::outputIRHandle(CallHandle h,
00121 IRHandlesIRInterface& pIR)
00122 {
00123 mStream << "CallHandle(" << pIR.toString(h) << ")";
00124 }
00125
00126 void OutputBuilderText::outputIRHandle(OpHandle h,
00127 IRHandlesIRInterface& pIR)
00128 {
00129 mStream << "OpHandle(" << pIR.toString(h) << ")";
00130 }
00131
00132 void OutputBuilderText::outputIRHandle(MemRefHandle h,
00133 IRHandlesIRInterface& pIR)
00134 {
00135 mStream << "MemRefHandle(" << pIR.toString(h) << ")";
00136 }
00137
00138 void OutputBuilderText::outputIRHandle(SymHandle h,
00139 IRHandlesIRInterface& pIR)
00140 {
00141 mStream << "SymHandle(" << pIR.toString(h) << ")";
00142 }
00143
00144 void OutputBuilderText::outputIRHandle(ConstSymHandle h,
00145 IRHandlesIRInterface& pIR)
00146 {
00147 mStream << "ConstSymHandle(" << pIR.toString(h) << ")";
00148 }
00149
00150 void
00151 OutputBuilderText::outputIRHandle(ConstValHandle h,
00152 IRHandlesIRInterface& pIR)
00153 {
00154 mStream << "ConstValHandle(" << pIR.toString(h) << ")";
00155 }
00156
00157
00158
00159
00160 void OutputBuilderText::objStart(const std::string& objName)
00166 {
00167 gNestedObjects++;
00168 mStream << indt << objName << "(" << pushIndt;
00169 }
00170
00171 void OutputBuilderText::objEnd(const std::string& objName)
00175 {
00176 gNestedObjects--;
00177 mStream << popIndt << indt << ")";
00178
00179
00180
00181
00182 if(gNestedObjects <= 0) {
00183 mStream << endl;
00184 }
00185 }
00186
00187 void OutputBuilderText::field(const std::string& fieldname,
00188 const std::string& value)
00189 {
00190 mStream << indt << fieldname << ": " << value;
00191 }
00192
00193 void OutputBuilderText::fieldStart(const std::string& fieldname)
00194 {
00195 mStream << indt << fieldname + ": ";
00196 }
00197
00198 void OutputBuilderText::fieldEnd(const std::string& fieldname)
00199 {
00200 }
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218 void OutputBuilderText::listStart()
00219 { mStream << "[ " << pushIndt; mListItemCount = 0; }
00220
00221 void OutputBuilderText::listEnd()
00222 { mStream << " ] " << popIndt; }
00223
00224 void OutputBuilderText::listItem(const std::string& value)
00225 {
00226 if(mListItemCount>0) {mStream << " "; }
00227 mStream << value;
00228 mListItemCount++;
00229 }
00230
00231 void OutputBuilderText::listItemStart()
00232 {
00233 if(mListItemCount>0) {mStream << " "; }
00234 }
00235
00236 void OutputBuilderText::listItemEnd()
00237 {
00238 mListItemCount++;
00239 }
00240
00241
00242
00243
00244 void OutputBuilderText::mapStart(const std::string& label,
00245 const std::string& keyLabel,
00246 const std::string& valueLabel)
00247 {
00248 mStream << indt << label << ": " << keyLabel << "\t => " << valueLabel;
00249 mStream << pushIndt;
00250 }
00251
00252 void OutputBuilderText::mapEnd(const std::string& label)
00253 {
00254
00255 mStream << popIndt << std::endl;
00256 }
00257
00258 void OutputBuilderText::mapEntry(const std::string& key, const std::string& value)
00259 {
00260 mapEntryStart();
00261 mapKey(key);
00262 mapValue(value);
00263 mapEntryEnd();
00264 }
00265
00266 void OutputBuilderText::mapKey(const std::string& key)
00267 {
00268 mapKeyStart();
00269 mStream << key;
00270 mapKeyEnd();
00271 }
00272
00273 void OutputBuilderText::mapValue(const std::string& value)
00274 {
00275 mapValueStart();
00276 mStream << value;
00277 mapValueEnd();
00278 }
00279
00280
00281 void OutputBuilderText::mapEntryStart()
00282 {
00283 mStream << pushIndt;
00284 }
00285
00286 void OutputBuilderText::mapEntryEnd()
00287 {
00288 mStream << popIndt;
00289 }
00290
00291 void OutputBuilderText::mapKeyStart()
00292 {
00293 mStream << indt;
00294 }
00295
00296 void OutputBuilderText::mapKeyEnd()
00297 {
00298 mStream << "\t => ";
00299 }
00300
00301 void OutputBuilderText::mapValueStart()
00302 {
00303 }
00304
00305 void OutputBuilderText::mapValueEnd()
00306 {
00307 }
00308
00309
00310
00311
00312 void OutputBuilderText::graphStart(const std::string &label)
00313 {
00314 mStream << indt << "graph " << label << ":" << std::endl << pushIndt;
00315 }
00316
00317 void OutputBuilderText::graphEnd(const std::string &label)
00318 {
00319 mStream << popIndt << std::endl;
00320 }
00321
00322 void OutputBuilderText::graphSubStart(const std::string &label)
00323 {
00324 mStream << indt << "subgraph " << label << ":" << std::endl << pushIndt;
00325 }
00326
00327 void OutputBuilderText::graphSubEnd(const std::string &label)
00328 {
00329 mStream << popIndt << std::endl;
00330 }
00331
00332 void OutputBuilderText::graphNodeStart(int id)
00333 {
00334 mStream << indt << "Node " << id << ": ";
00335 }
00336
00337 void OutputBuilderText::graphNodeLabel(const std::string &label)
00338 {
00339 mStream << label;
00340 }
00341
00342 void OutputBuilderText::graphNodeLabelStart()
00343 {
00344 mStream << pushIndt << indt;
00345 }
00346
00347 void OutputBuilderText::graphNodeLabelEnd()
00348 {
00349 mStream << popIndt;
00350 }
00351
00352 void OutputBuilderText::graphNodeEnd()
00353 {
00354 mStream << std::endl;
00355 }
00356
00357 void OutputBuilderText::graphEdgeStart()
00358 {
00359 mStream << indt << "Edge: ";
00360 }
00361
00362 void OutputBuilderText::graphEdgeLabelStart()
00363 {
00364 mStream << pushIndt << indt;
00365 }
00366
00367 void OutputBuilderText::graphEdgeLabelEnd()
00368 {
00369 mStream << popIndt;
00370 }
00371
00372 void OutputBuilderText::graphEdgeSourceNode(int id)
00373 {
00374 mStream << id << " => ";
00375 }
00376
00377 void OutputBuilderText::graphEdgeSinkNode(int id)
00378 {
00379 mStream << id;
00380 }
00381
00382 void OutputBuilderText::graphEdgeEnd()
00383 {
00384 mStream << std::endl;
00385 }
00386
00387 }
00388