summaryrefslogtreecommitdiff
path: root/project2/tablepatch.h
blob: 017429411065764f798b30bf412792acc76cb38e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef TABLEPATCH_H
#define TABLEPATCH_H

#include <string>
#include <set>
#include <map>
#include <connection.h>
#include <modifycommand.h>
#include <selectcommand.h>

class TablePatch {
    public:
        typedef std::string Table;
        typedef std::string Column;
        typedef std::set<Column> Columns;
        typedef Columns PrimaryKey;
        typedef PrimaryKey::const_iterator PKI;

        class PatchCheckFailure : public std::exception {
            public:
                const char * what() const throw();
        };

        TablePatch(const DB::Connection & db, const Table & src, const Table & dest, const Columns & cols);

        void            addKey(const Column & col);
        void            patch(const char * where, const char * order);

    private:
        void            doDeletes(const char * where, const char * order);
        void            doUpdates(const char * where, const char * order);
        void            doInserts(const char * order);

        Table           src;
        Table           dest;
        PrimaryKey      pk;
        Columns 		cols;
        const DB::Connection &db;
};

#endif