BPS C++ API  2.24.4
bpssqlvalues.h
Go to the documentation of this file.
1 
4 #ifndef BPSSQLVALUES_H
5 #define BPSSQLVALUES_H
6 
7 #include "bpscore_global.h"
8 #include "bpstypes.h"
9 #include <QVariantMap>
10 
11 class QSqlRecord;
12 
54 {
56 public:
57 
61  enum Condition {
65  CondUnequalOr
66  };
67 
72 
77  BpsSqlValues(const BpsSqlValues& aOther);
78 
83  BpsSqlValues(const QVariantMap& aMap);
84 
89  BpsSqlValues(const QSqlRecord& aRec);
90 
91  virtual ~BpsSqlValues();
92 
96  bool isEmpty() const;
97 
102  QString columns(const QString& aPrefix = QString()) const;
103 
107  QString tags() const;
108 
114  QString pairs(const QString& aPrefix = QString()) const;
115 
122  QString condPairs(const QString& aSeparator, const QString& aPrefix = QString()) const;
123 
136  QString condPairs(Condition aCondition = CondEqualAnd, const QString& aPrefix = QString()) const;
137 
142  QStringList keys(const QString& aPrefix = QString()) const;
143 
147  QVariantList values() const;
148 
154  void insert(const QString& aKey, const QVariant& aValue);
155 
160  void insert(const BpsSqlValues& aOther);
161 
167  int remove(const QString& aKey);
168 
172  QVariantMap map() const;
173 
178  void setMap(const QVariantMap& aMap);
179 
183  void clear();
184 
192  QVariant& operator[](const QString& aName);
193 
200  const QVariant operator[](const QString& aName) const;
201 
207  QVariant value(const QString& aName) const;
208 
214  BpsSqlValues& operator=(const QVariantMap& aOther);
215 
222 
229 
233  inline operator QVariant() const;
234 };
235 
236 inline BpsSqlValues::operator QVariant() const
237 {
238  return QVariant::fromValue(*this);
239 } // operator QVariant
240 
241 Q_DECLARE_METATYPE(BpsSqlValues)
242 
243 
244 #endif // BPSSQLVALUES_H
Public include file for BPS CORE library macros.
#define BPSCORE_EXPORT
Declare class to be an import from the shared library.
Definition: bpscore_global.h:22
#define BPS_PRIVATE(Class)
Declare pointer to private object in a public class.
Definition: bpsglobals.h:102
Convenience class to help composing select, insert and update statements.
Definition: bpssqlvalues.h:54
QStringList keys(const QString &aPrefix=QString()) const
void insert(const QString &aKey, const QVariant &aValue)
Insert a key/value pair.
BpsSqlValues()
Default constructor for an empty record.
BpsSqlValues & operator=(const BpsSqlValues &aOther)
Assign other sql values to this object.
QString condPairs(Condition aCondition=CondEqualAnd, const QString &aPrefix=QString()) const
Get list of pairs as used for select conditions.
QString tags() const
QVariantList values() const
BpsSqlValues & operator=(const QVariantMap &aOther)
Assign other variant map to this object.
QString columns(const QString &aPrefix=QString()) const
BpsSqlValues(const QVariantMap &aMap)
Create object from a variant map.
const QVariant operator[](const QString &aName) const
Get the named columns value.
Condition
Conditon pair building modes.
Definition: bpssqlvalues.h:61
@ CondEqualAnd
Compare if equal and combine the pairs with AND: c_aaa=? and c_bbb=? ...
Definition: bpssqlvalues.h:62
@ CondEqualOr
Compare if equal and combine the pairs with OR: c_aaa=? or c_bbb=? ...
Definition: bpssqlvalues.h:64
@ CondUnequalAnd
Compare if not equal and combine the pairs with AND: c_aaa<>? and c_bbb<>? ...
Definition: bpssqlvalues.h:63
QString condPairs(const QString &aSeparator, const QString &aPrefix=QString()) const
Get list of pairs as used for select conditions (depreciated).
void clear()
Clear the internal map.
QVariant & operator[](const QString &aName)
Get the value associated with the key aName as a modifiable reference.
void setMap(const QVariantMap &aMap)
Set the internal map.
int remove(const QString &aKey)
Removes all the items that have the key aKey from the map.
bool isEmpty() const
QString pairs(const QString &aPrefix=QString()) const
Get list of pairs as used for update statements.
QVariantMap map() const
void insert(const BpsSqlValues &aOther)
Inserts (merges) all key/value pairs from the other BpsSqlValues object.
QVariant value(const QString &aName) const
Get the named columns value.
BpsSqlValues(const BpsSqlValues &aOther)
Copy constructor.
BpsSqlValues & operator=(const QSqlRecord &aOther)
Assign values of a sql record to this object.
BpsSqlValues(const QSqlRecord &aRec)
Create object from a sql record.
QVariant fromValue(const T &value)