void PHPEntityVariable::PrintStdout(int indent) const { wxString indentString(' ', indent); wxPrintf("%s%s: %s", indentString, IsMember() ? "Member" : "Variable", GetShortName()); if(!GetTypeHint().IsEmpty()) { wxPrintf(", TypeHint: %s", GetTypeHint()); } if(!GetExpressionHint().IsEmpty()) { wxPrintf(", ExpressionHint: %s", GetExpressionHint()); } if(IsReference()) { wxPrintf(", Reference"); } if(!GetDefaultValue().IsEmpty()) { wxPrintf(", Default: %s", GetDefaultValue()); } wxPrintf(", Ln. %d", GetLine()); wxPrintf("\n"); PHPEntityBase::List_t::const_iterator iter = m_children.begin(); for(; iter != m_children.end(); ++iter) { (*iter)->PrintStdout(indent + 4); } }
void WaitPushUndoStack::writeUndo(const QUndoCommand * cmd, int indent, const BaseCommand * parent) { const BaseCommand * bcmd = dynamic_cast<const BaseCommand *>(cmd); QString cmdString; QString indexString; if (bcmd == NULL) { cmdString = cmd->text(); } else { cmdString = bcmd->getDebugString(); indexString = QString::number(bcmd->index()) + " "; } if (m_file.open(QIODevice::Append | QIODevice::Text)) { QTextStream out(&m_file); QString indentString(indent, QChar(' ')); if (parent) { indentString += QString("(%1) ").arg(parent->index()); } indentString += indexString; out << indentString << cmdString << "\n"; m_file.close(); } for (int i = 0; i < cmd->childCount(); i++) { writeUndo(cmd->child(i), indent + 4, NULL); } if (bcmd) { for (int i = 0; i < bcmd->subCommandCount(); i++) { writeUndo(bcmd->subCommand(i), indent + 4, bcmd); } } }
void ExportContext::endElement() { if(!m_objectStack.size()) { reportError("endElement(): no object being written.\n"); return; } ASSERT(m_elementStack.size()); element_entry& entry = m_elementStack.back(); if(m_state != WRITE_END && m_state != WRITE_CONTENT) { reportError("endElement(): not allowed.\n"); return; } indentLess(); BString out; // write closing tag if(!entry.hasContent) out << "/>"; else out << "\n" << indentString() << "</" << entry.name.String() << ">"; writeString(out); // pop element off stack m_elementStack.pop_back(); }
// writes a start tag. should only be called from // IPersistent::xmlExportBegin(). void ExportContext::beginElement( const char* name) { ASSERT(name); if(!m_objectStack.size()) { reportError("beginElement(): no object being written.\n"); return; } if(m_state != WRITE_BEGIN && m_state != WRITE_CONTENT) { reportError("beginElement(): not allowed.\n"); return; } // push tag onto element stack, and link to entry for the current object m_elementStack.push_back(element_entry()); m_elementStack.back().name = name; m_objectStack.back().element = m_elementStack.back().name.String(); // write tag BString out; out << "\n" << indentString() << '<' << name; writeString(out); indentMore(); }
void dumpArray(std::ostream& file, const Array<T> table, const std::string& title = "", int indent = 0) { std::string indentString(indent, ' '); if (!title.empty()) { file << indentString << title << std::endl; } Array<std::string> txts(table.width(), table.height()); size_t maxlen = 0; for (Point p: arrayRange(table)) { txts[p] = boost::lexical_cast<std::string>(table[p]); maxlen = std::max(maxlen, txts[p].size()); } // leave a space between characters ++maxlen; Point p; for (p.y = 0; p.y < static_cast<int>(table.height()); p.y++) { file << indentString; for (p.x = 0; p.x < static_cast<int>(table.width()); p.x++) { file.width(maxlen); file << txts[p]; } file << std::endl; } file << std::endl; }
String PolygonizerCubeArrayTable::toString() const { String result; for (UINT i = 0; i < ARRAYSIZE(m_table); i++) { result += format(_T("%3d,%s\n"), i, sprintbin((BYTE)i).cstr()); result += indentString(get(i).toString(),2); } return result; }
void CCLayerImpl::dumpLayer(std::string* str, int indent) const { str->append(indentString(indent)); base::StringAppendF(str, "%s(%s)\n", layerTypeAsString(), m_debugName.data()); dumpLayerProperties(str, indent+2); if (m_replicaLayer) { str->append(indentString(indent+2)); str->append("Replica:\n"); m_replicaLayer->dumpLayer(str, indent+3); } if (m_maskLayer) { str->append(indentString(indent+2)); str->append("Mask:\n"); m_maskLayer->dumpLayer(str, indent+3); } for (size_t i = 0; i < m_children.size(); ++i) m_children[i]->dumpLayer(str, indent+1); }
void PHPEntityNamespace::PrintStdout(int indent) const { wxString indentString(' ', indent); wxPrintf("%sNamespace name: %s\n", indentString, GetFullName()); PHPEntityBase::List_t::const_iterator iter = m_children.begin(); for(; iter != m_children.end(); ++iter) { (*iter)->PrintStdout(indent + 4); } }
void KeywordItem::execute(KTextEditor::View* view, const KTextEditor::Range& word) { KTextEditor::Document *document = view->document(); if ( !m_replacement.isEmpty() ) { QString replacement = m_replacement; replacement = replacement.replace('\n', '\n' + getIndendation(document->line(word.start().line()))); replacement = replacement.replace(QLatin1String("%INDENT%"), indentString(document)); int cursorPos = replacement.indexOf(QStringLiteral("%CURSOR%")); int selectionEnd = -1; if ( cursorPos != -1 ) { replacement.remove(QStringLiteral("%CURSOR%")); } else { cursorPos = replacement.indexOf(QStringLiteral("%SELECT%")); if ( cursorPos != -1 ) { replacement.remove(QStringLiteral("%SELECT%")); selectionEnd = replacement.indexOf(QStringLiteral("%ENDSELECT%"), cursorPos + 1); if ( selectionEnd == -1 ) { selectionEnd = replacement.length(); } replacement.remove(QStringLiteral("%ENDSELECT%")); } } document->replaceText(word, replacement); if ( cursorPos != -1 ) { if (view) { replacement = replacement.left(cursorPos); KTextEditor::Cursor newPos( word.start().line() + replacement.count('\n'), word.start().column() + replacement.length() - replacement.lastIndexOf('\n') - 1 ); view->setCursorPosition(newPos); if ( selectionEnd != -1 ) { ///TODO: maybe we want to support multi-line selections in the future? view->setSelection( KTextEditor::Range( newPos, KTextEditor::Cursor( newPos.line(), newPos.column() + selectionEnd - cursorPos ) ) ); } } } } else { document->replaceText(word, m_keyword + ' '); } }
static QString indent(QString s, int level = 2) { QString indentString(level, QLatin1Char(' ')); QString result; int last = 0; for (int i = 0; i < s.length(); ++i) { if (s.at(i) == QLatin1Char('\n') || i == s.length() - 1) { result.append(indentString); result.append(s.midRef(last, i + 1)); last = i + 1; } } return result; }
void PHPEntityClass::PrintStdout(int indent) const { wxString indentString(' ', indent); wxPrintf("%sClass name: %s", indentString, GetFullName()); if(!GetExtends().IsEmpty()) { wxPrintf(", extends %s", GetExtends()); } if(!GetImplements().IsEmpty()) { wxPrintf(", implements: "); for(size_t i = 0; i < GetImplements().GetCount(); ++i) { wxPrintf("%s ", GetImplements().Item(i)); } } wxPrintf("\n"); PHPEntityBase::List_t::const_iterator iter = m_children.begin(); for(; iter != m_children.end(); ++iter) { (*iter)->PrintStdout(indent + 4); } }
void CCRenderSurface::dumpSurface(std::string* str, int indent) const { std::string indentStr = indentString(indent); str->append(indentStr); base::StringAppendF(str, "%s\n", name().data()); indentStr.append(" "); str->append(indentStr); base::StringAppendF(str, "contentRect: (%d, %d, %d, %d)\n", m_contentRect.x(), m_contentRect.y(), m_contentRect.width(), m_contentRect.height()); str->append(indentStr); base::StringAppendF(str, "drawTransform: %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f\n", m_drawTransform.m11(), m_drawTransform.m12(), m_drawTransform.m13(), m_drawTransform.m14(), m_drawTransform.m21(), m_drawTransform.m22(), m_drawTransform.m23(), m_drawTransform.m24(), m_drawTransform.m31(), m_drawTransform.m32(), m_drawTransform.m33(), m_drawTransform.m34(), m_drawTransform.m41(), m_drawTransform.m42(), m_drawTransform.m43(), m_drawTransform.m44()); str->append(indentStr); base::StringAppendF(str, "damageRect is pos(%f, %f), size(%f, %f)\n", m_damageTracker->currentDamageRect().x(), m_damageTracker->currentDamageRect().y(), m_damageTracker->currentDamageRect().width(), m_damageTracker->currentDamageRect().height()); }
void CCLayerImpl::dumpLayerProperties(std::string* str, int indent) const { std::string indentStr = indentString(indent); str->append(indentStr); base::StringAppendF(str, "layer ID: %d\n", m_layerId); str->append(indentStr); base::StringAppendF(str, "bounds: %d, %d\n", bounds().width(), bounds().height()); if (m_renderTarget) { str->append(indentStr); base::StringAppendF(str, "renderTarget: %d\n", m_renderTarget->m_layerId); } str->append(indentStr); base::StringAppendF(str, "drawTransform: %f, %f, %f, %f // %f, %f, %f, %f // %f, %f, %f, %f // %f, %f, %f, %f\n", m_drawTransform.m11(), m_drawTransform.m12(), m_drawTransform.m13(), m_drawTransform.m14(), m_drawTransform.m21(), m_drawTransform.m22(), m_drawTransform.m23(), m_drawTransform.m24(), m_drawTransform.m31(), m_drawTransform.m32(), m_drawTransform.m33(), m_drawTransform.m34(), m_drawTransform.m41(), m_drawTransform.m42(), m_drawTransform.m43(), m_drawTransform.m44()); str->append(indentStr); base::StringAppendF(str, "drawsContent: %s\n", m_drawsContent ? "yes" : "no"); }
void CCIOSurfaceLayerImpl::dumpLayerProperties(std::string* str, int indent) const { str->append(indentString(indent)); base::StringAppendF(str, "iosurface id: %u texture id: %u\n", m_ioSurfaceId, m_ioSurfaceTextureId); CCLayerImpl::dumpLayerProperties(str, indent); }
QString LogMessage::toString() const { return QString("%1%2%3\t: %4").arg(indentString(), dateTimeString(), typeString(), textString()); }
static void parseAttributeValues(sdp_data_t *data, int indentation, QByteArray &xmlOutput) { if (!data) return; const int length = indentation*2 + 1; QByteArray indentString(length, ' '); char snBuffer[BUFFER_SIZE]; xmlOutput.append(indentString); // deal with every dtd type switch (data->dtd) { case SDP_DATA_NIL: xmlOutput.append("<nil/>\n"); break; case SDP_UINT8: qsnprintf(snBuffer, BUFFER_SIZE, "<uint8 value=\"0x%02x\"/>\n", data->val.uint8); xmlOutput.append(snBuffer); break; case SDP_UINT16: qsnprintf(snBuffer, BUFFER_SIZE, "<uint16 value=\"0x%04x\"/>\n", data->val.uint16); xmlOutput.append(snBuffer); break; case SDP_UINT32: qsnprintf(snBuffer, BUFFER_SIZE, "<uint32 value=\"0x%08x\"/>\n", data->val.uint32); xmlOutput.append(snBuffer); break; case SDP_UINT64: qsnprintf(snBuffer, BUFFER_SIZE, "<uint64 value=\"0x%016x\"/>\n", data->val.uint64); xmlOutput.append(snBuffer); break; case SDP_UINT128: xmlOutput.append("<uint128 value=\"0x"); for (int i = 0; i < 16; i++) ::sprintf(&snBuffer[i * 2], "%02x", data->val.uint128.data[i]); xmlOutput.append(snBuffer); xmlOutput.append("\"/>\n"); break; case SDP_INT8: qsnprintf(snBuffer, BUFFER_SIZE, "<int8 value=\"%d\"/>/n", data->val.int8); xmlOutput.append(snBuffer); break; case SDP_INT16: qsnprintf(snBuffer, BUFFER_SIZE, "<int16 value=\"%d\"/>/n", data->val.int16); xmlOutput.append(snBuffer); break; case SDP_INT32: qsnprintf(snBuffer, BUFFER_SIZE, "<int32 value=\"%d\"/>/n", data->val.int32); xmlOutput.append(snBuffer); break; case SDP_INT64: qsnprintf(snBuffer, BUFFER_SIZE, "<int64 value=\"%d\"/>/n", data->val.int64); xmlOutput.append(snBuffer); break; case SDP_INT128: xmlOutput.append("<int128 value=\"0x"); for (int i = 0; i < 16; i++) ::sprintf(&snBuffer[i * 2], "%02x", data->val.int128.data[i]); xmlOutput.append(snBuffer); xmlOutput.append("\"/>\n"); break; case SDP_UUID_UNSPEC: break; case SDP_UUID16: case SDP_UUID32: xmlOutput.append("<uuid value=\"0x"); sdp_uuid2strn(&(data->val.uuid), snBuffer, BUFFER_SIZE); xmlOutput.append(snBuffer); xmlOutput.append("\"/>\n"); break; case SDP_UUID128: xmlOutput.append("<uuid value=\""); sdp_uuid2strn(&(data->val.uuid), snBuffer, BUFFER_SIZE); xmlOutput.append(snBuffer); xmlOutput.append("\"/>\n"); break; case SDP_TEXT_STR_UNSPEC: break; case SDP_TEXT_STR8: case SDP_TEXT_STR16: case SDP_TEXT_STR32: { xmlOutput.append("<text "); QByteArray text = QByteArray::fromRawData(data->val.str, data->unitSize); bool hasNonPrintableChar = false; for (int i = 0; i < text.count(); i++) { if (text[i] == '\0') { text.resize(i); // cut trailing content break; } else if (!isprint(text[i])) { hasNonPrintableChar = true; text.resize(text.indexOf('\0')); // cut trailing content break; } } if (hasNonPrintableChar) { xmlOutput.append("encoding=\"hex\" value=\""); xmlOutput.append(text.toHex()); } else { text.replace('&', "&"); text.replace('<', "<"); text.replace('>', ">"); text.replace('"', """); xmlOutput.append("value=\""); xmlOutput.append(text); } xmlOutput.append("\"/>\n"); break; } case SDP_BOOL: if (data->val.uint8) xmlOutput.append("<boolean value=\"true\"/>\n"); else xmlOutput.append("<boolean value=\"false\"/>\n"); break; case SDP_SEQ_UNSPEC: break; case SDP_SEQ8: case SDP_SEQ16: case SDP_SEQ32: xmlOutput.append("<sequence>\n"); parseAttributeValues(data->val.dataseq, indentation + 1, xmlOutput); xmlOutput.append(indentString); xmlOutput.append("</sequence>\n"); break; case SDP_ALT_UNSPEC: break; case SDP_ALT8: case SDP_ALT16: case SDP_ALT32: xmlOutput.append("<alternate>\n"); parseAttributeValues(data->val.dataseq, indentation + 1, xmlOutput); xmlOutput.append(indentString); xmlOutput.append("</alternate>\n"); break; case SDP_URL_STR_UNSPEC: break; case SDP_URL_STR8: case SDP_URL_STR16: case SDP_URL_STR32: strncpy(snBuffer, data->val.str, data->unitSize - 1); xmlOutput.append("<url value=\""); xmlOutput.append(snBuffer); xmlOutput.append("\"/>\n"); break; default: fprintf(stderr, "Unknown dtd type\n"); } parseAttributeValues(data->next, indentation, xmlOutput); }
void CCTiledLayerImpl::dumpLayerProperties(std::string* str, int indent) const { str->append(indentString(indent)); base::StringAppendF(str, "skipsDraw: %d\n", (!m_tiler || m_skipsDraw)); CCLayerImpl::dumpLayerProperties(str, indent); }
QString toSQLParse::indentStatement(statement &stat, int level/*SQLITEMAN, toSyntaxAnalyzer &syntax*/) { QString ret; switch (stat.Type) { default: { QMessageBox::warning(QApplication::activeWindow(), "Sqliteman", "toSQLparse: Internal error in toSQLParse, should never get here"); } case statement::Block: { ret = IndentComment(level, 0, stat.Comment, false); int exc = 0; for (std::list<toSQLParse::statement>::iterator i = stat.subTokens().begin(); i != stat.subTokens().end(); i++) { int add = 0; std::list<toSQLParse::statement>::iterator j = i; j++; if (i != stat.subTokens().begin() && j != stat.subTokens().end()) add = Settings.IndentLevel; else exc = 0; QString t; if ((*i).subTokens().begin() != (*i).subTokens(). end()) t = (*(*i).subTokens().begin()).String.toUpper(); if (t == ("BEGIN") || t == ("WHEN") || t == ("ELSE") || t == ("ELSIF")) add = 0; if ((*i).Type == statement::List) ret += indentString(level + add + exc); ret += indentStatement(*i, level + add + exc/*SQLITEMAN , syntax*/); if ((*i).Type == statement::List) { int i; for (i = ret.length() - 1;i >= 0 && ret[i].isSpace();i--) ; ret = ret.mid(0, std::max(i + 1, 0)); ret += ("\n"); ret += indentString(level + exc); } if (t == ("EXCEPTION")) exc = Settings.IndentLevel * 2; } if (Settings.EndBlockNewline && level != 0) ret += ("\n"); } break; case statement::List: case statement::Statement: int maxlev = 0; int maxlevorig = 0; bool useMaxLev = false; bool any = true; int current; bool first; bool noKeyBreak = false; bool lineList = false; QString comment; if (stat.Type == statement::Statement) { ret = IndentComment(level, 0, stat.Comment, false); useMaxLev = true; first = true; current = 0; } else { for (std::list<toSQLParse::statement>::iterator i = stat.subTokens().begin(); i != stat.subTokens().end();) { if ((*i).Type != statement::Keyword) noKeyBreak = true; else useMaxLev = true; break; } current = level; first = true; } if (useMaxLev) { int count = 0; for (std::list<toSQLParse::statement>::iterator i = stat.subTokens().begin(); i != stat.subTokens().end(); i++) { if (any) { QString upp = (*i).String.toUpper(); if ((*i).Type == statement::Keyword && upp != ("LOOP") && upp != ("DO") && upp != ("THEN") && upp != ("AS") && upp != ("IS")) { if (int((*i).String.length()) + 1 > maxlev) maxlev = (*i).String.length() + 1; count++; any = false; } else if (i == stat.subTokens().begin()) { noKeyBreak = true; break; } } else if ((*i).Type == statement::Token) any = true; if ((*i).Type == statement::List) count++; } if (count <= 1 && maxlev > 0) maxlev--; maxlevorig = maxlev; any = true; } for (std::list<toSQLParse::statement>::iterator i = stat.subTokens().begin(); i != stat.subTokens().end(); i++) { comment = AddComment(comment, (*i).Comment); QString upp = (*i).String.toUpper(); #ifdef TOPARSE_DEBUG printf("%s\n", (const char*)(*i).String.toUtf8()); #endif if ((*i).Type == statement::List) { if (Settings.OperatorSpace) { ret += (" "); current++; } QString t = indentStatement(*i, current/*SQLITEMAN, syntax*/); if (t.indexOf(("\n")) >= 0) current = CurrentColumn(t); else current += CurrentColumn(t); ret += t; any = true; } else if ((*i).String == (",")) { if (Settings.CommaBefore) { ret += IndentComment(Settings.CommentColumn, current, comment, true); comment = QString::null; ret += indentString(level + maxlev - (Settings.OperatorSpace ? 2 : 1)); ret += (","); } else { ret += (","); ret += IndentComment(Settings.CommentColumn, current + 1, comment, true); comment = QString::null; ret += indentString(level + maxlev); } current = level + maxlev; any = false; lineList = true; } else if ((*i).Type == statement::Keyword && (upp == ("LOOP") || upp == ("DO") || upp == ("THEN") || upp == ("AS") || upp == ("IS"))) { if (!Settings.BlockOpenLine) { if (ret.length() > 0) { if (toIsIdent(ret.at(ret.length() - 1)) || ret.at(ret.length() - 1) == QUOTE_CHARACTER /*SQLITEMAN syntax.quoteCharacter()*/ || ret.at(ret.length() - 1) == '\'' || Settings.OperatorSpace) { ret += (" "); current++; } } ret += Settings.KeywordUpper ? (*i).String.toUpper() : (*i).String; current += (*i).String.length(); } else { ret += IndentComment(Settings.CommentColumn, current, comment, true); comment = QString::null; ret += indentString(level); ret += Settings.KeywordUpper ? (*i).String.toUpper() : (*i).String; current = level + (*i).String.length(); } any = false; } else if (any && (*i).Type == statement::Keyword && !noKeyBreak) { if (first) first = false; else { ret += IndentComment(Settings.CommentColumn, current, comment, true); current = 0; comment = QString::null; } if (current == 0) { ret += indentString(level); current = level; } else while (current < level) { ret += (" "); current++; } maxlev = maxlevorig; QString word = Settings.KeywordUpper ? (*i).String.toUpper() : (*i).String; if (ret.length()) { ret += QString("%1").arg(word, Settings.RightSeparator ? maxlev - 1 : 1 - maxlev); current = level + std::max(int(word.length()), maxlev - 1); } else { ret += word; current = level + word.length(); } any = false; lineList = false; } else { QString t = (*i).String; bool add = false; if ((*i).Type == statement::Keyword) { if (!lineList && !any && (*i).Type == statement::Keyword && !noKeyBreak && upp == ("BY")) add = true; } else { any = true; } if (isKeyword(upp) /*SQLITEMAN syntax.reservedWord(upp)*/ && Settings.KeywordUpper) t = upp; int extra; if (first) { first = false; any = false; extra = 0; } else { if (ret.length() > 0 && !ret.at(ret.length() - 1).isSpace() && (Settings.OperatorSpace || ((toIsIdent(t[0]) || t[0] == QUOTE_CHARACTER /*SQLITEMAN syntax.quoteCharacter()*/ || t[0] == '\'') && (toIsIdent(ret.at(ret.length() - 1)) || ret.at(ret.length() - 1) == QUOTE_CHARACTER /*SQLITEMAN syntax.quoteCharacter()*/ || ret.at(ret.length() - 1) == '\'') ) ) ) { if (t != (";") && t != (".") && ret.at(ret.length() - 1) != '.' && current != 0) { current++; ret += (" "); } } else if (ret.length() > 2 && ret.at(ret.length() - 2) == '*' && ret.at(ret.length() - 1) == '/') { current++; ret += (" "); } extra = maxlev; } if (current < level + maxlev) { if (current == 0) ret += indentString(level + maxlev); else while (current < level + maxlev) { ret += (" "); current++; } current = level + maxlev; } ret += t; current += t.length(); if (t.startsWith(("<<"))) { ret += ("\n"); current = 0; } if (add ) maxlev += t.length() + 1; } } if (stat.Type == statement::Statement) { ret += IndentComment(Settings.CommentColumn, current, comment, true); comment = QString::null; if (Settings.EndBlockNewline && level == 0 && stat.subTokens().begin() != stat.subTokens().end() && (*stat.subTokens().rbegin()).String == (";")) ret += ("\n"); } else if (!comment.isEmpty()) { ret += IndentComment(Settings.CommentColumn, current, comment, true); comment = QString::null; ret += indentString(level - (Settings.OperatorSpace ? 2 : 1)); } break; } return ret; }