#include "DWorkUtils.h" #include "DConsole.h" #include #include "DStringUtils.h" using namespace ccdb; void PrintDirectoryTree( DDirectory *dir, bool printFullPath/*=false*/,int level/*=0*/ ) { //TODO: Implement method DConsole console; if(!printFullPath) { for (int i=0; i< level; i++) { console.Write(DConsole::cBrightBlue, "--"); } if(level != 0) { console.Write(DConsole::cBrightBlue,"> "); } console.WriteLine(dir->GetName().c_str()); } else { console.WriteLine(dir->GetFullPath().c_str()); } const vector& subDirs=dir->GetSubdirectories(); if(subDirs.size()>0) { for(vector::const_iterator it=subDirs.begin(); itGetTypeTable(); if(table == NULL) return; vector columnNames = table->GetColumnNames(); vector columnTypes = table->GetColumnTypeStrings(); vector data = assignment->GetVectorData(); int columnsNum = columnNames.size(); assert(columnNames.size() == columnTypes.size()); assert(data.size() % columnsNum == 0 ); int minLength = 10; int *columnLengths = new int[columnsNum]; int totalDataLength = 0; //determine column length for(int i=0; iminLength)? columnNames[i].length() : minLength; totalDataLength += columnLengths[i]; } //this is our cap, if we need it.... string cap; cap.assign(totalDataLength + 3 * columnsNum + 1,'-'); //print header if needed if(printHeader) { //cap? if(displayBorders) console.WriteLine(borderColor, cap.c_str()); //names line for(int i=0; i< columnsNum; i++) { console.Write(borderColor, "%s",border); console.Write(headColor, DStringUtils::Format(" %%-%is ", columnLengths[i]).c_str(), columnNames[i].c_str()); } console.WriteLine(borderColor, "%s",border); //types line for(int i=0; i< columnsNum; i++) { console.Write(borderColor, "%s",border); console.Write(typeColor, DStringUtils::Format(" %%-%is ", columnLengths[i]).c_str(), columnTypes[i].c_str()); } console.WriteLine(borderColor, "%s",border); } //cap? if(displayBorders) console.WriteLine(borderColor, cap.c_str()); //data line by line vector::iterator colIter = data.begin(); int columnIter = 0; while(colIterGetName().c_str()); console.WriteLine("Comment: %s", table->GetComment().c_str()); console.WriteLine("Columns: %i Rows: %i", table->GetNColumns(), table->GetNColumnsFromDB(), table->GetNRows()); vector columnNames = table->GetColumnNames(); vector columnTypes = table->GetColumnTypeStrings(); int columnsNum = columnNames.size(); assert(columnNames.size() == columnTypes.size()); int nameColumnLength = 10; //determine column length for(int i=0; i nameColumnLength) nameColumnLength = columnNames[i].length(); } //this strange structure is just to create console.WriteLine(DStringUtils::Format(" %%-%is type", nameColumnLength).c_str(), "name"); //names line for(int i=0; i< columnsNum; i++) { console.WriteLine(DStringUtils::Format(" %%-%is %%s", nameColumnLength).c_str(), columnNames[i].c_str(), columnTypes[i].c_str()); } }