Changeset 175
- Timestamp:
- 07/31/08 12:08:33 (4 months ago)
- Files:
-
- trunk/dba/dba/xmlostream.cpp (modified) (3 diffs)
- trunk/dba/dba/xmlostream.h (modified) (1 diff)
- trunk/dba/test/main.cpp (modified) (1 diff)
- trunk/dba/test/xmltestcase.cpp (modified) (3 diffs)
- trunk/dba/test/xmltestcase.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/dba/dba/xmlostream.cpp
r174 r175 134 134 xmlNodeSetContent(node,encoded_data); 135 135 xmlFree(encoded_data); 136 debug("adding node '%s' to '%s'", pName, (const char*)pNode->name); 136 137 xmlAddChild(pNode,node); 137 138 } else { … … 155 156 xmlNodePtr last = xmlGetLastChild(mParentNode); 156 157 if (last == NULL) 157 xmlAddChild(mParentNode, node);158 mLastAddedNode = xmlAddChild(mParentNode, node); 158 159 else 159 xmlAddPrevSibling(last,node);160 } else {160 mLastAddedNode = xmlAddPrevSibling(last,node); 161 } else { 161 162 node->nsDef = xmlCopyNamespaceList(mParentNode->nsDef); 162 163 xmlFree(xmlDocSetRootElement(mDocument,node)); … … 181 182 //set new parent node for storing subobjects 182 183 if (mParentNode != NULL) { 183 debug("going down to first child of mParent '%s'", (const char*)mParentNode->name);184 mParentNode = m ParentNode->children;184 debug("going down to last added child '%s' of mParent '%s'", (const char*)mLastAddedNode->name, (const char*)mParentNode->name); 185 mParentNode = mLastAddedNode; 185 186 } else { 186 187 mParentNode = xmlDocGetRootElement(mDocument); trunk/dba/dba/xmlostream.h
r166 r175 45 45 xmlDocPtr mDocument; 46 46 xmlNodePtr mParentNode; 47 xmlNodePtr mLastAddedNode; 47 48 bool mReplaceParentNode; 48 49 bool mUseElements; trunk/dba/test/main.cpp
r174 r175 151 151 //runner.addTest(new CppUnit::TestCaller<SQLite3SQLArchiveTestCase>("debug_test",&SQLite3SQLArchiveTestCase::transactions_rollback)); 152 152 runner.addTest(dba_tests::XMLTestCase::suite()); 153 //runner.addTest(new CppUnit::TestCaller<dba_tests::XMLTestCase>("debug_test",&dba_tests::XMLTestCase::storeBug 1));153 //runner.addTest(new CppUnit::TestCaller<dba_tests::XMLTestCase>("debug_test",&dba_tests::XMLTestCase::storeBug2)); 154 154 //runner.addTest(new CppUnit::TestCaller<dba_tests::XMLTestCase>("debug_test",&dba_tests::XMLTestCase::store_two)); 155 155 //runner.addTest(new CppUnit::TestCaller<OdbcPluginTestCase>("debug_test",&OdbcPluginTestCase::dbConnection)); trunk/dba/test/xmltestcase.cpp
r174 r175 832 832 }; 833 833 834 struct Address : public dba::Storeable {834 struct storeBug1Address : public dba::Storeable { 835 835 DECLARE_STORE_TABLE(); 836 836 std::string mData; 837 837 }; 838 838 839 BEGIN_STORE_TABLE( Address,dba::Storeable,"address")839 BEGIN_STORE_TABLE(storeBug1Address,dba::Storeable,"address") 840 840 BIND_STR(mData,dba::String,"data") 841 841 END_STORE_TABLE() 842 842 843 struct Patient : public dba::Storeable {843 struct storeBug1Patient : public dba::Storeable { 844 844 DECLARE_STORE_TABLE(); 845 Address mAddress;846 }; 847 848 BEGIN_STORE_TABLE( Patient,dba::Storeable,"patient")845 storeBug1Address mAddress; 846 }; 847 848 BEGIN_STORE_TABLE(storeBug1Patient,dba::Storeable,"patient") 849 849 BIND_COL(mAddress,dba::Single,NULL) 850 850 END_STORE_TABLE() 851 851 852 852 853 struct Report : public dba::Storeable {853 struct storeBug1Report : public dba::Storeable { 854 854 DECLARE_STORE_TABLE(); 855 855 }; 856 856 857 BEGIN_STORE_TABLE( Report,dba::Storeable,"report")857 BEGIN_STORE_TABLE(storeBug1Report,dba::Storeable,"report") 858 858 END_STORE_TABLE() 859 859 860 struct Request : public dba::Storeable {860 struct storeBug1Request : public dba::Storeable { 861 861 DECLARE_STORE_TABLE(); 862 Patient mPatient;863 Report mReport;864 }; 865 866 BEGIN_STORE_TABLE( Request,dba::Storeable,"request")862 storeBug1Patient mPatient; 863 storeBug1Report mReport; 864 }; 865 866 BEGIN_STORE_TABLE(storeBug1Request,dba::Storeable,"request") 867 867 BIND_COL(mReport,dba::Single,NULL) 868 868 BIND_COL(mPatient,dba::Single,NULL) … … 886 886 unlink("storebug1.xml"); 887 887 ar.open("storebug1.xml"); 888 Request obj1;888 storeBug1Request obj1; 889 889 dba::XMLOStream stream(ar.getOStream()); 890 890 stream.enableDebug(); … … 895 895 }; 896 896 897 struct storeBug2Address : public dba::Storeable { 898 storeBug2Address(const std::string& pData) : mData(pData) {}; 899 std::string mData; 900 DECLARE_STORE_TABLE(); 901 }; 902 903 BEGIN_STORE_TABLE(storeBug2Address,dba::Storeable,"address") 904 BIND_STR(mData,dba::String,"addressdata") 905 END_STORE_TABLE() 906 907 struct storeBug2Patient : public dba::Storeable { 908 storeBug2Patient() : mAddress("patient address") {}; 909 storeBug2Address mAddress; 910 DECLARE_STORE_TABLE(); 911 }; 912 913 BEGIN_STORE_TABLE(storeBug2Patient,dba::Storeable,"patient") 914 BIND_COL(mAddress,dba::Single,NULL) 915 END_STORE_TABLE() 916 917 struct storeBug2Request : public dba::Storeable { 918 storeBug2Request() : mData("request data"), mAddress("request address") {}; 919 storeBug2Patient mPatient; 920 storeBug2Address mAddress; 921 std::string mData; 922 DECLARE_STORE_TABLE(); 923 }; 924 925 BEGIN_STORE_TABLE(storeBug2Request,dba::Storeable,"request") 926 BIND_STB(mAddress) 927 BIND_COL(mPatient,dba::Single,NULL) 928 BIND_STR(mData,dba::String,"requestdata") 929 END_STORE_TABLE() 930 931 void 932 XMLTestCase::storeBug2() { 933 const char* result = 934 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" 935 "<request>\n" 936 " <addressdata>request address</addressdata>\n" 937 " <patient>\n" 938 " <address>\n" 939 " <addressdata>patient address</addressdata>\n" 940 " </address>\n" 941 " </patient>\n" 942 " <requestdata>request data</requestdata>\n" 943 "</request>\n" 944 ; 945 { 946 dba::XMLArchive ar; 947 ar.setRootNodeName(NULL); 948 ar.useElements(); 949 unlink("storebug2.xml"); 950 ar.open("storebug2.xml"); 951 storeBug2Request obj1; 952 dba::XMLOStream stream(ar.getOStream()); 953 stream.enableDebug(); 954 stream.open(); 955 stream.put(&obj1); 956 } 957 CPPUNIT_ASSERT(compareXML("storebug2.xml",result)); 958 }; 959 897 960 } //namespace 898 961 trunk/dba/test/xmltestcase.h
r174 r175 53 53 CPPUNIT_TEST(loadFromElements); 54 54 CPPUNIT_TEST(storeToElements); 55 CPPUNIT_TEST(storeBug 1);55 CPPUNIT_TEST(storeBug2); 56 56 CPPUNIT_TEST_SUITE_END(); 57 57 public: … … 91 91 void storeToElements(); 92 92 void storeBug1(); 93 void storeBug2(); 93 94 private: 94 95 bool compareXML(const char* pFilename, const char* pData);
