Changeset 131

Show
Ignore:
Timestamp:
05/04/08 12:37:49 (8 months ago)
Author:
zork
Message:

simple store

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dba/dba/sqlostream.cpp

    r115 r131  
    278278  //nothing is binded 
    279279  if (mMemberList->mFirst->name == NULL) 
    280     return Storeable::InvalidId
     280    return false
    281281  //assign new id 
    282282  int id = mFetcher->getNextId(*mConn); 
  • trunk/dba/dba/xmlarchive.cpp

    r130 r131  
    2323    mRootNode(NULL) 
    2424{ 
     25  mConvSpecs.mTimestampFormat = "%Y-%m-%dZ%H:%M:%S"; 
    2526} 
    2627 
  • trunk/dba/dba/xmlostream.cpp

    r130 r131  
    1111// 
    1212#include "xmlostream.h" 
     13#include "conversion.h" 
    1314 
    1415namespace dba { 
     
    1617XMLOStream::XMLOStream(xmlNodePtr pNode, const ConvSpec& pSpecs) 
    1718  : OStream(), 
    18     ConvSpecContainer(pSpecs) 
     19    ConvSpecContainer(pSpecs), 
     20    mCurrentNode(pNode) 
    1921{ 
    2022} 
     
    4547}; 
    4648 
     49void 
     50XMLOStream::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 
     67void 
     68XMLOStream::updateNodeFromVars(xmlNodePtr pNode, mt_class* pTable) { 
     69  //TODO 
     70}; 
     71 
    4772bool  
    4873XMLOStream::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); 
    5090}; 
    5191 
  • trunk/dba/dba/xmlostream.h

    r130 r131  
    3838    virtual bool deleteRefData(const std::vector<id>& pIds, const char* pTableName); 
    3939    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); 
    4045}; 
    4146 
  • trunk/dba/test/xmltestcase.cpp

    r130 r131  
    7878XMLTestCase::simpleStore() { 
    7979  const char* result =  
    80 "<?xml version=\"1.0\" encoding=\"utf-8\">\n" 
     80"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" 
    8181"<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" 
    8383"</dba>\n"; 
    8484  {