Hello,
No, QxOrm library doesn't check enum values, you could use property bag if you want to use introspection engine of QxOrm library but this is not a perfect solution.
Some databases support enum type, so you can put a control on database side.
If you want to check on C++ side and want introspection on enums, because QxOrm is based on Qt, you can use Q_ENUM :
http://doc.qt.io/qt-5/qobject.html#Q_ENUMI think that Q_ENUM provides everything to know all enum's values by introspection.
I would recommend (but this is not necessary) to put all your enums in a seperate entity (not directly in the persistent class), for example QxEntityEditor creates a specific entity for each enum, for example :
- Code: Select all
class QXBLOG_EXPORT sex : public QObject
{
Q_OBJECT
Q_ENUMS(sex::enum_sex)
public:
enum enum_sex
{
male = 1,
female = 2,
unknown = 3
};
private:
sex();
virtual ~sex();
};
Then, if you want to check enums values before inserting/updating in database, you can use a validator method.
This is explained in the QxOrm manual here :
https://www.qxorm.com/qxorm_en/manual.html#manual_420Your validator method could be a generic method using Q_ENUM introspection.