Changeset 105

Show
Ignore:
Timestamp:
01/26/08 20:06:26 (1 year ago)
Author:
zork
Message:

lines in examples wrapped to 72 chars

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/debea_1_2/dba/examples/bind/bind.cpp

    r104 r105  
    1 // Author: Lukasz Michalski <lmichalski at sourceforge.net>, Copyright 2007 
    2 // 
     1// File: bind.cpp 
     2// Purpose: Example of binding custom variables 
     3// Author: Lukasz Michalski <lm at zork.pl>, Copyright 2007 
    34// License: See COPYING file that comes with this distribution 
    45// 
     6// This file is a part of debea library (http://debea.net) 
    57  
    68/** 
    7 @file inheritance.cpp 
    8 This is an example showing how inheritance works. 
     9@file bind.cpp 
     10This is an example showing how to bind custom variable  
     11to object stream. 
    912*/ 
    1013 
     
    5962  std::string var("Binded variable stored with Foo"); 
    6063  //bind variable to relation field using String filter for  
    61   //data conversion. Last argument tells stream that data should be fetched 
    62   //from database text fields. For SQL database this is more important for reading  
    63   //than writing 
     64  //data conversion. Last argument tells stream that data should  
     65  //be fetched from database text fields.  
     66  //For SQL database this is more important  
     67  //for reading than writing 
    6468   
    65   //table name must match one of relation names of written object. If is it not 
    66   //matched, then data will not be written. 
    67   ostream.bind("foo_table","binded_str",new dba::String(var),dba::Database::STRING); 
     69  //table name must match one of relation names of written object.  
     70  //If is it not matched, then data will not be written. 
     71  ostream.bind("foo_table","binded_str", 
     72    new dba::String(var),dba::Database::STRING); 
    6873   
    6974  ostream.open(); 
    7075  ostream.put(&b); //id of object is assigned here 
    71   std::cout << "FooBase was stored with id = " << b.getId() << std::endl; 
     76  std::cout << "FooBase was stored with id = "  
     77    << b.getId() << std::endl; 
    7278   
    7379  ostream.destroy();   
     
    95101   
    96102  //bind must be always done before open 
    97   istream.bind("foo_table","binded_str",new dba::String(str_readed),dba::Database::STRING); 
     103  istream.bind("foo_table","binded_str", 
     104    new dba::String(str_readed),dba::Database::STRING); 
    98105  istream.open(readed); 
    99106  istream.getNext(&readed); 
    100107   
    101   std::cout << "Readed binded var: '" << str_readed << "'" << std::endl; 
     108  std::cout << "Readed binded var: '" << str_readed  
     109    << "'" << std::endl; 
    102110}; 
    103111 
     
    110118    dba::SQLArchive ar; 
    111119     
    112     //set object responsible for assigning id numbers for serialized objects. 
    113     //We use generic one that needs special SQL table debea_object_count.  
     120    //set object responsible for assigning id numbers  
     121    //for serialized objects. 
     122    //We use generic one that needs special  
     123    //SQL table debea_object_count.  
    114124    ar.setIdFetcher(new dba::GenericFetcher()); 
    115125     
     
    131141  } catch (const dba::SQLException& pEx) { 
    132142    std::cout << "SQL Error: " << pEx.what() << std::endl; 
    133     std::cout << "While executing: " << std::endl << pEx.getQuery() << std::endl; 
     143    std::cout << "While executing: " << std::endl  
     144      << pEx.getQuery() << std::endl; 
    134145  } catch (const dba::Exception& pEx) { 
    135146    std::cout << "Error: " << pEx.what() << std::endl; 
  • branches/debea_1_2/dba/examples/bindstb/bindstb.cpp

    r104 r105  
    1 // Author: Lukasz Michalski <lmichalski at sourceforge.net>, Copyright 2007 
    2 // 
     1// File: bindstb.cpp 
     2// Purpose: Example of storing two store tables in one relation 
     3// Author: Lukasz Michalski <lm at zork.pl>, Copyright 2007 
    34// License: See COPYING file that comes with this distribution 
    45// 
     6// This file is a part of debea library (http://debea.net) 
    57  
    68/** 
    79@file bindstb.cpp 
    8 This is an example showing how inheritance works. 
     10This is an example showing how you can store 
     11members of two store tables in one relation 
     12using BIND_STB macro. 
    913*/ 
    1014 
     
    108112     dba::SQLArchive ar; 
    109113     
    110     //set object responsible for assigning id numbers for serialized objects. 
    111     //We use generic one that needs special SQL table debea_object_count.  
     114    //set object responsible for assigning id numbers  
     115    //for serialized objects. 
     116    //We use generic one that needs special  
     117    //SQL table debea_object_count.  
    112118    ar.setIdFetcher(new dba::GenericFetcher()); 
    113119     
     
    128134  } catch (const dba::SQLException& pEx) { 
    129135    std::cout << "SQL Error: " << pEx.what() << std::endl; 
    130     std::cout << "While executing: " << std::endl << pEx.getQuery() << std::endl; 
     136    std::cout << "While executing: " << std::endl  
     137      << pEx.getQuery() << std::endl; 
    131138  } catch (const dba::Exception& pEx) { 
    132139    std::cout << "Error: " << pEx.what() << std::endl; 
  • branches/debea_1_2/dba/examples/csv_auto/csv_auto.cpp

    r63 r105  
    1 // Author: Lukasz Michalski <lmichalski at sourceforge.net>, Copyright 2007 
    2 // 
     1// File: csv_auto.cpp 
     2// Purpose: Example of handling csv files with automatic 
     3//          column mapping 
     4// Author: Lukasz Michalski <lm at zork.pl>, Copyright 2007 
    35// License: See COPYING file that comes with this distribution 
    46// 
     7// This file is a part of debea library (http://debea.net) 
    58  
    69/** 
    7 @file csv_manual.cpp 
    8 This is an example showing how inheritance works. 
     10@file csv_auto.cpp 
    911*/ 
    1012 
  • branches/debea_1_2/dba/examples/csv_manual/csv_manual.cpp

    r63 r105  
    1 // Author: Lukasz Michalski <lmichalski at sourceforge.net>, Copyright 2007 
    2 // 
     1// File: csv_manual.cpp 
     2// Purpose: Example of handling csv files with manual 
     3//          column mapping 
     4// Author: Lukasz Michalski <lm at zork.pl>, Copyright 2007 
    35// License: See COPYING file that comes with this distribution 
    46// 
     7// This file is a part of debea library (http://debea.net) 
    58  
    69/** 
    710@file csv_manual.cpp 
    8 This is an example showing how inheritance works. 
    911*/ 
    1012 
  • branches/debea_1_2/dba/examples/filter/filter.cpp

    r104 r105  
    1 // Author: Lukasz Michalski <lmichalski at sourceforge.net>, Copyright 2007 
    2 // 
     1// File: filter.cpp 
     2// Purpose: Example of creation custom conversion filter 
     3// Author: Lukasz Michalski <lm at zork.pl>, Copyright 2007 
    34// License: See COPYING file that comes with this distribution 
    45// 
    5   
     6// This file is a part of debea library (http://debea.net) 
    67/** 
    78@file filter.cpp 
    8 This is an example showing how inheritance works. 
    99*/ 
    1010 
     
    5555     
    5656    //parse string readed from database     
    57     virtual void fromString(const dba::ConvSpec& pSpec, const std::string& pString)  
    58       throw (dba::StoreableFilterException)  
     57    virtual void fromString(const dba::ConvSpec& pSpec,  
     58      const std::string& pString) throw (dba::StoreableFilterException) 
    5959    { 
    60       std::string::const_iterator e = std::find(pString.begin(), pString.end(), (',')); 
     60      std::string::const_iterator e =  
     61        std::find(pString.begin(), pString.end(), (',')); 
    6162      if (e == pString.end()) 
    6263        throw dba::StoreableFilterException("Street part not found"); 
     
    111112 
    112113/* 
    113   We use AddressFilter to serialize and deserialize Address intstance   
     114  We use AddressFilter to serialize and deserialize Address intstance 
    114115*/ 
    115116BEGIN_STORE_TABLE(Foo, dba::Storeable, "foo_table") 
     
    152153   
    153154  ostream.put(&b1); //id of object is assigned here 
    154   std::cout << "FooBase was stored with id = " << b1.getId() << std::endl; 
     155  std::cout << "FooBase was stored with id = "  
     156    << b1.getId() << std::endl; 
    155157   
    156158  //destroy stream and release connection 
     
    179181    dba::SQLArchive ar; 
    180182     
    181     //set object responsible for assigning id numbers for serialized objects. 
    182     //We use generic one that needs special SQL table debea_object_count.  
     183    //set object responsible for assigning id numbers  
     184    //for serialized objects. 
     185    //We use generic one that needs special SQL table  
     186    //debea_object_count.  
    183187    ar.setIdFetcher(new dba::GenericFetcher()); 
    184188     
     
    200204  } catch (const dba::SQLException& pEx) { 
    201205    std::cout << "SQL Error: " << pEx.what() << std::endl; 
    202     std::cout << "While executing: " << std::endl << pEx.getQuery() << std::endl; 
     206    std::cout << "While executing: " << std::endl  
     207      << pEx.getQuery() << std::endl; 
    203208  } catch (const dba::Exception& pEx) { 
    204209    std::cout << "Error: " << pEx.what() << std::endl; 
  • branches/debea_1_2/dba/examples/idlock/idlock.cpp

    r104 r105  
    1 // Author: Lukasz Michalski <lmichalski at sourceforge.net>, Copyright 2007 
    2 // 
     1// File: idlock.cpp 
     2// Purpose: Example of cloning storeable object in database 
     3// Author: Lukasz Michalski <lm at zork.pl>, Copyright 2007 
    34// License: See COPYING file that comes with this distribution 
    45// 
     6// This file is a part of debea library (http://debea.net) 
    57  
    68/** 
    79@file idlock.cpp 
    8 This is an example showing how inheritance works. 
    910*/ 
    1011 
     
    6768    Foo one_clone(one); 
    6869    ostream.put(&one_clone); //id of object is assigned here 
    69     std::cout << "Foo was cloned with id = " << one_clone.getId() << std::endl; 
     70    std::cout << "Foo was cloned with id = "  
     71      << one_clone.getId() << std::endl; 
    7072  }; 
    7173   
     
    9395    dba::SQLArchive ar; 
    9496     
    95     //set object responsible for assigning id numbers for serialized objects. 
    96     //We use generic one that needs special SQL table debea_object_count.  
     97    //set object responsible for assigning id numbers  
     98    //for serialized objects. 
     99    //We use generic one that needs special SQL table  
     100    //debea_object_count.  
    97101    ar.setIdFetcher(new dba::GenericFetcher()); 
    98102     
     
    114118  } catch (const dba::SQLException& pEx) { 
    115119    std::cout << "SQL Error: " << pEx.what() << std::endl; 
    116     std::cout << "While executing: " << std::endl << pEx.getQuery() << std::endl; 
     120    std::cout << "While executing: " << std::endl  
     121      << pEx.getQuery() << std::endl; 
    117122  } catch (const dba::Exception& pEx) { 
    118123    std::cout << "Error: " << pEx.what() << std::endl; 
  • branches/debea_1_2/dba/examples/inheritance/inheritance.cpp

    r104 r105  
    1 // Author: Lukasz Michalski <lmichalski at sourceforge.net>, Copyright 2007 
    2 // 
     1// File: inheritance.cpp 
     2// Purpose: Example of storing members from different 
     3//          classes in inheritance tree 
     4// Author: Lukasz Michalski <lm at zork.pl>, Copyright 2007 
    35// License: See COPYING file that comes with this distribution 
    46// 
     7// This file is a part of debea library (http://debea.net) 
    58  
    69/** 
     
    6871/* 
    6972  BarDerived class inherits from BarBase, which does not  
    70   have relation name in its store table. This will cause all of store table  
    71   members from BarBase to be stored in BarDerived relation. 
     73  have relation name in its store table. This will cause  
     74  all of store table members from BarBase to be stored in  
     75  BarDerived relation. 
    7276*/ 
    7377class BarDerived : public BarBase { 
     
    131135   
    132136  ostream.put(&b); //id of object is assigned here 
    133   std::cout << "FooBase was stored with id = " << b.getId() << std::endl; 
     137  std::cout << "FooBase was stored with id = "  
     138    << b.getId() << std::endl; 
    134139   
    135140  //write base object in database. 
    136   //this will create two records: one in foo_table and one in foo_derived 
     141  //this will create two records: one in foo_table and  
     142  //one in foo_derived 
    137143  FooDerived d; 
    138144  d.mIntVal = 8; 
     
    140146     
    141147  ostream.put(&d); //id of object is assigned here 
    142   std::cout << "FooDerived was stored with id = " << d.getId() << std::endl; 
     148  std::cout << "FooDerived was stored with id = "  
     149    << d.getId() << std::endl; 
    143150     
    144151  //destroy stream and release connection 
     
    157164   
    158165  std::cout << "FooDerived data:" << std::endl; 
    159   res.reset(pAr.getIStream().sendQuery("SELECT id, derivedval FROM foo_derived")); 
     166  res.reset(pAr.getIStream().sendQuery( 
     167    "SELECT id, derivedval FROM foo_derived" 
     168  )); 
    160169  while(res->fetchRow()) { 
    161170    std::cout << "id: "<< res->getInt(0) << " derivedval: "  
     
    179188   
    180189  ostream.put(&b); //id of object is assigned here 
    181   std::cout << "BarBase was stored with id = " << b.getId() << std::endl; 
     190  std::cout << "BarBase was stored with id = "  
     191    << b.getId() << std::endl; 
    182192   
    183193  //write BarDerived object in database. 
    184   //this will create two records: one in foo_table and one in foo_derived 
     194  //this will create two records: one in foo_table  
     195  //and one in foo_derived 
    185196  BarDerived d; 
    186197  d.mBase = 8; 
     
    193204  ostream.open(); 
    194205  ostream.put(&d); //id of object is assigned here 
    195   std::cout << "BarDerived was stored with id = " << d.getId() << std::endl; 
     206  std::cout << "BarDerived was stored with id = "  
     207    << d.getId() << std::endl; 
    196208     
    197209  //destroy stream and release connection 
     
    204216  )); 
    205217  while(res->fetchRow()) { 
    206     std::cout << "id: "<< res->getInt(0) << " base: " << res->getInt(1) << std::endl; 
     218    std::cout << "id: "<< res->getInt(0) << " base: "  
     219      << res->getInt(1) << std::endl; 
    207220  }; 
    208221  std::cout << "=======================" << std::endl; 
    209222   
    210223  std::cout << "Bar table data:" << std::endl; 
    211   res.reset(pAr.getIStream().sendQuery("SELECT id, base, derived FROM bar_table")); 
     224  res.reset(pAr.getIStream().sendQuery( 
     225    "SELECT id, base, derived FROM bar_table" 
     226  )); 
    212227  while(res->fetchRow()) { 
    213228    std::cout <<  
     
    228243    dba::SQLArchive ar; 
    229244     
    230     //set object responsible for assigning id numbers for serialized objects. 
    231     //We use generic one that needs special SQL table debea_object_count.  
     245    //set object responsible for assigning id numbers  
     246    //for serialized objects. 
     247    //We use generic one that needs special SQL table  
     248    //debea_object_count.  
    232249    ar.setIdFetcher(new dba::GenericFetcher()); 
    233250     
     
    253270  } catch (const dba::SQLException& pEx) { 
    254271    std::cout << "SQL Error: " << pEx.what() << std::endl; 
    255     std::cout << "While executing: " << std::endl << pEx.getQuery() << std::endl; 
     272    std::cout << "While executing: " << std::endl  
     273      << pEx.getQuery() << std::endl; 
    256274  } catch (const dba::Exception& pEx) { 
    257275    std::cout << "Error: " << pEx.what() << std::endl; 
  • branches/debea_1_2/dba/examples/quickstart/quickstart.cpp

    r104 r105  
    1 // Author: Lukasz Michalski <lmichalski at sourceforge.net>, Copyright 2007 
    2 // 
     1// File: quicstart.cpp 
     2// Purpose: Example that shows basic debea features 
     3// Author: Lukasz Michalski <lm at zork.pl>, Copyright 2007 
    34// License: See COPYING file that comes with this distribution 
    45// 
     6// This file is a part of debea library (http://debea.net) 
    57  
    68/** 
    79@file quickstart.cpp 
    8 This is an example included in "quickstart" section of library documentation 
     10This is an example included in "quickstart" section of  
     11library documentation 
    912*/ 
    1013 
     
    6366    ar.open("dbasqlite3-static", "dbname=foobasefile.sqt3"); 
    6467     
    65     //create needed tables 
     68    //create needed tables sending simple SQL 
    6669    ar.getOStream().sendUpdate(counter_create); 
    6770    ar.getOStream().sendUpdate(counter_init); 
  • branches/debea_1_2/dba/examples/sublists/sublists.cpp

    r104 r105  
    1 // Author: Lukasz Michalski <lmichalski at sourceforge.net>, Copyright 2007 
    2 // 
     1// File: quicstart.cpp 
     2// Purpose: Example that shows how to store composited objects 
     3// Author: Lukasz Michalski <lm at zork.pl>, Copyright 2007 
    34// License: See COPYING file that comes with this distribution 
    45// 
     6// This file is a part of debea library (http://debea.net) 
    57  
    68/** 
     
    5557  BIND_COL name of field is a name of foreign key field in SQL table 
    5658   
    57   BIND_CLA needs two additional parameters: relation name and collection id. 
    58   We have to set relation name because CuBar does not have one in its store table 
    59   We have to set collection id because we load CuBar instances to two 'containers': 
    60   std::list (1-n relation) and CuBar type itself (1-1 relation) 
     59  BIND_CLA needs two additional parameters: relation name  
     60  and collection id. 
     61  We have to set relation name because CuBar does not  
     62  have one in its store table 
     63  We have to set collection id because we load CuBar  
     64  instances to two 'containers': std::list (1-n relation) and  
     65  CuBar type itself (1-1 relation) 
    6166   
    6267  See implementation of dba::stdList filter for hints how 
     
    142147  dba::SQLIStream istream = pAr.getIStream(); 
    143148  Foo loaded; 
    144   //tell stream which Foo object to load. Bars and CuBars will be retrieved by 
    145   //foreign key fields automatically. 
     149  //tell stream which Foo object to load. Bars and CuBars will  
     150  //be retrieved using foreign key fields automatically. 
    146151  istream.setWhereId(f.getId()); 
    147   //this should sent 3 SQL SELECT's to database (1 Foo + 1 for Bars + 1 for CuBars) 
     152  //this should sent 3 SQL SELECT's to database  
     153  //(1 Foo + 1 for Bars + 1 for CuBars) 
    148154  istream.get(&loaded); 
    149155   
     
    176182    dba::SQLArchive ar; 
    177183     
    178     //set object responsible for assigning id numbers for serialized objects. 
    179     //We use generic one that needs special SQL table debea_object_count.  
     184    //set object responsible for assigning id numbers  
     185    //for serialized objects. 
     186    //We use generic one that needs special SQL table  
     187    //debea_object_count.  
    180188    ar.setIdFetcher(new dba::GenericFetcher()); 
    181189     
     
    198206  } catch (const dba::SQLException& pEx) { 
    199207    std::cout << "SQL Error: " << pEx.what() << std::endl; 
    200     std::cout << "While executing: " << std::endl << pEx.getQuery() << std::endl; 
     208    std::cout << "While executing: " << std::endl  
     209      << pEx.getQuery() << std::endl; 
    201210  } catch (const dba::Exception& pEx) { 
    202211    std::cout << "Error: " << pEx.what() << std::endl; 
  • branches/debea_1_2/dba/examples/transaction/transaction.cpp

    r104 r105  
    1 // Author: Lukasz Michalski <lmichalski at sourceforge.net>, Copyright 2007 
    2 // 
     1// File: transaction.cpp 
     2// Purpose: Example of transation handling 
     3// Author: Lukasz Michalski <lm at zork.pl>, Copyright 2007 
    34// License: See COPYING file that comes with this distribution 
    45// 
     6// This file is a part of debea library (http://debea.net) 
    57  
    68/** 
     
    5860     
    5961    //streams should be obtained from transaction, not from archive 
    60     //obtaining stream from archive when transaction exists will create  
    61     //new connection to database 
     62    //obtaining stream from archive when transaction exists  
     63    //will create new connection to database 
    6264    dba::SQLOStream ostream = t.getOStream(); 
    6365     
     
    7072     
    7173    ostream.put(&b); //id of object is assigned here 
    72     std::cout << "Foo was stored with id = " << b.getId() << std::endl; 
     74    std::cout << "Foo was stored with id = "  
     75      << b.getId() << std::endl; 
    7376     
    7477    //Streams obtained from transaction do not own connection 
    75     //You don't need to destroy them because every new created 
     78    //You don't must not call destroy them because every new created 
    7679    //stream will reuse connection that transaction owns. 
    7780    Foo loaded;   
    7881    dba::SQLIStream istream = t.getIStream(); 
    7982    if (!istream.get(&loaded)) { 
    80       std::cerr << "Fatal error loading just stored object" << std::endl; 
     83      std::cerr << "Fatal error loading just stored object"  
     84        << std::endl; 
    8185      return; 
    8286    }; 
     
    8690      ",intval: " << loaded.mIntVal << std::endl; 
    8791    
    88     //Mark transaction to be rolled back. If you don't do it then it will be commmited 
    89     //when t goes out of scope. 
     92    //Mark transaction to be rolled back. If you don't do it then  
     93    //it will be commmited when t goes out of scope. 
    9094    t.rollback(); 
    9195     
     
    101105      "after transaction is rolled back" << std::endl; 
    102106  } else { 
    103     std::cout << "No objects in database, transaction was rolled back" << std::endl; 
     107    std::cout << "No objects in database, " 
     108      "transaction was rolled back" << std::endl; 
    104109  }; 
    105110}; 
     
    110115    dba::SharedSQLArchive ar; 
    111116     
    112     //set object responsible for assigning id numbers for serialized objects. 
    113     //We use generic one that needs special SQL table debea_object_count.  
     117    //set object responsible for assigning id numbers  
     118    //for serialized objects. 
     119    //We use generic one that needs special SQL table  
     120    //debea_object_count.  
    114121    ar.setIdFetcher(new dba::GenericFetcher()); 
    115122     
     
    130137  } catch (const dba::SQLException& pEx) { 
    131138    std::cout << "SQL Error: " << pEx.what() << std::endl; 
    132     std::cout << "While executing: " << std::endl << pEx.getQuery() << std::endl; 
     139    std::cout << "While executing: " << std::endl  
     140      << pEx.getQuery() << std::endl; 
    133141  } catch (const dba::Exception& pEx) { 
    134142    std::cout << "Error: " << pEx.what() << std::endl;