summaryrefslogtreecommitdiff
path: root/libopie2/opiedb/osqltable.h
blob: 86c30dd89b486a3735f4a590aa2746992f2dc28c (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#ifndef OSQL_TABLE_H
#define OSQL_TABLE_H

#include <qstring.h>
#include <qvaluelist.h>
#include <qvariant.h>

namespace Opie {
namespace DB {
/**
 * OSQLTableItem saves one column of a complete
 * table
 */
class OSQLTableItem {
public:
    typedef QValueList<OSQLTableItem> ValueList;
    /**
     * Type kinds ( to be extended )
     */
    enum Type { Undefined=-1, Integer=0, BigInteger =1,
                Float = 2, VarChar = 4 };
    /**
     * A constructor
     * @param type the Type of the Column
     * @param fieldName the Name of the Column
     * @param var a Variant
     */
    OSQLTableItem();
    OSQLTableItem( enum Type type,
                   const QString& fieldName,
                   const QVariant& var= QVariant() );

    /**
     * copy c'tor
     */
    OSQLTableItem( const OSQLTableItem& );

    /**
     * d'tor
     */
    ~OSQLTableItem();

    OSQLTableItem& operator=( const OSQLTableItem& );

    /**
     * the fieldName
     */
    QString fieldName() const;

    /**
     * the field Type
     */
    Type type() const;
    QVariant more() const;
private:
    class OSQLTableItemPrivate;
    OSQLTableItemPrivate* d;
    Type m_type;
    QString m_field;
    QVariant m_var;
};

/**
 * A OSQLTable consists of OSQLTableItems
 */
class OSQLTable  {
public:
    typedef QValueList<OSQLTable> ValueList;

    /**
     * @param tableName the Name of the Table
     */
    OSQLTable(const QString& tableName);

    /**
     * d'tor
     */
    ~OSQLTable();

    /**
     * setColumns sets the Columns of the Table
     */
    void setColumns( const OSQLTableItem::ValueList& );

    /**
     * returns all columns of the table
     */
    OSQLTableItem::ValueList columns() const;

    QString tableName()const;

private:
    QString m_table;
    OSQLTableItem::ValueList m_list;
    class Private;
    Private *d;
};

}
}

#endif