LibEngsas
esqlfield.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 2012 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 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  Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public
15  License along with this library; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17  MA 02110-1301 USA.
18 */
19 
20 #ifndef ESQLFIELD_H
21 #define ESQLFIELD_H
22 
23 #include "eglobal.h"
24 #include "eobject.h"
25 
26 #include <QString>
27 #include <QVariant>
28 #include <QMultiHash>
29 
40 {
41  Q_OBJECT
42  public:
43  enum Type { NoType, Integer, Text, Varchar, Boolean, Date, Time, Tinyint, Double, Timestamp, Blob, LongBlob };
44 
45  ESqlField(QObject* parent = 0);
46  ESqlField ( QString myName, ESqlField::Type myType = ESqlField::NoType, bool notNull = false, bool autoIncrement = false, QObject* parent = 0 );
47  bool isValid() const;
48  QString name() const;
49  void setName ( QString myName );
50  bool isPrimaryKey() const;
51  void setIsPrimaryKey ( bool status );
52  bool autoIncrement() const;
53  void setAutoIncrement ( bool status );
54  bool notNull() const;
55  void setNotNull ( bool status );
56  QVariant defaultValue() const;
57  void setDefaultValue ( QVariant value );
58  ESqlField::Type dataType() const;
59  void setDataType ( ESqlField::Type myType );
60  unsigned int length() const;
61  void setLength ( unsigned int len );
62  bool isUnsigned() const;
63  void setIsUnsigned ( bool status );
64  bool isBinary() const;
65  void setIsBinary ( bool status );
66  bool zeroFill() const;
67  void setZeroFill ( bool status );
68  QString sqlFieldType() const;
76  QString createStatement( EngSaS::SQL::DatabaseType type);
77 
78  ESqlField *copy() const;
79 
80  bool operator== (const ESqlField &field) const;
81  bool operator!= (const ESqlField &field) const;
82 
83  private:
84  QString fieldName;
85  bool pk;
86  bool ai;
87  bool nn;
88  QVariant fieldDefValue;
90  unsigned int fieldLength;
91  bool binary;
93  bool zf;
94  QMultiHash<int, QString> convFieldTypes;
95 
96  void init();
97 };
98 
99 #endif // ESQLFIELD_H
Mostly the same as EWidget but for QObject as base class.
Definition: eobject.h:42
bool ai
Definition: esqlfield.h:86
bool fieldUnsigned
Definition: esqlfield.h:92
unsigned int fieldLength
Definition: esqlfield.h:90
#define E_CORE_EXPORT
Definition: eglobal.h:107
bool pk
Definition: esqlfield.h:85
Definition: esqlfield.h:43
bool nn
Definition: esqlfield.h:87
bool binary
Definition: esqlfield.h:91
QString fieldName
Definition: esqlfield.h:84
QVariant fieldDefValue
Definition: esqlfield.h:88
Represents an field in an sql table.This class is used with ESqlInit to define database schemas...
Definition: esqlfield.h:39
Definition: esqlfield.h:43
QMultiHash< int, QString > convFieldTypes
Definition: esqlfield.h:94
ESqlField::Type fieldType
Definition: esqlfield.h:89
DatabaseType
Choose the type of the used database.
Definition: eglobal.h:181
bool zf
Definition: esqlfield.h:93
Type
Definition: esqlfield.h:43