sptk2 logo
SPTK Home Page
DataSource.h
1/*
2╔══════════════════════════════════════════════════════════════════════════════╗
3║ SIMPLY POWERFUL TOOLKIT (SPTK) ║
4╟──────────────────────────────────────────────────────────────────────────────╢
5║ copyright © 1999-2022 Alexey Parshin. All rights reserved. ║
6║ email alexeyp@gmail.com ║
7╚══════════════════════════════════════════════════════════════════════════════╝
8┌──────────────────────────────────────────────────────────────────────────────┐
9│ This library is free software; you can redistribute it and/or modify it │
10│ under the terms of the GNU Library General Public License as published by │
11│ the Free Software Foundation; either version 2 of the License, or (at your │
12│ option) any later version. │
13│ │
14│ This library is distributed in the hope that it will be useful, but │
15│ WITHOUT ANY WARRANTY; without even the implied warranty of │
16│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library │
17│ General Public License for more details. │
18│ │
19│ You should have received a copy of the GNU Library General Public License │
20│ along with this library; if not, write to the Free Software Foundation, │
21│ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. │
22│ │
23│ Please report all bugs and problems to alexeyp@gmail.com. │
24└──────────────────────────────────────────────────────────────────────────────┘
25*/
26
27#pragma once
28
29#include <sptk5/FieldList.h>
30#include <sptk5/Variant.h>
31
32class Fl_Group;
33
34namespace sptk {
35
48class SP_EXPORT DataSource
49{
50 friend class Fl_Group;
51
52public:
56 DataSource() = default;
57
61 virtual ~DataSource() = default;
62
70 virtual Field& operator[](size_t fieldIndex) = 0;
71
79 virtual Field& operator[](const String& fieldName) = 0;
80
87 virtual size_t fieldCount() const = 0;
88
95 virtual size_t recordCount() const = 0;
96
104 virtual bool readField(const char* fieldName, Variant& fieldValue) = 0;
105
113 virtual bool writeField(const char* fieldName, const Variant& fieldValue) = 0;
114
118 virtual bool open()
119 {
120 return false;
121 }
122
126 virtual bool close()
127 {
128 return false;
129 }
130
134 virtual bool first()
135 {
136 return false;
137 }
138
142 virtual bool next()
143 {
144 return false;
145 }
146
150 virtual bool prior()
151 {
152 return false;
153 }
154
158 virtual bool last()
159 {
160 return false;
161 }
162
166 virtual bool find(const String& /*fieldName*/, const Variant& /*position*/)
167 {
168 return false;
169 }
170
174 virtual bool eof() const
175 {
176 return false;
177 }
178
182 bool load();
183
187 bool save();
188
198 void exportRowTo(const xdoc::SNode& node, bool compactXmlMode, bool nullLargeData = false);
199
211 virtual void exportTo(xdoc::Node& parentNode, const String& nodeName, bool compactXmlMode);
212
213protected:
217 virtual bool loadData()
218 {
219 return true;
220 }
221
225 virtual bool saveData()
226 {
227 return true;
228 }
229};
230
234} // namespace sptk
Definition: DataSource.h:49
virtual bool eof() const
Definition: DataSource.h:174
virtual size_t recordCount() const =0
virtual bool readField(const char *fieldName, Variant &fieldValue)=0
void exportRowTo(const xdoc::SNode &node, bool compactXmlMode, bool nullLargeData=false)
virtual void exportTo(xdoc::Node &parentNode, const String &nodeName, bool compactXmlMode)
virtual bool prior()
Definition: DataSource.h:150
virtual bool find(const String &, const Variant &)
Definition: DataSource.h:166
virtual bool loadData()
Definition: DataSource.h:217
virtual ~DataSource()=default
virtual bool first()
Definition: DataSource.h:134
virtual size_t fieldCount() const =0
virtual bool open()
Definition: DataSource.h:118
virtual bool last()
Definition: DataSource.h:158
virtual bool close()
Definition: DataSource.h:126
virtual bool writeField(const char *fieldName, const Variant &fieldValue)=0
DataSource()=default
virtual bool next()
Definition: DataSource.h:142
virtual Field & operator[](const String &fieldName)=0
virtual Field & operator[](size_t fieldIndex)=0
virtual bool saveData()
Definition: DataSource.h:225
Definition: Field.h:54
Definition: String.h:49
Definition: Variant.h:372
Definition: Node.h:48

Fri Oct 14 2022 09:58:31: SPTK 5.4.1