Changeset 104

Show
Ignore:
Timestamp:
01/26/08 19:18:02 (1 year ago)
Author:
zork
Message:

wrapped examples for better presentation on trac

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/debea_1_2/dba/docs/src/toc.dox

    r90 r104  
    6060@skip Foo 
    6161@until Foo is Foo 
    62  
    63 At end, we have to manually destroy plugin: 
    64 @skip delete 
    65 @until destroy 
    6662*/ 
    6763 
  • branches/debea_1_2/dba/examples/bind/bind.cpp

    r81 r104  
    6565  //table name must match one of relation names of written object. If is it not 
    6666  //matched, then data will not be written. 
    67   ostream.bind("foo_table","binded_str",new dba::String(var),dba::Database::STRING);   
     67  ostream.bind("foo_table","binded_str",new dba::String(var),dba::Database::STRING); 
    6868   
    6969  ostream.open(); 
     
    7676  //print contents of foo tables on screen 
    7777  std::cout << "FooBase data:" << std::endl; 
    78   std::auto_ptr<dba::DbResult> res(pAr.getIStream().sendQuery("SELECT id, intval, binded_str FROM foo_table")); 
     78  std::auto_ptr<dba::DbResult> res(pAr.getIStream().sendQuery( 
     79    "SELECT id, intval, binded_str FROM foo_table" 
     80  )); 
     81 
    7982  while(res->fetchRow()) { 
    8083    std::cout <<  
  • branches/debea_1_2/dba/examples/bindstb/bindstb.cpp

    r81 r104  
    8787  //print contents of bar table on screen 
    8888  std::cout << "Bar data:" << std::endl; 
    89   std::auto_ptr<dba::DbResult> res(pAr.getIStream().sendQuery("SELECT id, base, intval  FROM bar_table")); 
     89  std::auto_ptr<dba::DbResult> res(pAr.getIStream().sendQuery( 
     90    "SELECT id, base, intval  FROM bar_table" 
     91  )); 
    9092  while(res->fetchRow()) { 
    9193    std::cout <<  
  • branches/debea_1_2/dba/examples/filter/filter.cpp

    r81 r104  
    3737class AddressFilter : public dba::StoreableFilter<Address> { 
    3838  public: 
    39     AddressFilter(Address& pAddress) : dba::StoreableFilter<Address>(pAddress) {} 
     39    AddressFilter(Address& pAddress)  
     40      : dba::StoreableFilter<Address>(pAddress)  
     41    {} 
    4042     
    4143    //create string from address 
    42     virtual std::string toString(const dba::ConvSpec& pSpec) const throw (dba::StoreableFilterException) { 
     44    virtual std::string toString(const dba::ConvSpec& pSpec) const  
     45      throw (dba::StoreableFilterException)  
     46    { 
    4347      std::string ret; 
    4448      ret += mMember->mStreet + ","; 
     
    5155     
    5256    //parse string readed from database     
    53     virtual void fromString(const dba::ConvSpec& pSpec, const std::string& pString) throw (dba::StoreableFilterException) { 
     57    virtual void fromString(const dba::ConvSpec& pSpec, const std::string& pString)  
     58      throw (dba::StoreableFilterException)  
     59    { 
    5460      std::string::const_iterator e = std::find(pString.begin(), pString.end(), (',')); 
    5561      if (e == pString.end()) 
     
    157163  istream.getNext(&b2); 
    158164   
    159   std::cout << "Loaded object id:" << b2.getId() << ", with Address: "<< std::endl << std::endl; 
     165  std::cout << "Loaded object id:" << b2.getId()  
     166     << ", with Address: "<< std::endl << std::endl; 
    160167  std::cout << b2.mAddress.mStreet << std::endl; 
    161   std::cout << b2.mAddress.mPostcode << " " << b2.mAddress.mCity << " (" << b2.mAddress.mRegion << ")" << std::endl; 
     168  std::cout << b2.mAddress.mPostcode << " " << b2.mAddress.mCity  
     169     << " (" << b2.mAddress.mRegion << ")" << std::endl; 
    162170  std::cout << b2.mAddress.mCountry << std::endl; 
    163171}; 
  • branches/debea_1_2/dba/examples/idlock/idlock.cpp

    r81 r104  
    7575  //print contents of foo tables on screen 
    7676  std::cout << "Foo data:" << std::endl; 
    77   std::auto_ptr<dba::DbResult> res(pAr.getIStream().sendQuery("SELECT id, intval FROM foo_table")); 
     77  std::auto_ptr<dba::DbResult> res(pAr.getIStream().sendQuery( 
     78    "SELECT id, intval FROM foo_table" 
     79  )); 
    7880  while(res->fetchRow()) { 
    79     std::cout << "id: "<< res->getInt(0) << " intval: " << res->getInt(1) << std::endl; 
     81    std::cout << "id: "<< res->getInt(0) << " intval: "  
     82      << res->getInt(1) << std::endl; 
    8083  }; 
    8184  std::cout << "=======================" << std::endl; 
  • branches/debea_1_2/dba/examples/inheritance/inheritance.cpp

    r81 r104  
    147147  //print contents of foo tables on screen 
    148148  std::cout << "FooBase data:" << std::endl; 
    149   std::auto_ptr<dba::DbResult> res(pAr.getIStream().sendQuery("SELECT id, intval FROM foo_table")); 
    150   while(res->fetchRow()) { 
    151     std::cout << "id: "<< res->getInt(0) << " intval: " << res->getInt(1) << std::endl; 
     149  std::auto_ptr<dba::DbResult> res(pAr.getIStream().sendQuery( 
     150    "SELECT id, intval FROM foo_table" 
     151  )); 
     152  while(res->fetchRow()) { 
     153    std::cout << "id: "<< res->getInt(0) << " intval: "  
     154      << res->getInt(1) << std::endl; 
    152155  }; 
    153156  std::cout << "=======================" << std::endl; 
     
    156159  res.reset(pAr.getIStream().sendQuery("SELECT id, derivedval FROM foo_derived")); 
    157160  while(res->fetchRow()) { 
    158     std::cout << "id: "<< res->getInt(0) << " derivedval: " << res->getInt(1) << std::endl; 
     161    std::cout << "id: "<< res->getInt(0) << " derivedval: "  
     162      << res->getInt(1) << std::endl; 
    159163  }; 
    160164  std::cout << "=======================" << std::endl; 
     
    196200  //print contents of foo tables on screen 
    197201  std::cout << "Custom table data:" << std::endl; 
    198   std::auto_ptr<dba::DbResult> res(pAr.getIStream().sendQuery("SELECT id, base FROM custom_table")); 
     202  std::auto_ptr<dba::DbResult> res(pAr.getIStream().sendQuery( 
     203    "SELECT id, base FROM custom_table" 
     204  )); 
    199205  while(res->fetchRow()) { 
    200206    std::cout << "id: "<< res->getInt(0) << " base: " << res->getInt(1) << std::endl; 
  • branches/debea_1_2/dba/examples/quickstart/quickstart.cpp

    r81 r104  
    1919}; 
    2020 
    21 //Class name, parent class name and relation name (SQL table in case of SQL database) 
     21//Class name, parent class name and relation name  
     22//(SQL table in case of SQL database) 
    2223BEGIN_STORE_TABLE(Foo, dba::Storeable, "foo_table") 
    23   //we store mStrVal in varchar database field named "strval" using dba::String as conversion filter  
     24  //we store mStrVal in varchar database field named  
     25  //"strval" using dba::String as conversion filter  
    2426  BIND_STR(Foo::mStrVal,dba::String,"strval") 
    25   //we store mIntVal in numeric database field named "intval" using dba::Int32 as conversion filter  
     27  //we store mIntVal in numeric database field named  
     28  //"intval" using dba::Int32 as conversion filter  
    2629  BIND_INT(Foo::mIntVal,dba::Int,"intval") 
    2730END_STORE_TABLE() 
  • branches/debea_1_2/dba/examples/sublists/sublists.cpp

    r81 r104  
    150150   
    151151  //print contents of loaded object 
    152   std::cout << "Foo 'loaded' object id " << loaded.getId() << ",mIntVal=" << loaded.mIntVal << std::endl; 
     152  std::cout << "Foo 'loaded' object id " << loaded.getId() <<  
     153    ",mIntVal=" << loaded.mIntVal << std::endl; 
    153154  std::cout  
    154155  << "Foo.mSpecialCuBar id " << loaded.mSpecialCuBar.getId()  
    155156  << ",mBarVal=" << loaded.mSpecialCuBar.mBarValue  
    156157  << std::endl; 
    157   for(std::list<Bar>::const_iterator it = loaded.mBars.begin(); it != loaded.mBars.end(); it++) { 
    158     std::cout << "Bar id=" << it->getId() << ",mBarVal=" << it->mBarValue << std::endl; 
    159   }; 
    160   for(std::list<CuBar>::const_iterator it = loaded.mCuBars.begin(); it != loaded.mCuBars.end(); it++) { 
    161     std::cout << "cuBar id=" << it->getId() << ",mBarVal=" << it->mBarValue << std::endl; 
     158  for(std::list<Bar>::const_iterator it = loaded.mBars.begin();  
     159    it != loaded.mBars.end(); it++)  
     160  { 
     161    std::cout << "Bar id=" << it->getId() <<  
     162      ",mBarVal=" << it->mBarValue << std::endl; 
     163  }; 
     164  for(std::list<CuBar>::const_iterator it = loaded.mCuBars.begin();  
     165      it != loaded.mCuBars.end(); it++)  
     166  { 
     167    std::cout << "cuBar id=" << it->getId() <<  
     168      ",mBarVal=" << it->mBarValue << std::endl; 
    162169  }; 
    163170  std::cout << "=======================" << std::endl; 
  • branches/debea_1_2/dba/examples/transaction/transaction.cpp

    r81 r104  
    55  
    66/** 
    7 @file inheritance.cpp 
    8 This is an example showing how inheritance works. 
     7@file transaction.cpp 
     8This is an example showing how transactions works. 
    99*/ 
    1010 
     
    8383        
    8484    //print loaded object  
    85     std::cout << "loaded Foo id=" << loaded.getId() << ",intval: " << loaded.mIntVal << std::endl; 
     85    std::cout << "loaded Foo id=" << loaded.getId() <<  
     86      ",intval: " << loaded.mIntVal << std::endl; 
    8687    
    8788    //Mark transaction to be rolled back. If you don't do it then it will be commmited 
     
    9394   
    9495  //print contents of foo tables on screen 
    95   std::auto_ptr<dba::DbResult> res(pAr.getIStream().sendQuery("SELECT id, intval FROM foo_table")); 
     96  std::auto_ptr<dba::DbResult> res(pAr.getIStream().sendQuery( 
     97    "SELECT id, intval FROM foo_table" 
     98  )); 
    9699  if (res->fetchRow()) { 
    97     std::cerr << "Fatal error: there should be no objects after transaction is rolled back" << std::endl; 
     100    std::cerr << "Fatal error: there should be no objects " 
     101      "after transaction is rolled back" << std::endl; 
    98102  } else { 
    99103    std::cout << "No objects in database, transaction was rolled back" << std::endl;