2018-08-25 18:11:12 +02:00
|
|
|
|
#ifndef PGOBJECT_H
|
|
|
|
|
|
#define PGOBJECT_H
|
|
|
|
|
|
|
2018-11-25 19:45:06 +01:00
|
|
|
|
#include <libpq-fe.h>
|
2018-11-18 19:30:45 +01:00
|
|
|
|
#include <QString>
|
2018-08-25 18:11:12 +02:00
|
|
|
|
|
|
|
|
|
|
class PgDatabaseCatalog;
|
|
|
|
|
|
|
2018-11-18 19:30:45 +01:00
|
|
|
|
class PgObject {
|
2018-08-25 18:11:12 +02:00
|
|
|
|
public:
|
2018-11-25 19:45:06 +01:00
|
|
|
|
explicit PgObject(PgDatabaseCatalog& cat, Oid oid, const QString &name);
|
2018-11-18 19:30:45 +01:00
|
|
|
|
virtual ~PgObject();
|
|
|
|
|
|
|
2018-11-25 19:45:06 +01:00
|
|
|
|
Oid oid() const;
|
|
|
|
|
|
const QString& objectName() const;
|
2018-11-18 19:30:45 +01:00
|
|
|
|
/// Default implementation uses objectName and add quotes when needed.
|
|
|
|
|
|
virtual QString quotedObjectName() const;
|
2018-12-25 13:17:04 +01:00
|
|
|
|
/// By default same as quotedObjectName however for objects that reside in namespaces
|
|
|
|
|
|
/// the namespace name is added to the name.
|
|
|
|
|
|
virtual QString fullyQualifiedQuotedObjectName() const;
|
2018-12-24 11:31:56 +01:00
|
|
|
|
virtual QString typeName() const = 0;
|
2018-11-18 19:30:45 +01:00
|
|
|
|
|
2018-11-25 19:45:06 +01:00
|
|
|
|
bool operator==(Oid _oid) const { return m_oid == _oid; }
|
|
|
|
|
|
bool operator==(const QString &n) const { return m_name == n; }
|
|
|
|
|
|
bool operator<(Oid _oid) const { return m_oid < _oid; }
|
|
|
|
|
|
bool operator<(const PgObject &rhs) const { return m_oid < rhs.m_oid; }
|
2018-08-25 18:11:12 +02:00
|
|
|
|
protected:
|
2018-11-18 19:30:45 +01:00
|
|
|
|
const PgDatabaseCatalog& catalog() const;
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
PgDatabaseCatalog* m_catalog;
|
2018-11-25 19:45:06 +01:00
|
|
|
|
Oid m_oid;
|
|
|
|
|
|
QString m_name;
|
2018-08-25 18:11:12 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // PGOBJECT_H
|