Mixe for Privacy and Anonymity in the Internet
CAAbstractXMLEncodable.cpp
Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2000, The JAP-Team 
00003 All rights reserved.
00004 Redistribution and use in source and binary forms, with or without modification, 
00005 are permitted provided that the following conditions are met:
00006 
00007   - Redistributions of source code must retain the above copyright notice, 
00008     this list of conditions and the following disclaimer.
00009 
00010   - Redistributions in binary form must reproduce the above copyright notice, 
00011     this list of conditions and the following disclaimer in the documentation and/or 
00012     other materials provided with the distribution.
00013 
00014   - Neither the name of the University of Technology Dresden, Germany nor the names of its contributors 
00015     may be used to endorse or promote products derived from this software without specific 
00016     prior written permission. 
00017 
00018   
00019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS 
00020 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 
00021 AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS
00022 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00023 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
00024 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 
00025 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
00026 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
00027 */
00028 #include "StdAfx.h"
00029 #ifndef ONLY_LOCAL_PROXY
00030 #include "CAAbstractXMLEncodable.hpp"
00031 #include "xml/DOM_Output.hpp"
00032 
00033 SINT32 CAAbstractXMLEncodable::toXmlDocument(XERCES_CPP_NAMESPACE::DOMDocument* & pDoc)
00034   {
00035     DOMElement* pElemRoot=NULL;
00036     pDoc = createDOMDocument();
00037     toXmlElement(pDoc, pElemRoot);
00038     pDoc->appendChild(pElemRoot);
00039     return E_SUCCESS;
00040   }
00041 
00042 UINT8* CAAbstractXMLEncodable::toXmlString(UINT32* pSize)
00043   {
00044     XERCES_CPP_NAMESPACE::DOMDocument* pDoc=NULL;
00045     toXmlDocument(pDoc);
00046     UINT8* tmp = DOM_Output::dumpToMem(pDoc, pSize);
00047     // put null at the end...
00048     UINT8* tmp2 = new UINT8[*pSize+1];
00049     memcpy(tmp2, tmp, *pSize);
00050     tmp2[*pSize]=0;
00051     delete[] tmp;
00052     tmp = NULL;
00053     if (pDoc != NULL)
00054     {
00055       pDoc->release();
00056       pDoc = NULL;
00057     }
00058     //delete pDoc;
00059     return tmp2;
00060   }
00061 #endif //ONLY_LOCAL_PROXY