LTP GCOV extension - code coverage report
Current view: directory - src/libstore - db.hh
Test: app.info
Date: 2008-11-20 Instrumented lines: 2
Code covered: 0.0 % Executed lines: 0

       1                 : #ifndef __DB_H
       2                 : #define __DB_H
       3                 : 
       4                 : #include "types.hh"
       5                 : 
       6                 : #include <map>
       7                 : 
       8                 : 
       9                 : /* Defined externally. */
      10                 : class DbTxn;
      11                 : class DbEnv;
      12                 : class Db;
      13                 : 
      14                 : 
      15                 : namespace nix {
      16                 : 
      17                 : 
      18                 : class Database;
      19                 : 
      20                 : 
      21                 : class Transaction
      22                 : {
      23                 :     friend class Database;
      24                 : 
      25                 : private:
      26                 :     DbTxn * txn;
      27                 :     
      28                 : public:
      29                 :     Transaction();
      30                 :     Transaction(Database & _db);
      31                 :     ~Transaction();
      32                 : 
      33                 :     void begin(Database & db);
      34                 :     void abort();
      35                 :     void commit();
      36                 : 
      37                 :     void moveTo(Transaction & t);
      38                 : };
      39                 : 
      40                 : 
      41                 : #define noTxn Transaction()
      42                 : 
      43                 : 
      44                 : typedef unsigned int TableId; /* table handles */
      45                 : 
      46                 : 
      47                 : class Database
      48                 : {
      49                 :     friend class Transaction;
      50                 : 
      51                 : private:
      52                 :     DbEnv * env;
      53                 : 
      54                 :     TableId nextId;
      55                 :     std::map<TableId, Db *> tables;
      56                 : 
      57                 :     void requireEnv();
      58                 : 
      59                 :     Db * getDb(TableId table);
      60                 : 
      61                 :     void open2(const string & path, bool removeOldEnv);
      62                 :     
      63                 : public:
      64                 :     Database();
      65                 :     ~Database();
      66                 :     
      67                 :     void open(const string & path);
      68                 :     void close();
      69                 : 
      70                 :     TableId openTable(const string & table, bool sorted = false);
      71                 :     void closeTable(TableId table);
      72                 :     void deleteTable(const string & table);
      73                 : 
      74                 :     bool queryString(const Transaction & txn, TableId table, 
      75                 :         const string & key, string & data);
      76                 : 
      77                 :     bool queryStrings(const Transaction & txn, TableId table, 
      78                 :         const string & key, Strings & data);
      79                 : 
      80                 :     void setString(const Transaction & txn, TableId table,
      81                 :         const string & key, const string & data);
      82                 : 
      83                 :     void setStrings(const Transaction & txn, TableId table,
      84                 :         const string & key, const Strings & data,
      85                 :         bool deleteEmpty = true);
      86                 : 
      87                 :     void delPair(const Transaction & txn, TableId table,
      88                 :         const string & key);
      89                 : 
      90                 :     void enumTable(const Transaction & txn, TableId table,
      91                 :         Strings & keys, const string & keyPrefix = "");
      92                 : 
      93                 :     void clearTable(const Transaction & txn, TableId table);
      94                 : };
      95                 : 
      96                 : 
      97                 : class DbNoPermission : public Error
      98               0 : {
      99                 : public:
     100               0 :     DbNoPermission(const format & f) : Error(f) { };
     101                 : };
     102                 : 
     103                 :  
     104                 : }
     105                 : 
     106                 : 
     107                 : #endif /* !__DB_H */

Generated by: LTP GCOV extension version 1.6