kexi

fieldlist.h
1/* This file is part of the KDE project
2 Copyright (C) 2003-2007 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_FIELDLIST_H
21#define KEXIDB_FIELDLIST_H
22
23#include <tqvaluelist.h>
24#include <tqdict.h>
25#include <tqstring.h>
26
27#include <kexidb/field.h>
28#include <kexidb/driver.h>
29
30namespace KexiDB {
31
32class Connection;
33
37class KEXI_DB_EXPORT FieldList
38{
39 public:
46 FieldList(bool owner = false);
47
51 FieldList(const FieldList& fl, bool deepCopyFields = true);
52
55 virtual ~FieldList();
56
58 inline uint fieldCount() const { return m_fields.count(); }
59
61 FieldList& addField(Field *field);
62
67 virtual FieldList& insertField(uint index, Field *field);
68
73 virtual void removeField(KexiDB::Field *field);
74
76 inline Field* field(uint id) { return (id < m_fields.count()) ? m_fields.at(id) : 0; }
77
79 virtual Field* field(const TQString& name);
80
82 inline bool hasField(const Field* field) { return m_fields.findRef(field)!=-1; }
83
86 inline int indexOf(const Field* field) { return m_fields.findRef(field); }
87
89 TQStringList names() const;
90
91 Field::ListIterator fieldsIterator() const { return Field::ListIterator(m_fields); }
92
93 inline Field::List* fields() { return &m_fields; }
94
96 Field::List* autoIncrementFields();
97
99 inline bool isOwner() const { return m_fields.autoDelete(); }
100
102 virtual void clear();
103
105 virtual TQString debugString();
106
108 void debug();
109
118 FieldList* subList(const TQString& n1, const TQString& n2 = TQString(),
119 const TQString& n3 = TQString(), const TQString& n4 = TQString(),
120 const TQString& n5 = TQString(), const TQString& n6 = TQString(),
121 const TQString& n7 = TQString(), const TQString& n8 = TQString(),
122 const TQString& n9 = TQString(), const TQString& n10 = TQString(),
123 const TQString& n11 = TQString(), const TQString& n12 = TQString(),
124 const TQString& n13 = TQString(), const TQString& n14 = TQString(),
125 const TQString& n15 = TQString(), const TQString& n16 = TQString(),
126 const TQString& n17 = TQString(), const TQString& n18 = TQString()
127 );
128
130 FieldList* subList(const TQStringList& list);
131
133 FieldList* subList(const TQValueList<uint>& list);
134
146 TQString sqlFieldsList(Driver *driver, const TQString& separator = TQString::fromLatin1(","),
147 const TQString& tableAlias = TQString(),
148 int drvEscaping = Driver::EscapeDriver|Driver::EscapeAsNecessary);
149
151 static TQString sqlFieldsList(Field::List* list, Driver *driver,
152 const TQString& separator = TQString::fromLatin1(","), const TQString& tableAlias = TQString(),
153 int drvEscaping = Driver::EscapeDriver|Driver::EscapeAsNecessary);
154
157 void renameField(const TQString& oldName, const TQString& newName);
158
161 void renameField(KexiDB::Field *field, const TQString& newName);
162
163 protected:
164 Field::List m_fields;
165 TQDict<Field> m_fields_by_name;
166 Field::List *m_autoinc_fields;
167
168 private:
170 TQString m_sqlFields;
171};
172
173} //namespace KexiDB
174
175#endif
Generic database abstraction.
Definition driver.h:67
bool hasField(const Field *field)
Definition fieldlist.h:82
bool isOwner() const
Definition fieldlist.h:99
uint fieldCount() const
Definition fieldlist.h:58
Field * field(uint id)
Definition fieldlist.h:76
TQDict< Field > m_fields_by_name
Fields collected by name. Not used by QuerySchema.
Definition fieldlist.h:165
int indexOf(const Field *field)
Definition fieldlist.h:86
Meta-data for a field.
Definition field.h:73
TQPtrList< Field > List
list of fields
Definition field.h:75
TQPtrListIterator< Field > ListIterator
iterator for list of fields
Definition field.h:77
High-level database connectivity library with database backend drivers.
KEXI_DB_EXPORT void debug(const QuerySchemaParameterList &list)
Shows debug information for list.