Back to index

lshw  02.16
db.h
Go to the documentation of this file.
00001 #ifndef _DB_H_
00002 #define _DB_H_
00003 
00004 #include <string>
00005 #include <iostream>
00006 
00007 namespace sqlite {
00008 
00009 class database
00010 {
00011   public:
00012 
00013        database(const std::string & filename);
00014        database(const database & db);
00015        ~database();
00016 
00017        database operator =(const database &);
00018 
00019        void execute(const std::string & sql);
00020 
00021        friend class statement;
00022 
00023   private:
00024        database();
00025 
00026        struct database_i *implementation;
00027 };
00028 
00029 typedef enum {
00030        null,
00031        text,
00032        integer,
00033        real,
00034        blob} type;
00035 
00036 class value
00037 {
00038   public:
00039 
00040        value();
00041        value(const char *);
00042        value(const std::string &);
00043        value(long long);
00044        value(double);
00045        value(const value &);
00046        ~value();
00047 
00048        value & operator =(const value &);
00049 
00050        type getType() const;
00051        std::string asText() const;
00052        long long asInteger() const;
00053        double asReal() const;
00054 
00055        std::ostream & print(std::ostream &) const;
00056 
00057   private:
00058        struct value_i *implementation;
00059 };
00060 
00061 class statement
00062 {
00063   public:
00064 
00065        statement(database &, const std::string &);
00066        ~statement();
00067 
00068        void prepare(const std::string &);
00069 
00070        void bind(int index, const value & v);
00071        bool step();
00072        void execute();
00073        void reset();
00074 
00075        int columns() const;
00076        value column(unsigned int) const;
00077        value column(const std::string &) const;
00078 
00079        value operator[](unsigned int) const;
00080        value operator[](const std::string &) const;
00081        
00082   private:
00083 
00084        statement();
00085        statement(const statement &);
00086        statement & operator =(const statement &);
00087 
00088        struct statement_i *implementation;
00089 };
00090 
00091 }; // namespace sqlite
00092 
00093 #endif