kexi

roweditbuffer.h
1/* This file is part of the KDE project
2 Copyright (C) 2003, 2006 Jaroslaw Staniek <js@iidea.pl>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#ifndef KEXIDB_ROWEDITBUFFER_H
21#define KEXIDB_ROWEDITBUFFER_H
22
23#include <tqmap.h>
24
25#include <kexidb/field.h>
26#include <kexidb/queryschema.h>
27
28namespace KexiDB {
29
74class KEXI_DB_EXPORT RowEditBuffer {
75public:
76 typedef TQStringVariantMap SimpleMap;
77 typedef TQMap<QueryColumnInfo*,TQVariant> DBMap;
78
79 RowEditBuffer(bool dbAwareBuffer);
80 ~RowEditBuffer();
81
82 inline bool isDBAware() const { return m_dbBuffer!=0; }
83
84 void clear();
85
86 bool isEmpty() const;
87
89 inline void insert( QueryColumnInfo& ci, TQVariant &val ) {
90 if (m_dbBuffer) {
91 m_dbBuffer->insert(&ci, val);
92 m_defaultValuesDbBuffer->remove(&ci);
93 }
94 }
95
97 inline void insert( const TQString& fname, TQVariant &val )
98 { if (m_simpleBuffer) m_simpleBuffer->insert(fname,val); }
99
105 const TQVariant* at( QueryColumnInfo& ci, bool useDefaultValueIfPossible = true ) const;
106
108 const TQVariant* at( Field& f ) const;
109
111 const TQVariant* at( const TQString& fname ) const;
112
115 inline bool hasDefaultValueAt( QueryColumnInfo& ci ) const {
116 return m_defaultValuesDbBuffer->contains(&ci) && (*m_defaultValuesDbBuffer)[ &ci ];
117 }
118
119 inline const SimpleMap simpleBuffer() { return *m_simpleBuffer; }
120 inline const DBMap dbBuffer() { return *m_dbBuffer; }
121
123 void debug();
124
125protected:
126 SimpleMap *m_simpleBuffer;
127 SimpleMap::ConstIterator *m_simpleBufferIt;
128 DBMap *m_dbBuffer;
129 DBMap::Iterator *m_dbBufferIt;
130 TQMap<QueryColumnInfo*,bool> *m_defaultValuesDbBuffer;
131 TQMap<QueryColumnInfo*,bool>::ConstIterator *m_defaultValuesDbBufferIt;
132};
133
134} //namespace KexiDB
135
136#endif
Meta-data for a field.
Definition field.h:73
Helper class that assigns additional information for the column in a query.
Definition queryschema.h:49
void insert(QueryColumnInfo &ci, TQVariant &val)
Inserts value val for db-aware buffer's column ci.
bool hasDefaultValueAt(QueryColumnInfo &ci) const
void insert(const TQString &fname, TQVariant &val)
Inserts value val for not-db-aware buffer's column fname.
High-level database connectivity library with database backend drivers.
KEXI_DB_EXPORT void debug(const QuerySchemaParameterList &list)
Shows debug information for list.