#include "StdAfx.h" #include "SigmaView.h" #include "sigmadoc.h" #include "ItemMathFind.h" #include "TinyXml\tinyxml.h" extern "C" __declspec(dllexport) int Sigma_MathFind(CSigmaView * pView, int kind, double step, double remainder, int start, char ** elementsContentBuffer) { if (pView->m_pDoc == 0) { return -1; } // 创建一个XML的文档对象。 TiXmlDocument *xmlDocument = new TiXmlDocument(); //TiXmlDeclaration * decl = new TiXmlDeclaration("1.0", "UTF-8", ""); //xmlDocument->LinkEndChild(decl); // 根元素。 TiXmlElement *rootElement = new TiXmlElement("ROOT"); xmlDocument->LinkEndChild(rootElement); CItemMathFind find(pView->m_pDoc); find.MathFind(kind, step, remainder, start, rootElement); TiXmlPrinter printer; xmlDocument->Accept(&printer); const char * xmlstr = printer.CStr(); size_t len = strlen(xmlstr); if (len <= 0) { return -1; } char * dest = (char *)malloc(len + 1); strcpy(dest, xmlstr); *elementsContentBuffer = dest; xmlDocument->Clear(); delete xmlDocument; return (int)len; } extern "C" __declspec(dllexport) void Sigma_ReleaseNativeMemory(void * nativeMemory) { delete nativeMemory; }