Changeset 104
- Timestamp:
- 01/26/08 19:18:02 (1 year ago)
- Files:
-
- branches/debea_1_2/dba/docs/src/toc.dox (modified) (1 diff)
- branches/debea_1_2/dba/examples/bind/bind.cpp (modified) (2 diffs)
- branches/debea_1_2/dba/examples/bindstb/bindstb.cpp (modified) (1 diff)
- branches/debea_1_2/dba/examples/filter/filter.cpp (modified) (3 diffs)
- branches/debea_1_2/dba/examples/idlock/idlock.cpp (modified) (1 diff)
- branches/debea_1_2/dba/examples/inheritance/inheritance.cpp (modified) (3 diffs)
- branches/debea_1_2/dba/examples/quickstart/quickstart.cpp (modified) (1 diff)
- branches/debea_1_2/dba/examples/sublists/sublists.cpp (modified) (1 diff)
- branches/debea_1_2/dba/examples/transaction/transaction.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/debea_1_2/dba/docs/src/toc.dox
r90 r104 60 60 @skip Foo 61 61 @until Foo is Foo 62 63 At end, we have to manually destroy plugin:64 @skip delete65 @until destroy66 62 */ 67 63 branches/debea_1_2/dba/examples/bind/bind.cpp
r81 r104 65 65 //table name must match one of relation names of written object. If is it not 66 66 //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); 68 68 69 69 ostream.open(); … … 76 76 //print contents of foo tables on screen 77 77 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 79 82 while(res->fetchRow()) { 80 83 std::cout << branches/debea_1_2/dba/examples/bindstb/bindstb.cpp
r81 r104 87 87 //print contents of bar table on screen 88 88 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 )); 90 92 while(res->fetchRow()) { 91 93 std::cout << branches/debea_1_2/dba/examples/filter/filter.cpp
r81 r104 37 37 class AddressFilter : public dba::StoreableFilter<Address> { 38 38 public: 39 AddressFilter(Address& pAddress) : dba::StoreableFilter<Address>(pAddress) {} 39 AddressFilter(Address& pAddress) 40 : dba::StoreableFilter<Address>(pAddress) 41 {} 40 42 41 43 //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 { 43 47 std::string ret; 44 48 ret += mMember->mStreet + ","; … … 51 55 52 56 //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 { 54 60 std::string::const_iterator e = std::find(pString.begin(), pString.end(), (',')); 55 61 if (e == pString.end()) … … 157 163 istream.getNext(&b2); 158 164 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; 160 167 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; 162 170 std::cout << b2.mAddress.mCountry << std::endl; 163 171 }; branches/debea_1_2/dba/examples/idlock/idlock.cpp
r81 r104 75 75 //print contents of foo tables on screen 76 76 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 )); 78 80 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; 80 83 }; 81 84 std::cout << "=======================" << std::endl; branches/debea_1_2/dba/examples/inheritance/inheritance.cpp
r81 r104 147 147 //print contents of foo tables on screen 148 148 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; 152 155 }; 153 156 std::cout << "=======================" << std::endl; … … 156 159 res.reset(pAr.getIStream().sendQuery("SELECT id, derivedval FROM foo_derived")); 157 160 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; 159 163 }; 160 164 std::cout << "=======================" << std::endl; … … 196 200 //print contents of foo tables on screen 197 201 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 )); 199 205 while(res->fetchRow()) { 200 206 std::cout << "id: "<< res->getInt(0) << " base: " << res->getInt(1) << std::endl; branches/debea_1_2/dba/examples/quickstart/quickstart.cpp
r81 r104 19 19 }; 20 20 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) 22 23 BEGIN_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 24 26 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 26 29 BIND_INT(Foo::mIntVal,dba::Int,"intval") 27 30 END_STORE_TABLE() branches/debea_1_2/dba/examples/sublists/sublists.cpp
r81 r104 150 150 151 151 //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; 153 154 std::cout 154 155 << "Foo.mSpecialCuBar id " << loaded.mSpecialCuBar.getId() 155 156 << ",mBarVal=" << loaded.mSpecialCuBar.mBarValue 156 157 << 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; 162 169 }; 163 170 std::cout << "=======================" << std::endl; branches/debea_1_2/dba/examples/transaction/transaction.cpp
r81 r104 5 5 6 6 /** 7 @file inheritance.cpp8 This is an example showing how inheritanceworks.7 @file transaction.cpp 8 This is an example showing how transactions works. 9 9 */ 10 10 … … 83 83 84 84 //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; 86 87 87 88 //Mark transaction to be rolled back. If you don't do it then it will be commmited … … 93 94 94 95 //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 )); 96 99 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; 98 102 } else { 99 103 std::cout << "No objects in database, transaction was rolled back" << std::endl;
