Hello!
During work on bug https://bugs.documentfoundation.org/show_bug.cgi?id=108124 I found dumpAsXml
methods in different classes (i.e. SwNode, SwNodes, SwDoc, SwPaM, SwPosition, etc.)
I've created separate function which creates XML writer, calls dumpAsXml from some class and
outputs result to debugger output. This is useful, as I can call such function from debugger (using
.call in WinDbg) and immediately get class contents as xml (i.e SwNodes as xml). This function
accepts only one parameter - pointer to class. Such pointer can be found in locals window in
debugger. So dumping any class to debug output become easy and quick task, without rewriting and
recompiling code.
The code itself is at the end of this message (this is draft code, written quickly).
I can make this code better (add cross-platform'ness as it depends on OutputDebugStringA and I'm
not sure that it exists in any other OS than Windows), and submit as patch to master. Also I can
add several lines here on how to use my function to get xml dump during debugging
https://wiki.documentfoundation.org/Development/How_to_debug#Debugging_options
If all this makes sense and can be useful not only for me?
---------------------------- Dumper function code ----------------------------------------
template <typename ClassWithDumpAsXml>
void DumpXmlToDebug(ClassWithDumpAsXml& tDumpedToDebug)
{
xmlDocPtr doc;
xmlChar *xmlbuff;
int buffersize;
xmlTextWriterPtr xmlWrt = xmlNewTextWriterDoc(&doc, 0);
assert(xmlWrt);
if (xmlTextWriterStartDocument(xmlWrt, NULL, "ISO-8859-1", NULL) < 0)
OutputDebugStringA("\n\nerror in xmlTextWriterStartDocument \n\n");
tDumpedToDebug.dumpAsXml(xmlWrt);
if (xmlTextWriterEndDocument(xmlWrt) < 0)
OutputDebugStringA("\n\nerror in xmlTextWriterEndDocument \n\n");
xmlDocDumpFormatMemory(doc, &xmlbuff, &buffersize, 1);
std::stringstream dbg;
dbg << "\n !!!!!!-------- !!!!!!!\n !! Called for " << typeid(ClassWithDumpAsXml).name() << " !!\n
" << (char *)xmlbuff << "\n\n\n";
OutputDebugStringA(dbg.str().c_str());
xmlFreeTextWriter(xmlWrt);
xmlFree(xmlbuff);
xmlFreeDoc(doc);
}
Context
- dumpAsXml · Yemelyanenko Fyodor
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.