sptk2 logo
SPTK Home Page
DatabaseField.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/sptk.h>
30
31#include <sptk5/Field.h>
32#include <sptk5/Strings.h>
33#include <sptk5/Variant.h>
34
35namespace sptk {
36
48class SP_EXPORT DatabaseField
49 : public Field
50{
51 friend class Query;
52
53public:
63 DatabaseField(const String& fieldName, int fieldColumn, int fieldType, VariantDataType dataType, int fieldLength,
64 int fieldScale = 4);
65
72 void checkSize(size_t sz);
73
81 void setDataSize(size_t sz)
82 {
83 dataSize(sz);
84 }
85
90 int fieldColumn() const
91 {
92 return m_fldColumn;
93 }
94
99 int fieldType() const
100 {
101 return m_fldType;
102 }
103
108 uint32_t fieldSize() const
109 {
110 return (uint32_t) m_fldSize;
111 }
112
118 {
119 return m_displayFormat;
120 }
121
125 void displayFormat(const String& format)
126 {
127 m_displayFormat = format;
128 }
129
134 int alignment() const
135 {
136 return m_alignment;
137 }
138
142 void alignment(int al)
143 {
144 m_alignment = al;
145 }
146
147protected:
154 void setFieldType(int fieldType, int fieldLength, int fieldScale)
155 {
156 m_fldType = fieldType;
157 m_fldSize = fieldLength;
158 m_fldScale = fieldScale;
159 }
160
161 String doubleDataToString() const override;
162
163private:
164 int m_fldType;
165 int m_fldColumn;
166 int m_fldSize;
167 int m_fldScale;
168 String m_displayFormat;
169 int m_alignment {ALIGN_LEFT};
170};
171
172using SDatabaseField = std::shared_ptr<DatabaseField>;
173
177} // namespace sptk
database field
Definition: DatabaseField.h:50
int alignment() const
Definition: DatabaseField.h:134
DatabaseField(const String &fieldName, int fieldColumn, int fieldType, VariantDataType dataType, int fieldLength, int fieldScale=4)
void setDataSize(size_t sz)
Sets the internal data size.
Definition: DatabaseField.h:81
void setFieldType(int fieldType, int fieldLength, int fieldScale)
Definition: DatabaseField.h:154
String displayFormat() const
Definition: DatabaseField.h:117
void checkSize(size_t sz)
Checks the internal buffer size.
uint32_t fieldSize() const
Definition: DatabaseField.h:108
void displayFormat(const String &format)
Definition: DatabaseField.h:125
int fieldType() const
Definition: DatabaseField.h:99
int fieldColumn() const
Definition: DatabaseField.h:90
void alignment(int al)
Definition: DatabaseField.h:142
Definition: Field.h:54
Definition: Query.h:239
Definition: String.h:49
VariantDataType
Definition: VariantData.h:44

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