std::wstring Inspector::showUnreferencedItem(size_t _iPos) { std::wstring st; InternalType* pIT = getUnreferencedItem(_iPos); if (pIT == NULL) { st = L"NULL"; } else { st = pIT->getTypeStr(); } return st; }
/** ** toString to display Structs ** FIXME : Find a better indentation process */ bool Cell::subMatrixToString(std::wostringstream& ostr, int* _piDims, int /*_iDims*/) { int iPrecision = ConfigVariable::getFormatSize(); if (isEmpty()) { ostr << L" {}"; } else { //max len for each column int *piTypeLen = new int[getCols()]; int *piSizeLen = new int[getCols()]; memset(piTypeLen, 0x00, getCols() * sizeof(int)); memset(piSizeLen, 0x00, getCols() * sizeof(int)); for (int j = 0 ; j < getCols() ; j++) { for (int i = 0 ; i < getRows() ; i++) { _piDims[0] = i; _piDims[1] = j; int iPos = getIndex(_piDims); InternalType* pIT = get(iPos); if (pIT->isAssignable()) { //compute number of digits to write dimensions int iTypeLen = 0; if (pIT->isGenericType()) { GenericType* pGT = pIT->getAs<GenericType>(); for (int k = 0 ; k < pGT->getDims() ; k++) { iTypeLen += static_cast<int>(log10(static_cast<double>(pGT->getDimsArray()[k])) + 1); } piSizeLen[j] = std::max(piSizeLen[j], iTypeLen + (pGT->getDims() - 1));//add number of "x" } else { //types non derived from ArrayOf. int iSize = static_cast<int>(log10(static_cast<double>(pIT->getAs<GenericType>()->getRows())) + 1); piSizeLen[j] = std::max(piSizeLen[j], iSize); } } else { //no size so let a white space, size == 1 piSizeLen[j] = std::max(piSizeLen[j], 1); } piTypeLen[j] = std::max(piTypeLen[j], static_cast<int>(pIT->getTypeStr().size())); } } for (int i = 0 ; i < getRows() ; i++) { for (int j = 0 ; j < getCols() ; j++) { _piDims[0] = i; _piDims[1] = j; int iPos = getIndex(_piDims); InternalType* pIT = get(iPos); ostr << L" ["; if (pIT->isAssignable()) { if (pIT->isGenericType()) { //" ixjxkxl type " GenericType* pGT = pIT->getAs<GenericType>(); std::wostringstream ostemp; for (int k = 0 ; k < pGT->getDims() ; k++) { if (k != 0) { ostemp << L"x"; } ostemp << pGT->getDimsArray()[k]; } configureStream(&ostr, piSizeLen[j], iPrecision, ' '); ostr << std::right << ostemp.str(); } else { //" i " configureStream(&ostr, piSizeLen[j], iPrecision, ' '); if (pIT->isList()) { ostr << std::right << pIT->getAs<List>()->getSize(); } else { ostr << std::right << 1; } } } else { configureStream(&ostr, piSizeLen[j], iPrecision, ' '); ostr << L"";//fill with space } ostr << L" "; configureStream(&ostr, piTypeLen[j], iPrecision, ' '); ostr << std::left << pIT->getTypeStr(); ostr << L"]"; } ostr << std::endl; } delete[] piSizeLen; delete[] piTypeLen; } ostr << std::endl; return true; }