Changeset 131
- Timestamp:
- 05/04/08 12:37:49 (8 months ago)
- Files:
-
- trunk/dba/dba/sqlostream.cpp (modified) (1 diff)
- trunk/dba/dba/xmlarchive.cpp (modified) (1 diff)
- trunk/dba/dba/xmlostream.cpp (modified) (3 diffs)
- trunk/dba/dba/xmlostream.h (modified) (1 diff)
- trunk/dba/test/xmltestcase.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/dba/dba/sqlostream.cpp
r115 r131 278 278 //nothing is binded 279 279 if (mMemberList->mFirst->name == NULL) 280 return Storeable::InvalidId;280 return false; 281 281 //assign new id 282 282 int id = mFetcher->getNextId(*mConn); trunk/dba/dba/xmlarchive.cpp
r130 r131 23 23 mRootNode(NULL) 24 24 { 25 mConvSpecs.mTimestampFormat = "%Y-%m-%dZ%H:%M:%S"; 25 26 } 26 27 trunk/dba/dba/xmlostream.cpp
r130 r131 11 11 // 12 12 #include "xmlostream.h" 13 #include "conversion.h" 13 14 14 15 namespace dba { … … 16 17 XMLOStream::XMLOStream(xmlNodePtr pNode, const ConvSpec& pSpecs) 17 18 : OStream(), 18 ConvSpecContainer(pSpecs) 19 ConvSpecContainer(pSpecs), 20 mCurrentNode(pNode) 19 21 { 20 22 } … … 45 47 }; 46 48 49 void 50 XMLOStream::updateNodeFromObject(xmlNodePtr pNode, const Storeable& pObject, mt_class* pTable) { 51 mt_member* current = pTable->firstField; 52 current = pTable->firstField; 53 while(current->name != NULL) { 54 void* member = (char*)&pObject + (int)(current->offset); 55 StoreableFilterBase& filter = *(StoreableFilterBase*)current->func; 56 setFilterPtr(filter,member); 57 if (!filter.isNull()) { 58 std::string strdata(filter.toString(getConversionSpecs())); 59 xmlNewProp(pNode,(xmlChar*)current->name,(xmlChar*)strdata.c_str()); 60 }; 61 current = current->next; 62 if (current == NULL) 63 break; 64 }; 65 }; 66 67 void 68 XMLOStream::updateNodeFromVars(xmlNodePtr pNode, mt_class* pTable) { 69 //TODO 70 }; 71 47 72 bool 48 73 XMLOStream::store(Storeable* pObject) { 49 //TODO 74 createTree(Stream::getTable(*pObject)); 75 if (mMemberList->mFirst->name == NULL) 76 return false; 77 int id = 1; //TODO assign new id here - per file? 78 79 mt_class* current = mMemberList->mFirst; 80 xmlNodePtr node = xmlNewNode(NULL, (xmlChar*)current->name); 81 xmlNewProp(node,(xmlChar*)"id",(xmlChar*)(toStr(id).c_str())); 82 while(current->name != NULL) { 83 updateNodeFromObject(node,*pObject,current); 84 updateNodeFromVars(node,current); 85 current = current->next; 86 if (current == NULL) 87 break; 88 }; 89 xmlAddChild(mCurrentNode, node); 50 90 }; 51 91 trunk/dba/dba/xmlostream.h
r130 r131 38 38 virtual bool deleteRefData(const std::vector<id>& pIds, const char* pTableName); 39 39 virtual ~XMLOStream(); 40 private: 41 xmlNodePtr mCurrentNode; 42 43 void updateNodeFromVars(xmlNodePtr pNode, mt_class* pTable); 44 void updateNodeFromObject(xmlNodePtr pNode, const Storeable& pObject, mt_class* pTable); 40 45 }; 41 46 trunk/dba/test/xmltestcase.cpp
r130 r131 78 78 XMLTestCase::simpleStore() { 79 79 const char* result = 80 "<?xml version=\"1.0\" encoding=\"utf-8\" >\n"80 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" 81 81 "<dba>\n" 82 " <test_objects id=\"1\" i_value=\"1\" f_value=\"1.1\" s_value=\"test\" d_value=\"2008-01-01Z00:00:00\"/>\n"82 " <test_objects id=\"1\" i_value=\"1\" f_value=\"1.1\" s_value=\"test\" d_value=\"2008-01-01Z00:00:00\"/>\n" 83 83 "</dba>\n"; 84 84 {
