bool TiXmlPrinter::Visit( const TiXmlText& text ) { if ( text.CDATA() ) { DoIndent(); buffer += "<![CDATA["; buffer += text.Value(); buffer += "]]>"; DoLineBreak(); } else if ( simpleTextPrint ) { TIXML_STRING str; TiXmlBase::EncodeString( text.ValueTStr(), &str ); buffer += str; } else { DoIndent(); TIXML_STRING str; TiXmlBase::EncodeString( text.ValueTStr(), &str ); buffer += str; DoLineBreak(); } return true; }
void SmartIndentPascal::OnEditorHook(cbEditor* ed, wxScintillaEvent& event) const { if (!ed) return; // check the event type and the currently set language // if it is not a CharAdded event or the language is not Pascal return wxEventType type = event.GetEventType(); if ( type != wxEVT_SCI_CHARADDED ) return; cbStyledTextCtrl* stc = ed->GetControl(); if ( !stc ) return; // check if smart indent is enabled const bool smartIndent = Manager::Get()->GetConfigManager(_T("editor"))->ReadBool(_T("/smart_indent"), true); if ( !smartIndent ) return; wxString langname = Manager::Get()->GetEditorManager()->GetColourSet()->GetLanguageName(ed->GetLanguage()); if ( langname != wxT("Pascal") ) return; ed->AutoIndentDone(); // we are responsible. wxChar ch = event.GetKey(); if ( (ch == wxT('\n')) || ( (stc->GetEOLMode() == wxSCI_EOL_CR) && (ch == wxT('\r')) ) ) DoIndent(ed, langname); // indent because \n added else if ( ch != wxT(' ') ) DoUnIndent(ed, langname); // un-indent because not a newline added bool braceCompleted = false; if ( SelectionBraceCompletionEnabled() || stc->IsBraceShortcutActive() ) braceCompleted = stc->DoSelectionBraceCompletion(ch); if (!braceCompleted && BraceCompletionEnabled()) stc->DoBraceCompletion(ch); }
bool TiXmlPrinter::Visit( const TiXmlDeclaration& declaration ) { DoIndent(); declaration.Print( 0, 0, &buffer ); DoLineBreak(); return true; }
bool TiXmlPrinter::VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ) { DoIndent(); buffer += "<"; buffer += element.Value(); for( const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->Next() ) { buffer += " "; attrib->Print( 0, 0, &buffer ); } if ( !element.FirstChild() ) { buffer += " />"; DoLineBreak(); } else { buffer += ">"; if ( element.FirstChild()->ToText() && element.LastChild() == element.FirstChild() && element.FirstChild()->ToText()->CDATA() == false ) { simpleTextPrint = true; // no DoLineBreak()! } else { DoLineBreak(); } } ++depth; return true; }
bool TiXmlPrinter::Visit( const TiXmlUnknown& unknown ) { DoIndent(); buffer += "<"; buffer += unknown.Value(); buffer += ">"; DoLineBreak(); return true; }
bool TiXmlPrinter::Visit( const TiXmlComment& comment ) { DoIndent(); buffer += "<!--"; buffer += comment.Value(); buffer += "-->"; DoLineBreak(); return true; }
bool TiXmlPrinter::VisitExit( const TiXmlElement& element ) { --depth; if ( !element.FirstChild() ) { // nothing. } else { if ( simpleTextPrint ) { simpleTextPrint = false; } else { DoIndent(); } buffer += "</"; buffer += element.Value(); buffer += ">"; DoLineBreak(); } return true; }
static void PrintMMessageFieldToStream(const MMessageField * field, FILE * file, int indent) { char pbuf[5]; const void * data = field->data; int i = 0; int ni = field->numItems; if (ni > 10) ni = 10; /* truncate to avoid too much spam */ MakePrettyTypeCodeString(field->typeCode, pbuf); DoIndent(indent); fprintf(file, "Entry: Name=[%s] GetNumItems()="UINT32_FORMAT_SPEC", TypeCode=%s ("INT32_FORMAT_SPEC") flatSize="UINT32_FORMAT_SPEC"\n", field->name, field->numItems, pbuf, field->typeCode, GetMMessageFieldFlattenedSize(field, MFalse)); for (i=0; i<ni; i++) { DoIndent(indent); fprintf(file, " %i. ", i); switch(field->typeCode) { case B_BOOL_TYPE: fprintf(file, "%i\n", (((const MBool *)data)[i])); break; case B_DOUBLE_TYPE: fprintf(file, "%f\n", ((const double *)data)[i]); break; case B_FLOAT_TYPE: fprintf(file, "%f\n", ((const float *)data)[i]); break; case B_INT64_TYPE: fprintf(file, INT64_FORMAT_SPEC"\n", ((const int64 *)data)[i]); break; case B_INT32_TYPE: fprintf(file, INT32_FORMAT_SPEC"\n", ((const int32 *)data)[i]); break; case B_POINTER_TYPE: fprintf(file, "%p\n", ((const void **)data)[i]); break; case B_INT16_TYPE: fprintf(file, "%i\n", ((const int16 *)data)[i]); break; case B_INT8_TYPE: fprintf(file, "%i\n", ((const int8 *)data)[i]); break; case B_POINT_TYPE: { const MPoint * pt = &((const MPoint *)data)[i]; fprintf(file, "x=%f y=%f\n", pt->x, pt->y); } break; case B_RECT_TYPE: { const MRect * rc = &((const MRect *)data)[i]; fprintf(file, "l=%f t=%f r=%f b=%f\n", rc->left, rc->top, rc->right, rc->bottom); } break; case B_MESSAGE_TYPE: { MMessage * subMsg = ((MMessage **)field->data)[i]; if (subMsg) PrintMMessageToStreamAux(subMsg, file, indent+3); else fprintf(file, "(NULL Message)\n"); } break; case B_STRING_TYPE: { MByteBuffer * subBuf = ((MByteBuffer **)field->data)[i]; if (subBuf) fprintf(file, "[%s]\n", (const char *) (&subBuf->bytes)); else fprintf(file, "(NULL String)\n"); } break; default: { MByteBuffer * subBuf = ((MByteBuffer **)field->data)[i]; if (subBuf) { int numBytes = subBuf->numBytes; if (numBytes > 0) { const uint8 * b = &subBuf->bytes; int nb = subBuf->numBytes; int j; if (nb > 10) { fprintf(file, "(%i bytes, starting with", nb); nb = 10; } else fprintf(file, "(%i bytes, equal to",nb); for (j=0; j<nb; j++) fprintf(file, " %02x", b[j]); if (nb < subBuf->numBytes) fprintf(file, "...)\n"); else fprintf(file, ")\n"); } else fprintf(file, "(zero-length buffer)\n"); } else fprintf(file, "(NULL Buffer)\n"); } break; } } }
static void PrintMMessageFieldToStream(const MMessageField * field, int indent) { char pbuf[5]; const void * data = field->data; int i = 0; int ni = field->numItems; if (ni > 10) ni = 10; /* truncate to avoid too much spam */ MakePrettyTypeCodeString(field->typeCode, pbuf); dlog(DEBUG1,"Entry: Name=[%s] GetNumItems()=%lu, TypeCode=%s (%li) flatSize=%lu", field->name, field->numItems, pbuf, field->typeCode, GetMMessageFieldFlattenedSize(field, MFalse)); for (i=0; i<ni; i++) { switch(field->typeCode) { case B_BOOL_TYPE: dlog(DEBUG1,"%i) %i",i, (((const MBool *)data)[i])); break; case B_DOUBLE_TYPE: dlog(DEBUG1,"%i) %f", i, ((const double *)data)[i]); break; case B_FLOAT_TYPE: dlog(DEBUG1,"%i) %f", i, ((const float *)data)[i]); break; case B_INT64_TYPE: dlog(DEBUG1,"%i) %lli", i, ((const int64 *)data)[i]); break; case B_INT32_TYPE: dlog(DEBUG1,"%i) %li", i, ((const int32 *)data)[i]); break; case B_POINTER_TYPE: dlog(DEBUG1,"%i) %p", i, ((const void **)data)[i]); break; case B_INT16_TYPE: dlog(DEBUG1,"%i) %i", i, ((const int16 *)data)[i]); break; case B_INT8_TYPE: dlog(DEBUG1,"%i) %i", i, ((const int8 *)data)[i]); break; case B_POINT_TYPE: { const MPoint * pt = &((const MPoint *)data)[i]; dlog(DEBUG1,"%i) x=%f y=%f", i, pt->x, pt->y); } break; case B_RECT_TYPE: { const MRect * rc = &((const MRect *)data)[i]; dlog(DEBUG1,"%i) l=%f t=%f r=%f b=%f", i, rc->left, rc->top, rc->right, rc->bottom); } break; case B_MESSAGE_TYPE: { MMessage * subMsg = ((MMessage **)field->data)[i]; if (subMsg) PrintMMessageToStreamAux(subMsg, indent+3); else dlog(DEBUG1,"%i) (NULL Message)", i); } break; case B_STRING_TYPE: { MByteBuffer * subBuf = ((MByteBuffer **)field->data)[i]; if (subBuf) dlog(DEBUG1,"%i) [%s]", i,(const char *) (&subBuf->bytes)); else dlog(DEBUG1,"%i) (NULL String)", i); } break; default: { MByteBuffer * subBuf = ((MByteBuffer **)field->data)[i]; if (subBuf) { int numBytes = subBuf->numBytes; if (numBytes > 0) { const uint8 * b = &subBuf->bytes; int nb = subBuf->numBytes; int j; if (nb > 10) { dlog(DEBUG1,"%i) (%i bytes, starting with", i, nb); nb = 10; } else dlog(DEBUG1,"%i) (%i bytes, equal to", i, nb); for (j=0; j<nb; j++) dlog(DEBUG1," %02x", b[j]); if (nb < subBuf->numBytes) dlog(DEBUG1,"...)"); else dlog(DEBUG1,")"); } else dlog(DEBUG1,"%i) (zero-length buffer)", i); } else dlog(DEBUG1,"%i) (NULL Buffer)", i); } break; } } /* just to shut up the warnings */ if (0) { DoIndent(0); } }