Changeset 172
- Timestamp:
- 07/29/08 15:26:33 (4 months ago)
- Files:
-
- trunk/dba/dba/xmlarchive.cpp (modified) (2 diffs)
- trunk/dba/dba/xmlarchive.h (modified) (2 diffs)
- trunk/wxdba/wxdba/xmlarchive.cpp (modified) (1 diff)
- trunk/wxdba/wxdba/xmlarchive.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/dba/dba/xmlarchive.cpp
r166 r172 31 31 xmlFree(mRootNodeName); 32 32 mRootNodeName = xmlStrdup((xmlChar*)pName); 33 }; 34 35 void 36 XMLArchive::open(xmlDocPtr pDocument) { 37 mDocument = pDocument; 38 xmlNodePtr root = xmlDocGetRootElement(mDocument); 39 if (root == NULL) 40 if (mRootNodeName != NULL) { 41 root = xmlNewDocNode(mDocument,NULL,mRootNodeName,NULL); 42 } else { 43 root = xmlNewDocNode(mDocument,NULL,(xmlChar*)"__dba_for_replace",NULL); 44 }; 45 xmlDocSetRootElement(mDocument,root); 46 if ((mRootNodeName != NULL) && (xmlStrcmp(mRootNodeName,root->name))) 47 throw DataException("Wrong root node name"); 48 updateEncoding(); 49 mRootNode = xmlDocGetRootElement(mDocument); 33 50 }; 34 51 … … 80 97 XMLArchive::close() { 81 98 if (mDocument != NULL) { 82 write(); 83 xmlFreeDoc(mDocument); 99 if (!mFilename.empty()) { 100 write(); 101 xmlFreeDoc(mDocument); 102 }; 84 103 mDocument = NULL; 85 104 }; trunk/dba/dba/xmlarchive.h
r166 r172 43 43 virtual void open(const char* pOpenStr); 44 44 /** 45 Open already created document in memory. Archive will not take 46 ownership on this document. 47 @param pDocument libxml2 xmlDoc pointer to already created document 48 */ 49 virtual void open(xmlDocPtr pDocument); 50 /** 45 51 Close archive and write xml document to file 46 52 */ … … 67 73 /** 68 74 name of file where mDocument is serialized 75 If empty then mDocument is supplied by user 69 76 */ 70 77 std::string mFilename; trunk/wxdba/wxdba/xmlarchive.cpp
r169 r172 37 37 try { 38 38 mHandle.open(pOpenStr.mb_str(wxConvFile)); 39 } catch (const dba::Exception& pEx) { 40 Exception::Rethrow(pEx); 41 }; 42 }; 43 44 void 45 XMLArchive::Open(xmlDocPtr pDocument) { 46 try { 47 mHandle.open(pDocument); 39 48 } catch (const dba::Exception& pEx) { 40 49 Exception::Rethrow(pEx); trunk/wxdba/wxdba/xmlarchive.h
r171 r172 18 18 void AddNamespace(const wxString& pName, const wxString& pPrefix); 19 19 void Open(const wxString& pOpenStr); 20 void Open(xmlDocPtr pDocument); 20 21 bool IsOpen() const; 21 22 XMLOStream GetOStream();
